From bf709ea4624d04f6b7294d045bb89b2f4922fc9a Mon Sep 17 00:00:00 2001 From: Danny McCormick Date: Thu, 9 Feb 2023 11:36:57 -0500 Subject: [PATCH] Fix typo - metdata -> metadata --- .../examples/inference/run_inference_side_inputs.py | 6 +++--- sdks/python/apache_beam/ml/inference/base.py | 10 +++++----- sdks/python/apache_beam/ml/inference/base_test.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sdks/python/apache_beam/examples/inference/run_inference_side_inputs.py b/sdks/python/apache_beam/examples/inference/run_inference_side_inputs.py index b89c9cc0e039..a6e4dc2bdb03 100644 --- a/sdks/python/apache_beam/examples/inference/run_inference_side_inputs.py +++ b/sdks/python/apache_beam/examples/inference/run_inference_side_inputs.py @@ -96,12 +96,12 @@ def run(argv=None, save_main_session=True): options.view_as(SetupOptions).save_main_session = save_main_session class GetModel(beam.DoFn): - def process(self, element) -> Iterable[base.ModelMetdata]: + def process(self, element) -> Iterable[base.ModelMetadata]: if time.time() > mid_ts: - yield base.ModelMetdata( + yield base.ModelMetadata( model_id='model_add.pkl', model_name='model_add') else: - yield base.ModelMetdata( + yield base.ModelMetadata( model_id='model_sub.pkl', model_name='model_sub') class _EmitSingletonSideInput(beam.DoFn): diff --git a/sdks/python/apache_beam/ml/inference/base.py b/sdks/python/apache_beam/ml/inference/base.py index 842607f36ffd..50056107702e 100644 --- a/sdks/python/apache_beam/ml/inference/base.py +++ b/sdks/python/apache_beam/ml/inference/base.py @@ -86,15 +86,15 @@ def __new__(cls, example, inference, model_id=None): PredictionResult.model_id.__doc__ = """Model ID used to run the prediction.""" -class ModelMetdata(NamedTuple): +class ModelMetadata(NamedTuple): model_id: str model_name: str -ModelMetdata.model_id.__doc__ = """Unique identifier for the model. This can be +ModelMetadata.model_id.__doc__ = """Unique identifier for the model. This can be a file path or a URL where the model can be accessed. It is used to load the model for inference.""" -ModelMetdata.model_name.__doc__ = """Human-readable name for the model. This +ModelMetadata.model_name.__doc__ = """Human-readable name for the model. This can be used to identify the model in the metrics generated by the RunInference transform.""" @@ -310,7 +310,7 @@ def __init__( inference_args: Optional[Dict[str, Any]] = None, metrics_namespace: Optional[str] = None, *, - model_metadata_pcoll: beam.PCollection[ModelMetdata] = None): + model_metadata_pcoll: beam.PCollection[ModelMetadata] = None): """ A transform that takes a PCollection of examples (or features) for use on an ML model. The transform then outputs inferences (or predictions) for @@ -530,7 +530,7 @@ def _run_inference(self, batch, inference_args): return predictions def process( - self, batch, inference_args, si_model_metadata: Optional[ModelMetdata]): + self, batch, inference_args, si_model_metadata: Optional[ModelMetadata]): """ When side input is enabled: The method checks if the side input model has been updated, and if so, diff --git a/sdks/python/apache_beam/ml/inference/base_test.py b/sdks/python/apache_beam/ml/inference/base_test.py index c427e40841af..319735da2363 100644 --- a/sdks/python/apache_beam/ml/inference/base_test.py +++ b/sdks/python/apache_beam/ml/inference/base_test.py @@ -392,7 +392,7 @@ def test_run_inference_with_iterable_side_input(self): test_pipeline = TestPipeline() side_input = ( test_pipeline | "CreateDummySideInput" >> beam.Create( - [base.ModelMetdata(1, 1), base.ModelMetdata(2, 2)]) + [base.ModelMetadata(1, 1), base.ModelMetadata(2, 2)]) | "ApplySideInputWindow" >> beam.WindowInto( window.GlobalWindows(), trigger=trigger.Repeatedly(trigger.AfterProcessingTime(1)), @@ -442,11 +442,11 @@ def test_run_inference_side_input_in_batch(self): sample_side_input_elements = [( first_ts + 8, - base.ModelMetdata( + base.ModelMetadata( model_id='fake_model_id_1', model_name='fake_model_id_1')), ( first_ts + 15, - base.ModelMetdata( + base.ModelMetadata( model_id='fake_model_id_2', model_name='fake_model_id_2'))]