damccorm commented on code in PR #29564:
URL: https://github.com/apache/beam/pull/29564#discussion_r1417854711
##########
sdks/python/apache_beam/ml/transforms/base.py:
##########
@@ -404,20 +399,19 @@ def save_attributes(
**kwargs,
):
if _JsonPickleTransformAttributeManager._is_remote_path(artifact_location):
- try:
- options = kwargs.get('options')
- except KeyError:
- raise RuntimeError(
- 'pipeline options are required to save the attributes.'
- 'in the artifact location %s' % artifact_location)
-
temp_dir = tempfile.mkdtemp()
temp_json_file = os.path.join(temp_dir, _ATTRIBUTE_FILE_NAME)
with open(temp_json_file, 'w+') as f:
f.write(jsonpickle.encode(ptransform_list))
with open(temp_json_file, 'rb') as f:
from apache_beam.runners.dataflow.internal import apiclient
_LOGGER.info('Creating artifact location: %s', artifact_location)
+ # pipeline options required to for the client to configure project.
+ options = kwargs.get('options')
+ if not options:
+ raise RuntimeError(
+ 'pipeline options are required to save the attributes.'
+ 'in the artifact location %s' % artifact_location)
Review Comment:
I think I didn't quite explain what I meant here correctly. My idea was to
do something like:
```
try:
apiclient.DataflowApplicationClient(options=options).stage_file(
gcs_or_local_path=artifact_location,
file_name=_ATTRIBUTE_FILE_NAME,
stream=f,
mime_type='application/json')
except exc:
if not options:
raise RuntimeError(
'Failed to create Dataflow client. Pipeline options are
required to save the attributes.'
'in the artifact location %s' % artifact_location) from exc
raise
```
--
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]