Skip to content

Commit

Permalink
Fix parameter name collision in AutoMLBatchPredictOperator #10723 (#1…
Browse files Browse the repository at this point in the history
…0869)

Rename `params` to `prediction_params` to avoid
clash with BaseOperator arguments
  • Loading branch information
tszerszen authored Sep 13, 2020
1 parent f77a11d commit 12a652f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
27 changes: 27 additions & 0 deletions airflow/providers/google/cloud/ADDITIONAL_INFO.md
Original file line number Diff line number Diff line change
@@ -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.
12 changes: 6 additions & 6 deletions airflow/providers/google/cloud/operators/automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -287,7 +287,7 @@ def __init__( # pylint: disable=too-many-arguments
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,
Expand All @@ -300,7 +300,7 @@ def __init__( # pylint: disable=too-many-arguments
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
Expand All @@ -321,7 +321,7 @@ def execute(self, context):
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,
Expand Down
1 change: 1 addition & 0 deletions tests/providers/google/cloud/operators/test_automl.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def test_execute(self, mock_hook):
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(
Expand Down

0 comments on commit 12a652f

Please sign in to comment.