Skip to content

Commit

Permalink
Revert "feat: merge conflict"
Browse files Browse the repository at this point in the history
This reverts commit b58e20b.
  • Loading branch information
donatas-dt committed May 30, 2023
1 parent b58e20b commit d856cd3
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 463 deletions.
17 changes: 0 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,8 @@ test-all-components: ## Run unit tests for all pipeline components
$(MAKE) test-components GROUP=$$(basename $$component_group) ; \
done

<<<<<<< HEAD
sync-assets: ## Sync assets folder to GCS.
@if [ -d "./pipelines/assets/" ] ; then \
=======
test-components-coverage: ## Run tests with coverage
@cd "components/${GROUP}" && \
pipenv run coverage run -m pytest && \
pipenv run coverage report -m

test-all-components-coverage: ## Run tests with coverage
@set -e && \
for component_group in components/*/ ; do \
echo "Test components under $$component_group" && \
$(MAKE) test-components-coverage GROUP=$$(basename $$component_group) ; \
done

sync-assets: ## Sync assets folder to GCS. Must specify pipeline=<training|prediction>
@if [ -d "./pipelines/src/pipelines/${PIPELINE_TEMPLATE}/$(pipeline)/assets/" ] ; then \
>>>>>>> develop
echo "Syncing assets to GCS" && \
gsutil -m rsync -r -d ./pipelines/assets ${PIPELINE_FILES_GCS_PATH}/assets ; \
else \
Expand Down
64 changes: 0 additions & 64 deletions components/bigquery-components/tests/test_extract_bq_to_dataset.py

This file was deleted.

93 changes: 0 additions & 93 deletions components/vertex-components/tests/test_custom_training_job.py

This file was deleted.

57 changes: 0 additions & 57 deletions components/vertex-components/tests/test_import_model_evaluation.py

This file was deleted.

126 changes: 72 additions & 54 deletions components/vertex-components/tests/test_lookup_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,75 +22,93 @@
lookup_model = vertex_components.lookup_model.python_func


@mock.patch("google.cloud.aiplatform.Model")
def test_lookup_model(mock_model, tmpdir):
def test_lookup_model(tmpdir):
"""
Assert lookup_model produces expected resource name, and that list method is
called with the correct arguemnts
Args:
tmpdir: built-in pytest tmpdir fixture
Returns:
None
"""
with mock.patch("google.cloud.aiplatform.Model") as mock_model:

# Mock attribute and method

mock_path = tmpdir
mock_model.resource_name = "my-model-resource-name"
mock_model.uri = mock_path
mock_model.list.return_value = [mock_model]

# Invoke the model look up
found_model_resource_name, _ = lookup_model(
model_name="my-model",
project_location="europe-west4",
project_id="my-project-id",
order_models_by="create_time desc",
fail_on_model_not_found=False,
model=Model(uri=mock_path),
)

assert found_model_resource_name == "my-model-resource-name"

# Check the list method was called once with the correct arguments
mock_model.list.assert_called_once_with(
filter='display_name="my-model"',
order_by="create_time desc",
location="europe-west4",
project="my-project-id",
)


# Mock attribute and method
mock_path = tmpdir
mock_model.resource_name = "my-model-resource-name"
mock_model.uri = mock_path
mock_model.list.return_value = [mock_model]

# Invoke the model look up
found_model_resource_name, _ = lookup_model(
model_name="my-model",
project_location="europe-west4",
project_id="my-project-id",
order_models_by="create_time desc",
fail_on_model_not_found=False,
model=Model(uri=mock_path),
)

assert found_model_resource_name == "my-model-resource-name"

# Check the list method was called once with the correct arguments
mock_model.list.assert_called_once_with(
filter='display_name="my-model"',
order_by="create_time desc",
location="europe-west4",
project="my-project-id",
)


@mock.patch("google.cloud.aiplatform.Model")
def test_lookup_model_when_no_models(mock_model, tmpdir):
def test_lookup_model_when_no_models(tmpdir):
"""
Checks that when there are no models and fail_on_model_found = False,
lookup_model returns an empty string.
"""
mock_model.list.return_value = []
exported_model_resource_name, _ = lookup_model(
model_name="my-model",
project_location="europe-west4",
project_id="my-project-id",
order_models_by="create_time desc",
fail_on_model_not_found=False,
model=Model(uri=str(tmpdir)),
)
Args:
tmpdir: built-in pytest tmpdir fixture
Returns:
None
"""
with mock.patch("google.cloud.aiplatform.Model") as mock_model:
mock_model.list.return_value = []
exported_model_resource_name, _ = lookup_model(
model_name="my-model",
project_location="europe-west4",
project_id="my-project-id",
order_models_by="create_time desc",
fail_on_model_not_found=False,
model=Model(uri=str(tmpdir)),
)
print(exported_model_resource_name)
assert exported_model_resource_name == ""


@mock.patch("google.cloud.aiplatform.Model")
def test_lookup_model_when_no_models_fail(mock_model, tmpdir):
def test_lookup_model_when_no_models_fail(tmpdir):
"""
Checks that when there are no models and fail_on_model_found = True,
lookup_model raises a RuntimeError.
Args:
tmpdir: built-in pytest tmpdir fixture
Returns:
None
"""
mock_model.list.return_value = []
with mock.patch("google.cloud.aiplatform.Model") as mock_model:
mock_model.list.return_value = []

# Verify that a ValueError is raised
with pytest.raises(RuntimeError):
lookup_model(
model_name="my-model",
project_location="europe-west4",
project_id="my-project-id",
order_models_by="create_time desc",
fail_on_model_not_found=True,
model=Model(uri=str(tmpdir)),
)
# Verify that a ValueError is raised
with pytest.raises(RuntimeError):
lookup_model(
model_name="my-model",
project_location="europe-west4",
project_id="my-project-id",
order_models_by="create_time desc",
fail_on_model_not_found=True,
model=Model(uri=str(tmpdir)),
)
Loading

0 comments on commit d856cd3

Please sign in to comment.