Skip to content

Commit 7266352

Browse files
jaycee-licopybara-github
authored andcommitted
docs: add a sample for get_experiment_run_artifacts
PiperOrigin-RevId: 483795137
1 parent 021dd22 commit 7266352

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

samples/model-builder/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,12 @@ def mock_classification_metrics():
649649
yield mock
650650

651651

652+
@pytest.fixture
653+
def mock_artifacts():
654+
mock = MagicMock()
655+
yield mock
656+
657+
652658
@pytest.fixture
653659
def mock_get_execution(mock_execution):
654660
with patch.object(aiplatform, "Execution") as mock_get_execution:
@@ -903,6 +909,15 @@ def mock_get_classification_metrics(mock_classification_metrics, mock_experiment
903909
yield mock_get_classification_metrics
904910

905911

912+
@pytest.fixture
913+
def mock_get_artifacts(mock_artifacts, mock_experiment_run):
914+
with patch.object(
915+
mock_experiment_run, "get_artifacts"
916+
) as mock_get_artifacts:
917+
mock_get_artifacts.return_value = mock_artifacts
918+
yield mock_get_artifacts
919+
920+
906921
"""
907922
----------------------------------------------------------------------------
908923
Model Versioning Fixtures
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from typing import List, Union
16+
17+
from google.cloud import aiplatform
18+
from google.cloud.aiplatform.metadata import artifact
19+
20+
21+
# [START aiplatform_sdk_get_experiment_run_artifacts_sample]
22+
def get_experiment_run_artifacts_sample(
23+
run_name: str,
24+
experiment: Union[str, aiplatform.Experiment],
25+
project: str,
26+
location: str,
27+
) -> List[artifact.Artifact]:
28+
experiment_run = aiplatform.ExperimentRun(
29+
run_name=run_name,
30+
experiment=experiment,
31+
project=project,
32+
location=location,
33+
)
34+
35+
return experiment_run.get_artifacts()
36+
37+
# [END aiplatform_sdk_get_experiment_run_artifacts_sample]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import get_experiment_run_artifacts_sample
16+
17+
import pytest
18+
19+
import test_constants as constants
20+
21+
22+
@pytest.mark.usefixtures("mock_get_run")
23+
def test_get_experiment_run_artifact_sample(mock_get_artifacts, mock_artifacts):
24+
25+
artifacts = (
26+
get_experiment_run_artifacts_sample.get_experiment_run_artifacts_sample(
27+
run_name=constants.EXPERIMENT_RUN_NAME,
28+
experiment=constants.EXPERIMENT_NAME,
29+
project=constants.PROJECT,
30+
location=constants.LOCATION,
31+
)
32+
)
33+
34+
mock_get_artifacts.assert_called_with()
35+
36+
assert artifacts is mock_artifacts

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy