Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Study.list() method #1594

Merged
merged 8 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions google/cloud/aiplatform/base.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -1077,9 +1077,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

Expand Down
4 changes: 1 addition & 3 deletions tests/unit/aiplatform/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "filter": None}
)
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)
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/aiplatform/test_featurestores.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/aiplatform/test_matching_engine_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, "filter": None}
)
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/aiplatform/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/aiplatform/test_pipeline_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/aiplatform/test_tensorboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)


Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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}
)