From 17c9bddc2220b5a11f9d10fd91837bcea85056e4 Mon Sep 17 00:00:00 2001 From: jaycee-li Date: Mon, 15 Aug 2022 09:52:40 -0700 Subject: [PATCH 1/5] fix: high level list method --- google/cloud/aiplatform/base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/google/cloud/aiplatform/base.py b/google/cloud/aiplatform/base.py index 19b5f7d468..62b753b67d 100644 --- a/google/cloud/aiplatform/base.py +++ b/google/cloud/aiplatform/base.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -1064,9 +1064,11 @@ def _list( or initializer.global_config.common_location_path( project=project, location=location ), - "filter": filter, } + if filter: + list_request["filter"] = filter + if order_by: list_request["order_by"] = order_by From b4308fd723a5e6166f525f9af809cfd4764c625e Mon Sep 17 00:00:00 2001 From: jaycee-li Date: Wed, 17 Aug 2022 14:39:41 -0700 Subject: [PATCH 2/5] Revert "fix: high level list method" This reverts commit 17c9bddc2220b5a11f9d10fd91837bcea85056e4. --- google/cloud/aiplatform/base.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/google/cloud/aiplatform/base.py b/google/cloud/aiplatform/base.py index 62b753b67d..19b5f7d468 100644 --- a/google/cloud/aiplatform/base.py +++ b/google/cloud/aiplatform/base.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -1064,11 +1064,9 @@ def _list( or initializer.global_config.common_location_path( project=project, location=location ), + "filter": filter, } - if filter: - list_request["filter"] = filter - if order_by: list_request["order_by"] = order_by From 827d73d3dac14a1973f267808e8fdcb5be082adc Mon Sep 17 00:00:00 2001 From: jaycee-li Date: Wed, 17 Aug 2022 14:47:09 -0700 Subject: [PATCH 3/5] Revert "Revert "fix: high level list method"" This reverts commit b4308fd723a5e6166f525f9af809cfd4764c625e. --- google/cloud/aiplatform/base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/google/cloud/aiplatform/base.py b/google/cloud/aiplatform/base.py index 19b5f7d468..62b753b67d 100644 --- a/google/cloud/aiplatform/base.py +++ b/google/cloud/aiplatform/base.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -1064,9 +1064,11 @@ def _list( or initializer.global_config.common_location_path( project=project, location=location ), - "filter": filter, } + if filter: + list_request["filter"] = filter + if order_by: list_request["order_by"] = order_by From 04c67c362ce3448e88030a563b3eb254a933ee19 Mon Sep 17 00:00:00 2001 From: jaycee-li Date: Wed, 17 Aug 2022 14:57:42 -0700 Subject: [PATCH 4/5] fix: unit tests for list() --- tests/unit/aiplatform/test_datasets.py | 2 +- tests/unit/aiplatform/test_featurestores.py | 10 +++++----- tests/unit/aiplatform/test_matching_engine_index.py | 2 +- .../aiplatform/test_matching_engine_index_endpoint.py | 2 +- tests/unit/aiplatform/test_models.py | 4 ++-- tests/unit/aiplatform/test_pipeline_jobs.py | 2 +- tests/unit/aiplatform/test_tensorboard.py | 10 +++++----- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/unit/aiplatform/test_datasets.py b/tests/unit/aiplatform/test_datasets.py index 2a912d47dd..a8b79c0e98 100644 --- a/tests/unit/aiplatform/test_datasets.py +++ b/tests/unit/aiplatform/test_datasets.py @@ -1422,7 +1422,7 @@ def test_list_dataset_no_order_or_filter(self, list_datasets_mock): ds_list = aiplatform.TabularDataset.list() list_datasets_mock.assert_called_once_with( - request={"parent": _TEST_PARENT, "filter": None} + request={"parent": _TEST_PARENT} ) # Ensure returned list is smaller since it filtered out non-tabular datasets diff --git a/tests/unit/aiplatform/test_featurestores.py b/tests/unit/aiplatform/test_featurestores.py index 014a2442bd..08d57be0c5 100644 --- a/tests/unit/aiplatform/test_featurestores.py +++ b/tests/unit/aiplatform/test_featurestores.py @@ -984,7 +984,7 @@ def test_list_featurestores(self, list_featurestores_mock): my_featurestore_list = aiplatform.Featurestore.list() list_featurestores_mock.assert_called_once_with( - request={"parent": _TEST_PARENT, "filter": None} + request={"parent": _TEST_PARENT} ) assert len(my_featurestore_list) == len(_TEST_FEATURESTORE_LIST) for my_featurestore in my_featurestore_list: @@ -1028,7 +1028,7 @@ def test_list_entity_types(self, list_entity_types_mock): my_entity_type_list = my_featurestore.list_entity_types() list_entity_types_mock.assert_called_once_with( - request={"parent": _TEST_FEATURESTORE_NAME, "filter": None} + request={"parent": _TEST_FEATURESTORE_NAME} ) assert len(my_entity_type_list) == len(_TEST_ENTITY_TYPE_LIST) for my_entity_type in my_entity_type_list: @@ -1770,7 +1770,7 @@ def test_list_entity_types(self, featurestore_name, list_entity_types_mock): ) list_entity_types_mock.assert_called_once_with( - request={"parent": _TEST_FEATURESTORE_NAME, "filter": None} + request={"parent": _TEST_FEATURESTORE_NAME} ) assert len(my_entity_type_list) == len(_TEST_ENTITY_TYPE_LIST) for my_entity_type in my_entity_type_list: @@ -1784,7 +1784,7 @@ def test_list_features(self, list_features_mock): my_feature_list = my_entity_type.list_features() list_features_mock.assert_called_once_with( - request={"parent": _TEST_ENTITY_TYPE_NAME, "filter": None} + request={"parent": _TEST_ENTITY_TYPE_NAME} ) assert len(my_feature_list) == len(_TEST_FEATURE_LIST) for my_feature in my_feature_list: @@ -2851,7 +2851,7 @@ def test_list_features(self, entity_type_name, featurestore_id, list_features_mo ) list_features_mock.assert_called_once_with( - request={"parent": _TEST_ENTITY_TYPE_NAME, "filter": None} + request={"parent": _TEST_ENTITY_TYPE_NAME} ) assert len(my_feature_list) == len(_TEST_FEATURE_LIST) for my_feature in my_feature_list: diff --git a/tests/unit/aiplatform/test_matching_engine_index.py b/tests/unit/aiplatform/test_matching_engine_index.py index 78e3a608a9..072253590a 100644 --- a/tests/unit/aiplatform/test_matching_engine_index.py +++ b/tests/unit/aiplatform/test_matching_engine_index.py @@ -247,7 +247,7 @@ def test_list_indexes(self, list_indexes_mock): my_indexes_list = aiplatform.MatchingEngineIndex.list() list_indexes_mock.assert_called_once_with( - request={"parent": _TEST_PARENT, "filter": None} + request={"parent": _TEST_PARENT} ) assert len(my_indexes_list) == len(_TEST_INDEX_LIST) for my_index in my_indexes_list: diff --git a/tests/unit/aiplatform/test_matching_engine_index_endpoint.py b/tests/unit/aiplatform/test_matching_engine_index_endpoint.py index 58ff16ed56..231ab20ae0 100644 --- a/tests/unit/aiplatform/test_matching_engine_index_endpoint.py +++ b/tests/unit/aiplatform/test_matching_engine_index_endpoint.py @@ -440,7 +440,7 @@ def test_list_index_endpoints(self, list_index_endpoints_mock): my_index_endpoints_list = aiplatform.MatchingEngineIndexEndpoint.list() list_index_endpoints_mock.assert_called_once_with( - request={"parent": _TEST_PARENT, "filter": None} + request={"parent": _TEST_PARENT} ) assert len(my_index_endpoints_list) == len(_TEST_INDEX_ENDPOINT_LIST) for my_index_endpoint in my_index_endpoints_list: diff --git a/tests/unit/aiplatform/test_models.py b/tests/unit/aiplatform/test_models.py index fdd22bfe96..e71d257fc0 100644 --- a/tests/unit/aiplatform/test_models.py +++ b/tests/unit/aiplatform/test_models.py @@ -2382,7 +2382,7 @@ def test_get_model_evaluation_without_id( test_model.get_model_evaluation() list_model_evaluations_mock.assert_called_once_with( - request={"parent": _TEST_MODEL_RESOURCE_NAME, "filter": None} + request={"parent": _TEST_MODEL_RESOURCE_NAME} ) def test_list_model_evaluations( @@ -2397,7 +2397,7 @@ def test_list_model_evaluations( eval_list = test_model.list_model_evaluations() list_model_evaluations_mock.assert_called_once_with( - request={"parent": _TEST_MODEL_RESOURCE_NAME, "filter": None} + request={"parent": _TEST_MODEL_RESOURCE_NAME} ) assert len(eval_list) == len(_TEST_MODEL_EVAL_LIST) diff --git a/tests/unit/aiplatform/test_pipeline_jobs.py b/tests/unit/aiplatform/test_pipeline_jobs.py index 63c09ac799..9975fedd5c 100644 --- a/tests/unit/aiplatform/test_pipeline_jobs.py +++ b/tests/unit/aiplatform/test_pipeline_jobs.py @@ -1289,7 +1289,7 @@ def test_list_pipeline_job( job.list() mock_pipeline_service_list.assert_called_once_with( - request={"parent": _TEST_PARENT, "filter": None} + request={"parent": _TEST_PARENT} ) @pytest.mark.usefixtures( diff --git a/tests/unit/aiplatform/test_tensorboard.py b/tests/unit/aiplatform/test_tensorboard.py index b73b805202..7a999905ea 100644 --- a/tests/unit/aiplatform/test_tensorboard.py +++ b/tests/unit/aiplatform/test_tensorboard.py @@ -735,7 +735,7 @@ def test_list_tensorboard_experiments(self, list_tensorboard_experiment_mock): tensorboard.TensorboardExperiment.list(tensorboard_name=_TEST_NAME) list_tensorboard_experiment_mock.assert_called_once_with( - request={"parent": _TEST_NAME, "filter": None} + request={"parent": _TEST_NAME} ) @@ -785,7 +785,7 @@ def test_init_tensorboard_run_with_id_only_with_project_and_location( name=_TEST_TENSORBOARD_RUN_NAME, retry=base._DEFAULT_RETRY ) list_tensorboard_time_series_mock.assert_called_once_with( - request={"parent": _TEST_TENSORBOARD_RUN_NAME, "filter": None} + request={"parent": _TEST_TENSORBOARD_RUN_NAME} ) @pytest.mark.usefixtures("list_tensorboard_time_series_mock") @@ -900,11 +900,11 @@ def test_list_tensorboard_runs( ) list_tensorboard_run_mock.assert_called_once_with( - request={"parent": _TEST_TENSORBOARD_EXPERIMENT_NAME, "filter": None} + request={"parent": _TEST_TENSORBOARD_EXPERIMENT_NAME} ) list_tensorboard_time_series_mock.assert_called_once_with( - request={"parent": _TEST_TENSORBOARD_RUN_NAME, "filter": None} + request={"parent": _TEST_TENSORBOARD_RUN_NAME} ) @pytest.mark.usefixtures( @@ -1064,5 +1064,5 @@ def test_list_tensorboard_time_series(self, list_tensorboard_time_series_mock): ) list_tensorboard_time_series_mock.assert_called_once_with( - request={"parent": _TEST_TENSORBOARD_RUN_NAME, "filter": None} + request={"parent": _TEST_TENSORBOARD_RUN_NAME} ) From 0cd9d9146113ab79ead788070b870b25c0eff3e4 Mon Sep 17 00:00:00 2001 From: jaycee-li Date: Thu, 18 Aug 2022 08:57:02 -0700 Subject: [PATCH 5/5] fix: blacken --- tests/unit/aiplatform/test_datasets.py | 4 +--- tests/unit/aiplatform/test_matching_engine_index.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/unit/aiplatform/test_datasets.py b/tests/unit/aiplatform/test_datasets.py index a8b79c0e98..2b81c04251 100644 --- a/tests/unit/aiplatform/test_datasets.py +++ b/tests/unit/aiplatform/test_datasets.py @@ -1421,9 +1421,7 @@ def test_list_dataset_no_order_or_filter(self, list_datasets_mock): ds_list = aiplatform.TabularDataset.list() - list_datasets_mock.assert_called_once_with( - request={"parent": _TEST_PARENT} - ) + list_datasets_mock.assert_called_once_with(request={"parent": _TEST_PARENT}) # Ensure returned list is smaller since it filtered out non-tabular datasets assert len(ds_list) < len(_TEST_DATASET_LIST) diff --git a/tests/unit/aiplatform/test_matching_engine_index.py b/tests/unit/aiplatform/test_matching_engine_index.py index 072253590a..98943fdfb7 100644 --- a/tests/unit/aiplatform/test_matching_engine_index.py +++ b/tests/unit/aiplatform/test_matching_engine_index.py @@ -246,9 +246,7 @@ def test_list_indexes(self, list_indexes_mock): my_indexes_list = aiplatform.MatchingEngineIndex.list() - list_indexes_mock.assert_called_once_with( - request={"parent": _TEST_PARENT} - ) + list_indexes_mock.assert_called_once_with(request={"parent": _TEST_PARENT}) assert len(my_indexes_list) == len(_TEST_INDEX_LIST) for my_index in my_indexes_list: assert type(my_index) == aiplatform.MatchingEngineIndex