diff --git a/CHANGELOG.md b/CHANGELOG.md index cecf430b5a..7fdf7e7f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +### [1.4.3](https://www.github.com/googleapis/python-aiplatform/compare/v1.4.2...v1.4.3) (2021-09-17) + + +### Features + +* **PipelineJob:** support dict, list, bool typed input parameters fr… ([#693](https://www.github.com/googleapis/python-aiplatform/issues/693)) ([243b75c](https://www.github.com/googleapis/python-aiplatform/commit/243b75c2655beeef47848410a40d86a072428ac3)) + + +### Bug Fixes + +* Update milli node_hours for image training ([#663](https://www.github.com/googleapis/python-aiplatform/issues/663)) ([64768c3](https://www.github.com/googleapis/python-aiplatform/commit/64768c3591f648932e023713d2a728ce5318bb8b)) +* XAI Metadata compatibility with Model.upload ([#705](https://www.github.com/googleapis/python-aiplatform/issues/705)) ([f0570cb](https://www.github.com/googleapis/python-aiplatform/commit/f0570cb999f024ca96e7daaa102c81b681c2a575)) + + +### Miscellaneous Chores + +* release 1.4.3 ([#715](https://www.github.com/googleapis/python-aiplatform/issues/715)) ([b610486](https://www.github.com/googleapis/python-aiplatform/commit/b6104868161a236fc5585855b5948a5e3294aea2)) + ### [1.4.2](https://www.github.com/googleapis/python-aiplatform/compare/v1.4.1...v1.4.2) (2021-09-10) diff --git a/google/cloud/aiplatform/explain/metadata/tf/v1/saved_model_metadata_builder.py b/google/cloud/aiplatform/explain/metadata/tf/v1/saved_model_metadata_builder.py index 89261f8c1f..6f0af6d93b 100644 --- a/google/cloud/aiplatform/explain/metadata/tf/v1/saved_model_metadata_builder.py +++ b/google/cloud/aiplatform/explain/metadata/tf/v1/saved_model_metadata_builder.py @@ -17,9 +17,7 @@ from google.protobuf import json_format from typing import Any, Dict, List, Optional -from google.cloud.aiplatform.compat.types import ( - explanation_metadata_v1beta1 as explanation_metadata, -) +from google.cloud.aiplatform.compat.types import explanation_metadata from google.cloud.aiplatform.explain.metadata import metadata_builder diff --git a/google/cloud/aiplatform/explain/metadata/tf/v2/saved_model_metadata_builder.py b/google/cloud/aiplatform/explain/metadata/tf/v2/saved_model_metadata_builder.py index 36f520d7b0..dd7f2b8d0a 100644 --- a/google/cloud/aiplatform/explain/metadata/tf/v2/saved_model_metadata_builder.py +++ b/google/cloud/aiplatform/explain/metadata/tf/v2/saved_model_metadata_builder.py @@ -18,9 +18,7 @@ from typing import Optional, List, Dict, Any, Tuple from google.cloud.aiplatform.explain.metadata import metadata_builder -from google.cloud.aiplatform.compat.types import ( - explanation_metadata_v1beta1 as explanation_metadata, -) +from google.cloud.aiplatform.compat.types import explanation_metadata class SavedModelMetadataBuilder(metadata_builder.MetadataBuilder): diff --git a/google/cloud/aiplatform/training_jobs.py b/google/cloud/aiplatform/training_jobs.py index 66efc2bac6..8d8583f850 100644 --- a/google/cloud/aiplatform/training_jobs.py +++ b/google/cloud/aiplatform/training_jobs.py @@ -3911,6 +3911,202 @@ def run( sync=sync, ) + def _run_with_experiments( + self, + dataset: datasets.TimeSeriesDataset, + target_column: str, + time_column: str, + time_series_identifier_column: str, + unavailable_at_forecast_columns: List[str], + available_at_forecast_columns: List[str], + forecast_horizon: int, + data_granularity_unit: str, + data_granularity_count: int, + predefined_split_column_name: Optional[str] = None, + weight_column: Optional[str] = None, + time_series_attribute_columns: Optional[List[str]] = None, + context_window: Optional[int] = None, + export_evaluated_data_items: bool = False, + export_evaluated_data_items_bigquery_destination_uri: Optional[str] = None, + export_evaluated_data_items_override_destination: bool = False, + quantiles: Optional[List[float]] = None, + validation_options: Optional[str] = None, + budget_milli_node_hours: int = 1000, + model_display_name: Optional[str] = None, + model_labels: Optional[Dict[str, str]] = None, + sync: bool = True, + additional_experiments: Optional[List[str]] = None, + ) -> models.Model: + """Runs the training job with experiment flags and returns a model. + + The training data splits are set by default: Roughly 80% will be used for training, + 10% for validation, and 10% for test. + + Args: + dataset (datasets.Dataset): + Required. The dataset within the same Project from which data will be used to train the Model. The + Dataset must use schema compatible with Model being trained, + and what is compatible should be described in the used + TrainingPipeline's [training_task_definition] + [google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition]. + For time series Datasets, all their data is exported to + training, to pick and choose from. + target_column (str): + Required. Name of the column that the Model is to predict values for. + time_column (str): + Required. Name of the column that identifies time order in the time series. + time_series_identifier_column (str): + Required. Name of the column that identifies the time series. + unavailable_at_forecast_columns (List[str]): + Required. Column names of columns that are unavailable at forecast. + Each column contains information for the given entity (identified by the + [time_series_identifier_column]) that is unknown before the forecast + (e.g. population of a city in a given year, or weather on a given day). + available_at_forecast_columns (List[str]): + Required. Column names of columns that are available at forecast. + Each column contains information for the given entity (identified by the + [time_series_identifier_column]) that is known at forecast. + forecast_horizon: (int): + Required. The amount of time into the future for which forecasted values for the target are + returned. Expressed in number of units defined by the [data_granularity_unit] and + [data_granularity_count] field. Inclusive. + data_granularity_unit (str): + Required. The data granularity unit. Accepted values are ``minute``, + ``hour``, ``day``, ``week``, ``month``, ``year``. + data_granularity_count (int): + Required. The number of data granularity units between data points in the training + data. If [data_granularity_unit] is `minute`, can be 1, 5, 10, 15, or 30. For all other + values of [data_granularity_unit], must be 1. + predefined_split_column_name (str): + Optional. The key is a name of one of the Dataset's data + columns. The value of the key (either the label's value or + value in the column) must be one of {``TRAIN``, + ``VALIDATE``, ``TEST``}, and it defines to which set the + given piece of data is assigned. If for a piece of data the + key is not present or has an invalid value, that piece is + ignored by the pipeline. + + Supported only for tabular and time series Datasets. + weight_column (str): + Optional. Name of the column that should be used as the weight column. + Higher values in this column give more importance to the row + during Model training. The column must have numeric values between 0 and + 10000 inclusively, and 0 value means that the row is ignored. + If the weight column field is not set, then all rows are assumed to have + equal weight of 1. + time_series_attribute_columns (List[str]): + Optional. Column names that should be used as attribute columns. + Each column is constant within a time series. + context_window (int): + Optional. The amount of time into the past training and prediction data is used for + model training and prediction respectively. Expressed in number of units defined by the + [data_granularity_unit] and [data_granularity_count] fields. When not provided uses the + default value of 0 which means the model sets each series context window to be 0 (also + known as "cold start"). Inclusive. + export_evaluated_data_items (bool): + Whether to export the test set predictions to a BigQuery table. + If False, then the export is not performed. + export_evaluated_data_items_bigquery_destination_uri (string): + Optional. URI of desired destination BigQuery table for exported test set predictions. + + Expected format: + ``bq://::`` + + If not specified, then results are exported to the following auto-created BigQuery + table: + ``:export_evaluated_examples__.evaluated_examples`` + + Applies only if [export_evaluated_data_items] is True. + export_evaluated_data_items_override_destination (bool): + Whether to override the contents of [export_evaluated_data_items_bigquery_destination_uri], + if the table exists, for exported test set predictions. If False, and the + table exists, then the training job will fail. + + Applies only if [export_evaluated_data_items] is True and + [export_evaluated_data_items_bigquery_destination_uri] is specified. + quantiles (List[float]): + Quantiles to use for the `minizmize-quantile-loss` + [AutoMLForecastingTrainingJob.optimization_objective]. This argument is required in + this case. + + Accepts up to 5 quantiles in the form of a double from 0 to 1, exclusive. + Each quantile must be unique. + validation_options (str): + Validation options for the data validation component. The available options are: + "fail-pipeline" - (default), will validate against the validation and fail the pipeline + if it fails. + "ignore-validation" - ignore the results of the validation and continue the pipeline + budget_milli_node_hours (int): + Optional. The train budget of creating this Model, expressed in milli node + hours i.e. 1,000 value in this field means 1 node hour. + The training cost of the model will not exceed this budget. The final + cost will be attempted to be close to the budget, though may end up + being (even) noticeably smaller - at the backend's discretion. This + especially may happen when further model training ceases to provide + any improvements. + If the budget is set to a value known to be insufficient to train a + Model for the given training set, the training won't be attempted and + will error. + The minimum value is 1000 and the maximum is 72000. + model_display_name (str): + Optional. If the script produces a managed Vertex AI Model. The display name of + the Model. The name can be up to 128 characters long and can be consist + of any UTF-8 characters. + + If not provided upon creation, the job's display_name is used. + model_labels (Dict[str, str]): + Optional. The labels with user-defined metadata to + organize your Models. + Label keys and values can be no longer than 64 + characters (Unicode codepoints), can only + contain lowercase letters, numeric characters, + underscores and dashes. International characters + are allowed. + See https://goo.gl/xmQnxf for more information + and examples of labels. + sync (bool): + Whether to execute this method synchronously. If False, this method + will be executed in concurrent Future and any downstream object will + be immediately returned and synced when the Future has completed. + additional_experiments (List[str]): + Additional experiment flags for the time series forcasting training. + + Returns: + model: The trained Vertex AI Model resource or None if training did not + produce a Vertex AI Model. + + Raises: + RuntimeError if Training job has already been run or is waiting to run. + """ + + if additional_experiments: + self._add_additional_experiments(additional_experiments) + + return self.run( + dataset=dataset, + target_column=target_column, + time_column=time_column, + time_series_identifier_column=time_series_identifier_column, + unavailable_at_forecast_columns=unavailable_at_forecast_columns, + available_at_forecast_columns=available_at_forecast_columns, + forecast_horizon=forecast_horizon, + data_granularity_unit=data_granularity_unit, + data_granularity_count=data_granularity_count, + predefined_split_column_name=predefined_split_column_name, + weight_column=weight_column, + time_series_attribute_columns=time_series_attribute_columns, + context_window=context_window, + budget_milli_node_hours=budget_milli_node_hours, + export_evaluated_data_items=export_evaluated_data_items, + export_evaluated_data_items_bigquery_destination_uri=export_evaluated_data_items_bigquery_destination_uri, + export_evaluated_data_items_override_destination=export_evaluated_data_items_override_destination, + quantiles=quantiles, + validation_options=validation_options, + model_display_name=model_display_name, + model_labels=model_labels, + sync=sync, + ) + @base.optional_sync() def _run( self, @@ -4318,7 +4514,7 @@ def run( training_filter_split: Optional[str] = None, validation_filter_split: Optional[str] = None, test_filter_split: Optional[str] = None, - budget_milli_node_hours: int = 1000, + budget_milli_node_hours: Optional[int] = None, model_display_name: Optional[str] = None, model_labels: Optional[Dict[str, str]] = None, disable_early_stopping: bool = False, @@ -4384,18 +4580,26 @@ def run( single DataItem is matched by more than one of the FilterSplit filters, then it is assigned to the first set that applies to it in the training, validation, test order. This is ignored if Dataset is not provided. - budget_milli_node_hours: int = 1000 + budget_milli_node_hours (int): Optional. The train budget of creating this Model, expressed in milli node hours i.e. 1,000 value in this field means 1 node hour. + + Defaults by `prediction_type`: + + `classification` - For Cloud models the budget must be: 8,000 - 800,000 + milli node hours (inclusive). The default value is 192,000 which + represents one day in wall time, assuming 8 nodes are used. + `object_detection` - For Cloud models the budget must be: 20,000 - 900,000 + milli node hours (inclusive). The default value is 216,000 which represents + one day in wall time, assuming 9 nodes are used. + The training cost of the model will not exceed this budget. The final cost will be attempted to be close to the budget, though may end up being (even) noticeably smaller - at the backend's discretion. This especially may happen when further model training ceases to provide - any improvements. - If the budget is set to a value known to be insufficient to train a - Model for the given training set, the training won't be attempted and + any improvements. If the budget is set to a value known to be insufficient to + train a Model for the given training set, the training won't be attempted and will error. - The minimum value is 1000 and the maximum is 72000. model_display_name (str): Optional. The display name of the managed Vertex AI Model. The name can be up to 128 characters long and can be consist of any UTF-8 diff --git a/google/cloud/aiplatform/utils/pipeline_utils.py b/google/cloud/aiplatform/utils/pipeline_utils.py index 31b08671a5..bc531d2b12 100644 --- a/google/cloud/aiplatform/utils/pipeline_utils.py +++ b/google/cloud/aiplatform/utils/pipeline_utils.py @@ -15,6 +15,7 @@ # import copy +import json from typing import Any, Dict, Mapping, Optional, Union @@ -89,7 +90,11 @@ def update_runtime_parameters( Optional. The mapping from runtime parameter names to its values. """ if parameter_values: - self._parameter_values.update(parameter_values) + parameters = dict(parameter_values) + for k, v in parameter_values.items(): + if isinstance(v, (dict, list, bool)): + parameters[k] = json.dumps(v) + self._parameter_values.update(parameters) def build(self) -> Dict[str, Any]: """Build a RuntimeConfig proto. diff --git a/setup.py b/setup.py index 28f75b4515..1563307fb3 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ import setuptools # type: ignore name = "google-cloud-aiplatform" -version = "1.4.2" +version = "1.4.3" description = "Cloud AI Platform API client library" package_root = os.path.abspath(os.path.dirname(__file__)) diff --git a/tests/system/aiplatform/e2e_base.py b/tests/system/aiplatform/e2e_base.py index de91c1249a..c63c715d7c 100644 --- a/tests/system/aiplatform/e2e_base.py +++ b/tests/system/aiplatform/e2e_base.py @@ -76,7 +76,7 @@ def prepare_staging_bucket( shared_state["storage_client"] = storage_client shared_state["bucket"] = storage_client.create_bucket( - staging_bucket_name, location=_LOCATION + staging_bucket_name, project=_PROJECT, location=_LOCATION ) yield diff --git a/tests/unit/aiplatform/test_automl_forecasting_training_jobs.py b/tests/unit/aiplatform/test_automl_forecasting_training_jobs.py index 8dc1f362ba..142301f98b 100644 --- a/tests/unit/aiplatform/test_automl_forecasting_training_jobs.py +++ b/tests/unit/aiplatform/test_automl_forecasting_training_jobs.py @@ -361,6 +361,69 @@ def test_run_call_pipeline_if_no_model_display_name_nor_model_labels( training_pipeline=true_training_pipeline, ) + @pytest.mark.usefixtures("mock_pipeline_service_get") + @pytest.mark.parametrize("sync", [True, False]) + def test_run_with_experiments( + self, + mock_pipeline_service_create, + mock_dataset_time_series, + mock_model_service_get, + sync, + ): + aiplatform.init(project=_TEST_PROJECT, staging_bucket=_TEST_BUCKET_NAME) + + job = AutoMLForecastingTrainingJob( + display_name=_TEST_DISPLAY_NAME, + optimization_objective=_TEST_TRAINING_OPTIMIZATION_OBJECTIVE_NAME, + column_transformations=_TEST_TRAINING_COLUMN_TRANSFORMATIONS, + ) + + model_from_job = job._run_with_experiments( + dataset=mock_dataset_time_series, + target_column=_TEST_TRAINING_TARGET_COLUMN, + time_column=_TEST_TRAINING_TIME_COLUMN, + time_series_identifier_column=_TEST_TRAINING_TIME_SERIES_IDENTIFIER_COLUMN, + unavailable_at_forecast_columns=_TEST_TRAINING_UNAVAILABLE_AT_FORECAST_COLUMNS, + available_at_forecast_columns=_TEST_TRAINING_AVAILABLE_AT_FORECAST_COLUMNS, + forecast_horizon=_TEST_TRAINING_FORECAST_HORIZON, + data_granularity_unit=_TEST_TRAINING_DATA_GRANULARITY_UNIT, + data_granularity_count=_TEST_TRAINING_DATA_GRANULARITY_COUNT, + weight_column=_TEST_TRAINING_WEIGHT_COLUMN, + time_series_attribute_columns=_TEST_TRAINING_TIME_SERIES_ATTRIBUTE_COLUMNS, + context_window=_TEST_TRAINING_CONTEXT_WINDOW, + budget_milli_node_hours=_TEST_TRAINING_BUDGET_MILLI_NODE_HOURS, + export_evaluated_data_items=_TEST_TRAINING_EXPORT_EVALUATED_DATA_ITEMS, + export_evaluated_data_items_bigquery_destination_uri=_TEST_TRAINING_EXPORT_EVALUATED_DATA_ITEMS_BIGQUERY_DESTINATION_URI, + export_evaluated_data_items_override_destination=_TEST_TRAINING_EXPORT_EVALUATED_DATA_ITEMS_OVERRIDE_DESTINATION, + quantiles=_TEST_TRAINING_QUANTILES, + validation_options=_TEST_TRAINING_VALIDATION_OPTIONS, + sync=sync, + additional_experiments=_TEST_ADDITIONAL_EXPERIMENTS, + ) + + if not sync: + model_from_job.wait() + + # Test that if defaults to the job display name + true_managed_model = gca_model.Model(display_name=_TEST_DISPLAY_NAME) + + true_input_data_config = gca_training_pipeline.InputDataConfig( + dataset_id=mock_dataset_time_series.name, + ) + + true_training_pipeline = gca_training_pipeline.TrainingPipeline( + display_name=_TEST_DISPLAY_NAME, + training_task_definition=schema.training_job.definition.automl_forecasting, + training_task_inputs=_TEST_TRAINING_TASK_INPUTS_WITH_ADDITIONAL_EXPERIMENTS, + model_to_upload=true_managed_model, + input_data_config=true_input_data_config, + ) + + mock_pipeline_service_create.assert_called_once_with( + parent=initializer.global_config.common_location_path(), + training_pipeline=true_training_pipeline, + ) + @pytest.mark.usefixtures("mock_pipeline_service_get") @pytest.mark.parametrize("sync", [True, False]) def test_run_call_pipeline_if_set_additional_experiments( diff --git a/tests/unit/aiplatform/test_automl_image_training_jobs.py b/tests/unit/aiplatform/test_automl_image_training_jobs.py index 7f092f12d1..330fe3d0ea 100644 --- a/tests/unit/aiplatform/test_automl_image_training_jobs.py +++ b/tests/unit/aiplatform/test_automl_image_training_jobs.py @@ -34,7 +34,7 @@ _TEST_DISPLAY_NAME = "test-display-name" _TEST_METADATA_SCHEMA_URI_IMAGE = schema.dataset.metadata.image -_TEST_TRAINING_BUDGET_MILLI_NODE_HOURS = 1000 +_TEST_TRAINING_BUDGET_MILLI_NODE_HOURS = 7500 _TEST_TRAINING_DISABLE_EARLY_STOPPING = True _TEST_MODEL_TYPE_ICN = "CLOUD" # Image Classification default _TEST_MODEL_TYPE_IOD = "CLOUD_HIGH_ACCURACY_1" # Image Object Detection default @@ -493,6 +493,7 @@ def test_splits_fraction( training_fraction_split=_TEST_FRACTION_SPLIT_TRAINING, validation_fraction_split=_TEST_FRACTION_SPLIT_VALIDATION, test_fraction_split=_TEST_FRACTION_SPLIT_TEST, + budget_milli_node_hours=_TEST_TRAINING_BUDGET_MILLI_NODE_HOURS, disable_early_stopping=_TEST_TRAINING_DISABLE_EARLY_STOPPING, sync=sync, ) @@ -560,6 +561,7 @@ def test_splits_filter( training_filter_split=_TEST_FILTER_SPLIT_TRAINING, validation_filter_split=_TEST_FILTER_SPLIT_VALIDATION, test_filter_split=_TEST_FILTER_SPLIT_TEST, + budget_milli_node_hours=_TEST_TRAINING_BUDGET_MILLI_NODE_HOURS, disable_early_stopping=_TEST_TRAINING_DISABLE_EARLY_STOPPING, sync=sync, ) @@ -624,6 +626,7 @@ def test_splits_default( model_from_job = job.run( dataset=mock_dataset_image, model_display_name=_TEST_MODEL_DISPLAY_NAME, + budget_milli_node_hours=_TEST_TRAINING_BUDGET_MILLI_NODE_HOURS, disable_early_stopping=_TEST_TRAINING_DISABLE_EARLY_STOPPING, sync=sync, ) diff --git a/tests/unit/aiplatform/test_explain_saved_model_metadata_builder_tf1_test.py b/tests/unit/aiplatform/test_explain_saved_model_metadata_builder_tf1_test.py index 41ff8bb68e..8c83b3b087 100644 --- a/tests/unit/aiplatform/test_explain_saved_model_metadata_builder_tf1_test.py +++ b/tests/unit/aiplatform/test_explain_saved_model_metadata_builder_tf1_test.py @@ -15,12 +15,15 @@ # limitations under the License. # +import pytest import tensorflow.compat.v1 as tf +from google.cloud.aiplatform import models from google.cloud.aiplatform.explain.metadata.tf.v1 import saved_model_metadata_builder -from google.cloud.aiplatform.compat.types import ( - explanation_metadata_v1beta1 as explanation_metadata, -) +from google.cloud.aiplatform.compat.types import explanation_metadata + +import test_models +from test_models import upload_model_mock, get_model_mock # noqa: F401 class SavedModelMetadataBuilderTF1Test(tf.test.TestCase): @@ -108,3 +111,28 @@ def test_get_metadata_protobuf_double_output(self): ) assert md_builder.get_metadata_protobuf() == expected_object + + @pytest.mark.usefixtures("upload_model_mock", "get_model_mock") + def test_model_upload_compatibility(self): + self._set_up() + md_builder = saved_model_metadata_builder.SavedModelMetadataBuilder( + self.model_path, tags=[tf.saved_model.tag_constants.SERVING] + ) + + generated_md = md_builder.get_metadata_protobuf() + + try: + models.Model.upload( + display_name=test_models._TEST_MODEL_NAME, + serving_container_image_uri=test_models._TEST_SERVING_CONTAINER_IMAGE, + explanation_parameters=test_models._TEST_EXPLANATION_PARAMETERS, + explanation_metadata=generated_md, # Test metadata from builder + labels=test_models._TEST_LABEL, + ) + except TypeError as e: + if "Parameter to MergeFrom() must be instance of same class" in str(e): + pytest.fail( + f"Model.upload() expects different proto version, more info: {e}" + ) + else: + raise e diff --git a/tests/unit/aiplatform/test_explain_saved_model_metadata_builder_tf2_test.py b/tests/unit/aiplatform/test_explain_saved_model_metadata_builder_tf2_test.py index 5ebc0a9af7..a18eed243c 100644 --- a/tests/unit/aiplatform/test_explain_saved_model_metadata_builder_tf2_test.py +++ b/tests/unit/aiplatform/test_explain_saved_model_metadata_builder_tf2_test.py @@ -15,14 +15,16 @@ # limitations under the License. # - +import pytest import tensorflow as tf import numpy as np +from google.cloud.aiplatform import models from google.cloud.aiplatform.explain.metadata.tf.v2 import saved_model_metadata_builder -from google.cloud.aiplatform.compat.types import ( - explanation_metadata_v1beta1 as explanation_metadata, -) +from google.cloud.aiplatform.compat.types import explanation_metadata + +import test_models +from test_models import upload_model_mock, get_model_mock # noqa: F401 class SavedModelMetadataBuilderTF2Test(tf.test.TestCase): @@ -184,3 +186,28 @@ def test_model_with_feature_column(self): "outputs": {"output_1": {"outputTensorName": "output_1"}}, } assert expected_md == generated_md + + @pytest.mark.usefixtures("upload_model_mock", "get_model_mock") + def test_model_upload_compatibility(self): + self._set_up_sequential() + + builder = saved_model_metadata_builder.SavedModelMetadataBuilder( + self.saved_model_path + ) + generated_md = builder.get_metadata_protobuf() + + try: + models.Model.upload( + display_name=test_models._TEST_MODEL_NAME, + serving_container_image_uri=test_models._TEST_SERVING_CONTAINER_IMAGE, + explanation_parameters=test_models._TEST_EXPLANATION_PARAMETERS, + explanation_metadata=generated_md, # Test metadata from builder + labels=test_models._TEST_LABEL, + ) + except TypeError as e: + if "Parameter to MergeFrom() must be instance of same class" in str(e): + pytest.fail( + f"Model.upload() expects different proto version, more info: {e}" + ) + else: + raise e diff --git a/tests/unit/aiplatform/test_utils.py b/tests/unit/aiplatform/test_utils.py index bdc674ebc0..418014ee45 100644 --- a/tests/unit/aiplatform/test_utils.py +++ b/tests/unit/aiplatform/test_utils.py @@ -370,6 +370,9 @@ class TestPipelineUtils: "int_param": {"type": "INT"}, "float_param": {"type": "DOUBLE"}, "new_param": {"type": "STRING"}, + "bool_param": {"type": "STRING"}, + "dict_param": {"type": "STRING"}, + "list_param": {"type": "STRING"}, } } } @@ -430,7 +433,13 @@ def test_pipeline_utils_runtime_config_builder_with_merge_updates(self): ) my_builder.update_pipeline_root("path/to/my/new/root") my_builder.update_runtime_parameters( - {"int_param": 888, "new_param": "new-string"} + { + "int_param": 888, + "new_param": "new-string", + "dict_param": {"a": 1}, + "list_param": [1, 2, 3], + "bool_param": True, + } ) actual_runtime_config = my_builder.build() @@ -441,6 +450,9 @@ def test_pipeline_utils_runtime_config_builder_with_merge_updates(self): "int_param": {"intValue": 888}, "float_param": {"doubleValue": 3.14}, "new_param": {"stringValue": "new-string"}, + "dict_param": {"stringValue": '{"a": 1}'}, + "list_param": {"stringValue": "[1, 2, 3]"}, + "bool_param": {"stringValue": "true"}, }, } assert expected_runtime_config == actual_runtime_config