You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "bvolpato (via GitHub)" <gi...@apache.org> on 2023/08/08 13:48:10 UTC

[GitHub] [beam] bvolpato commented on a diff in pull request #27841: Add PIPELINE_OPTIONS_FILE environment variable to allow PIPELINE_OPTIONS to be read from a file

bvolpato commented on code in PR #27841:
URL: https://github.com/apache/beam/pull/27841#discussion_r1287151799


##########
sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnHarness.java:
##########
@@ -117,11 +123,29 @@ public static void main(Function<String, String> environmentVarGetter) throws Ex
         "Control location %s%n", environmentVarGetter.apply(CONTROL_API_SERVICE_DESCRIPTOR));
     System.out.format(
         "Status location %s%n", environmentVarGetter.apply(STATUS_API_SERVICE_DESCRIPTOR));
-    System.out.format("Pipeline options %s%n", environmentVarGetter.apply(PIPELINE_OPTIONS));
-
     String id = environmentVarGetter.apply(HARNESS_ID);
-    PipelineOptions options =
-        PipelineOptionsTranslation.fromJson(environmentVarGetter.apply(PIPELINE_OPTIONS));
+
+    String pipelineOptionsJson = environmentVarGetter.apply(PIPELINE_OPTIONS);
+    // Try looking for a file first. If that exists it should override PIPELINE_OPTIONS to avoid
+    // maxing out the kernel's environment space
+    try {
+      String pipelineOptionsPath = environmentVarGetter.apply(PIPELINE_OPTIONS_FILE);
+      System.out.format("Pipeline Options File %s%n", pipelineOptionsPath);
+      if (pipelineOptionsPath != null) {
+        Path filePath = Paths.get(pipelineOptionsPath);
+        if (Files.exists(filePath)) {
+          System.out.format(
+              "Pipeline Options File %s exists. Overriding existing options.%n",
+              pipelineOptionsPath);
+          pipelineOptionsJson = new String(Files.readAllBytes(filePath), StandardCharsets.UTF_8);
+        }
+      }
+    } catch (Exception e) {
+      System.out.format("Problem loading pipeline options from file: %s%n", e.getMessage());
+    }
+
+    System.out.format("Pipeline options %s%n", pipelineOptionsJson);

Review Comment:
   Intentionally not using logger? 



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org