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

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

                Author: ASF GitHub Bot
            Created on: 22/Jul/20 00:50
            Start Date: 22/Jul/20 00:50
    Worklog Time Spent: 10m 
      Work Description: TheNeuralBit merged pull request #12333:
URL: https://github.com/apache/beam/pull/12333


   


----------------------------------------------------------------
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.

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


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

    Worklog Id:     (was: 461813)
    Time Spent: 50m  (was: 40m)

> Python SDK can't parse type=json.loads pipeline options at execution time
> -------------------------------------------------------------------------
>
>                 Key: BEAM-10274
>                 URL: https://issues.apache.org/jira/browse/BEAM-10274
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-py-core, sdk-py-harness
>            Reporter: Brian Hulette
>            Priority: P2
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> It's pretty common to use `type=json.loads` in argparse to create JSON 
> formatted options, in fact we have a couple in Beam: 
> https://github.com/apache/beam/blob/61b665640d6c0f91751bba59782c0ac6aceacba6/sdks/python/apache_beam/options/pipeline_options.py#L431-L443
> https://github.com/apache/beam/blob/61b665640d6c0f91751bba59782c0ac6aceacba6/sdks/python/apache_beam/options/pipeline_options.py#L577-L586
> Attempting to access these options at pipeline execution time yields an error 
> (note the single quotes):
> {code}
> argparse.ArgumentError: argument --beam_services: invalid loads value: 
> "{'foo': 'bar'}"
> {code}
> Why does this happen?
> - sdk_worker_main.py received these values from the PIPELINE_OPTIONS env var 
> which represents them as proper JSON: 
> {code}
> ..., "some_option": "some_value", "json_option": {"foo": "bar"}}, ...
> {code}
> - The json is loaded and parsed with PipelineOptions.from_dictionary: 
> https://github.com/apache/beam/blob/61b665640d6c0f91751bba59782c0ac6aceacba6/sdks/python/apache_beam/runners/worker/sdk_worker_main.py#L168-L181
> - from_dictionary just [writes out the value with 
> str(v)|https://github.com/apache/beam/blob/61b665640d6c0f91751bba59782c0ac6aceacba6/sdks/python/apache_beam/options/pipeline_options.py#L241-L249].
>  When the option is accessed we attempt re-parse it, and it's no longer valid 
> JSON, so json.loads fails.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to