Abacn commented on code in PR #32058:
URL: https://github.com/apache/beam/pull/32058#discussion_r1702214257


##########
runners/prism/java/src/main/java/org/apache/beam/runners/prism/ArtifactResolver.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.runners.prism;
+
+import static 
org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkState;
+
+import com.google.auto.value.AutoValue;
+import java.util.Optional;
+import org.apache.beam.model.pipeline.v1.RunnerApi;
+import org.apache.beam.sdk.Pipeline;
+import org.apache.beam.sdk.options.PipelineOptions;
+import org.apache.beam.sdk.util.construction.DefaultArtifactResolver;
+import org.apache.beam.sdk.util.construction.PipelineTranslation;
+import org.apache.beam.sdk.util.construction.SdkComponents;
+
+/**
+ * The {@link ArtifactResolver} converts a {@link Pipeline} to a {@link 
RunnerApi.Pipeline} via
+ * resolving {@link RunnerApi.ArtifactInformation}.
+ */
+@AutoValue
+abstract class ArtifactResolver {
+
+  /**
+   * Instantiates a {@link ArtifactResolver} from the {@param pipeline}, 
applying defaults to the
+   * remaining dependencies.
+   */
+  static ArtifactResolver of(Pipeline pipeline) {
+    return ArtifactResolver.builder().setPipeline(pipeline).build();
+  }
+
+  static Builder builder() {
+    return new AutoValue_ArtifactResolver.Builder();
+  }
+
+  /**
+   * Converts the {@link #getPipeline()} using {@link 
PipelineTranslation#toProto} and {@link
+   * #getDelegate()}'s {@link
+   * org.apache.beam.sdk.util.construction.ArtifactResolver#resolveArtifacts}.
+   */
+  RunnerApi.Pipeline resolvePipelineProto() {
+    RunnerApi.Pipeline result = PipelineTranslation.toProto(getPipeline(), 
getSdkComponents());
+    return getDelegate().resolveArtifacts(result);
+  }
+
+  /**
+   * {@link ArtifactResolver} delegates to {@link
+   * org.apache.beam.sdk.util.construction.ArtifactResolver} to transform 
{@link
+   * RunnerApi.ArtifactInformation}. Defaults to {@link 
DefaultArtifactResolver#INSTANCE} if not
+   * set.
+   */
+  abstract org.apache.beam.sdk.util.construction.ArtifactResolver 
getDelegate();
+
+  /** The {@link Pipeline} from which {@link 
ArtifactResolver#resolvePipelineProto()}. */
+  abstract Pipeline getPipeline();
+
+  /**
+   * SDK objects that will be represented by {@link
+   * org.apache.beam.model.pipeline.v1.RunnerApi.Components}. Instantiated via 
{@link
+   * SdkComponents#create(PipelineOptions)} by default, where {@link 
PipelineOptions} are acquired
+   * from {@link #getPipeline}'s {@link Pipeline#getOptions}.
+   */
+  abstract SdkComponents getSdkComponents();
+
+  @AutoValue.Builder
+  abstract static class Builder {
+
+    abstract Builder setDelegate(
+        org.apache.beam.sdk.util.construction.ArtifactResolver 
artifactResolver);

Review Comment:
   since there is a naming conflict, consider PrismArtifactResolver? As there 
is already ArtifactResolver(interface); DefaultArtifactResolver(an impl), and 
this follows the same naming convention



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to