mik-laj commented on a change in pull request #7809: Run Dataflow for ML Engine
summary in venv
URL: https://github.com/apache/airflow/pull/7809#discussion_r396172462
##########
File path: airflow/providers/google/cloud/utils/mlengine_prediction_summary.py
##########
@@ -156,23 +157,22 @@ def run(argv=None):
raise ValueError("--metric_fn_encoded must be an encoded callable.")
metric_keys = known_args.metric_keys.split(",")
- with beam.Pipeline(
- options=beam.pipeline.PipelineOptions(pipeline_args)) as pipe:
- # This is apache-beam ptransform's convention
+ with beam.Pipeline(options=beam.pipeline.PipelineOptions(pipeline_args))
as p:
# pylint: disable=no-value-for-parameter
- _ = (pipe
- | "ReadPredictionResult" >> beam.io.ReadFromText(
- os.path.join(known_args.prediction_path,
- "prediction.results-*-of-*"),
- coder=JsonCoder())
- | "Summary" >> MakeSummary(metric_fn, metric_keys)
- | "Write" >> beam.io.WriteToText(
- os.path.join(known_args.prediction_path,
- "prediction.summary.json"),
- shard_name_template='', # without trailing -NNNNN-of-NNNNN.
- coder=JsonCoder()))
- # pylint: enable=no-value-for-parameter
+ prediction_result_pattern = os.path.join(known_args.prediction_path,
"prediction.results-*-of-*")
+ prediction_summary_path = os.path.join(known_args.prediction_path,
"prediction.summary.json")
+ # This is apache-beam ptransform's convention
+ _ = (
+ p | "ReadPredictionResult" >>
beam.io.ReadFromText(prediction_result_pattern, coder=JsonCoder())
+ | "Summary" >> MakeSummary(metric_fn, metric_keys)
+ | "Write" >> beam.io.WriteToText(
+ prediction_summary_path,
+ shard_name_template='', # without trailing
-NNNNN-of-NNNNN.
+ coder=JsonCoder()
+ )
+ )
if __name__ == "__main__":
+ logging.getLogger().setLevel(logging.INFO)
Review comment:
Dataflow does not print anything on the screen by default. Good practice
says to configure the logger to be able to track the progress. This code is run
in a separate process, so it's safe.
----------------------------------------------------------------
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]
With regards,
Apache Git Services