[ 
https://issues.apache.org/jira/browse/BEAM-4176?focusedWorklogId=151564&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-151564
 ]

ASF GitHub Bot logged work on BEAM-4176:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Oct/18 09:50
            Start Date: 05/Oct/18 09:50
    Worklog Time Spent: 10m 
      Work Description: mxm commented on a change in pull request #6563: 
[BEAM-4176] Cleanup SDK Harness docker container
URL: https://github.com/apache/beam/pull/6563#discussion_r222951038
 
 

 ##########
 File path: 
runners/core-construction-java/src/main/java/org/apache/beam/runners/core/construction/PipelineOptionsTranslation.java
 ##########
 @@ -71,33 +72,45 @@ public static Struct toProto(PipelineOptions options) {
   }
 
   /** Converts the provided {@link Struct} into {@link PipelineOptions}. */
-  public static PipelineOptions fromProto(Struct protoOptions) throws 
IOException {
-    Map<String, TreeNode> mapWithoutUrns = new HashMap<>();
-    TreeNode rootOptions = 
MAPPER.readTree(JsonFormat.printer().print(protoOptions));
-    Iterator<String> optionsKeys = rootOptions.fieldNames();
-    while (optionsKeys.hasNext()) {
-      String optionKey = optionsKeys.next();
-      TreeNode optionValue = rootOptions.get(optionKey);
-      mapWithoutUrns.put(
-          CaseFormat.LOWER_UNDERSCORE.to(
-              CaseFormat.LOWER_CAMEL,
-              optionKey.substring("beam:option:".length(), optionKey.length() 
- ":v1".length())),
-          optionValue);
+  public static PipelineOptions fromProto(Struct protoOptions) {
+    try {
+      Map<String, TreeNode> mapWithoutUrns = new HashMap<>();
+      TreeNode rootOptions = 
MAPPER.readTree(JsonFormat.printer().print(protoOptions));
+      Iterator<String> optionsKeys = rootOptions.fieldNames();
+      while (optionsKeys.hasNext()) {
+        String optionKey = optionsKeys.next();
+        TreeNode optionValue = rootOptions.get(optionKey);
+        mapWithoutUrns.put(
+            CaseFormat.LOWER_UNDERSCORE.to(
+                CaseFormat.LOWER_CAMEL,
+                optionKey.substring("beam:option:".length(), 
optionKey.length() - ":v1".length())),
+            optionValue);
+      }
+      return MAPPER.readValue(
+          MAPPER.writeValueAsString(ImmutableMap.of("options", 
mapWithoutUrns)),
+          PipelineOptions.class);
+    } catch (IOException e) {
+      throw new RuntimeException(e);
 
 Review comment:
   I find it nice to add a descriptive message, e.g.
   ```
   new RuntimeException("Failed to read PipelineOptions from Protocol", e);
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 151564)
    Time Spent: 29.5h  (was: 29h 20m)

> Java: Portable batch runner passes all ValidatesRunner tests that 
> non-portable runner passes
> --------------------------------------------------------------------------------------------
>
>                 Key: BEAM-4176
>                 URL: https://issues.apache.org/jira/browse/BEAM-4176
>             Project: Beam
>          Issue Type: Bug
>          Components: runner-flink
>            Reporter: Ben Sidhom
>            Assignee: Ankur Goenka
>            Priority: Major
>         Attachments: 81VxNWtFtke.png, Screen Shot 2018-08-14 at 4.18.31 
> PM.png, Screen Shot 2018-09-03 at 11.07.38 AM.png
>
>          Time Spent: 29.5h
>  Remaining Estimate: 0h
>
> We need this as a sanity check that runner execution is correct.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to