You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by tu...@apache.org on 2020/09/13 15:06:39 UTC

[airflow] branch master updated: Fix parameter name collision in AutoMLBatchPredictOperator #10723 (#10869)

This is an automated email from the ASF dual-hosted git repository.

turbaszek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/master by this push:
     new 12a652f  Fix parameter name collision in AutoMLBatchPredictOperator #10723 (#10869)
12a652f is described below

commit 12a652f5344c7f03c3d780556ca1829b235fdb2d
Author: tszerszen <48...@users.noreply.github.com>
AuthorDate: Sun Sep 13 17:05:57 2020 +0200

    Fix parameter name collision in AutoMLBatchPredictOperator #10723 (#10869)
    
    Rename `params` to `prediction_params` to avoid
    clash with BaseOperator arguments
---
 airflow/providers/google/cloud/ADDITIONAL_INFO.md  | 27 ++++++++++++++++++++++
 airflow/providers/google/cloud/operators/automl.py | 12 +++++-----
 .../google/cloud/operators/test_automl.py          |  1 +
 3 files changed, 34 insertions(+), 6 deletions(-)

diff --git a/airflow/providers/google/cloud/ADDITIONAL_INFO.md b/airflow/providers/google/cloud/ADDITIONAL_INFO.md
new file mode 100644
index 0000000..46b6e17
--- /dev/null
+++ b/airflow/providers/google/cloud/ADDITIONAL_INFO.md
@@ -0,0 +1,27 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+
+## Additional info
+
+### Breaking change in `AutoMLBatchPredictOperator`
+Class `AutoMLBatchPredictOperator` property `params` is renamed to `prediction_params`.
+To keep old behaviour, please rename `params` to `prediction_params` when initializing an instance of `AutoMLBatchPredictOperator`.
+
+Property `params` still exists, but as a property inherited from parent's class `BaseOperator`.
+Property `params` has nothing to do with prediction, use `prediction_params` instead.
diff --git a/airflow/providers/google/cloud/operators/automl.py b/airflow/providers/google/cloud/operators/automl.py
index 466cd07..435e1fd 100644
--- a/airflow/providers/google/cloud/operators/automl.py
+++ b/airflow/providers/google/cloud/operators/automl.py
@@ -240,9 +240,9 @@ class AutoMLBatchPredictOperator(BaseOperator):
         written. If a dict is provided, it must be of the same form as the protobuf message
         `google.cloud.automl_v1beta1.types.BatchPredictOutputConfig`
     :type output_config: Union[dict, ~google.cloud.automl_v1beta1.types.BatchPredictOutputConfig]
-    :param params: Additional domain-specific parameters for the predictions, any string must be up to
-        25000 characters long.
-    :type params: Optional[Dict[str, str]]
+    :param prediction_params: Additional domain-specific parameters for the predictions,
+        any string must be up to 25000 characters long.
+    :type prediction_params: Optional[Dict[str, str]]
     :param project_id: ID of the Google Cloud project where model is located if None then
         default project_id is used.
     :type project_id: str
@@ -287,7 +287,7 @@ class AutoMLBatchPredictOperator(BaseOperator):
         output_config: dict,
         location: str,
         project_id: Optional[str] = None,
-        params: Optional[Dict[str, str]] = None,
+        prediction_params: Optional[Dict[str, str]] = None,
         metadata: Optional[MetaData] = None,
         timeout: Optional[float] = None,
         retry: Optional[Retry] = None,
@@ -300,7 +300,7 @@ class AutoMLBatchPredictOperator(BaseOperator):
         self.model_id = model_id
         self.location = location
         self.project_id = project_id
-        self.params = params  # type: ignore
+        self.prediction_params = prediction_params
         self.metadata = metadata
         self.timeout = timeout
         self.retry = retry
@@ -321,7 +321,7 @@ class AutoMLBatchPredictOperator(BaseOperator):
             output_config=self.output_config,
             project_id=self.project_id,
             location=self.location,
-            params=self.params,
+            params=self.prediction_params,
             retry=self.retry,
             timeout=self.timeout,
             metadata=self.metadata,
diff --git a/tests/providers/google/cloud/operators/test_automl.py b/tests/providers/google/cloud/operators/test_automl.py
index 84db446..d16e297 100644
--- a/tests/providers/google/cloud/operators/test_automl.py
+++ b/tests/providers/google/cloud/operators/test_automl.py
@@ -94,6 +94,7 @@ class TestAutoMLBatchPredictOperator(unittest.TestCase):
             input_config=INPUT_CONFIG,
             output_config=OUTPUT_CONFIG,
             task_id=TASK_ID,
+            prediction_params={},
         )
         op.execute(context=None)
         mock_hook.return_value.batch_predict.assert_called_once_with(