tvalentyn commented on code in PR #22164:
URL: https://github.com/apache/beam/pull/22164#discussion_r930146853
##########
sdks/python/apache_beam/examples/inference/pytorch_image_classification.py:
##########
@@ -120,27 +130,35 @@ def run(argv=None, model_class=None, model_params=None,
save_main_session=True):
model_class=model_class,
model_params=model_params))
- with beam.Pipeline(options=pipeline_options) as p:
- filename_value_pair = (
- p
- | 'ReadImageNames' >> beam.io.ReadFromText(
- known_args.input, skip_header_lines=1)
- | 'ReadImageData' >> beam.Map(
- lambda image_name: read_image(
- image_file_name=image_name, path_to_dir=known_args.images_dir))
- | 'PreprocessImages' >> beam.MapTuple(
- lambda file_name, data: (file_name, preprocess_image(data))))
- predictions = (
- filename_value_pair
- | 'PyTorchRunInference' >> RunInference(model_handler)
- | 'ProcessOutput' >> beam.ParDo(PostProcessor()))
-
- if known_args.output:
- predictions | "WriteOutputToGCS" >> beam.io.WriteToText( # pylint:
disable=expression-not-assigned
- known_args.output,
- shard_name_template='',
- append_trailing_newlines=True)
+ if not test_pipeline:
Review Comment:
I understand that, i meant that we could call the `test_pipeline` args just
`pipeline`, and then have the code like:
```
...
pipeline: used for internal testing. No backwards-compatibility,
...
if not pipeline:
pipeline = ...
```
--
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]