File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 27
27
from google .cloud .aiplatform import compat
28
28
from google .cloud .aiplatform import initializer
29
29
from google .cloud .aiplatform import utils as aiplatform_utils
30
+ from google .cloud .aiplatform .metadata import experiment_resources
30
31
from google .cloud .aiplatform_v1 .services import gen_ai_tuning_service
31
32
from google .cloud .aiplatform_v1 .types import job_state
32
33
from google .cloud .aiplatform_v1 .types import tuning_job as gca_tuning_job
35
36
36
37
import pytest
37
38
39
+ from unittest .mock import patch
40
+
38
41
from google .rpc import status_pb2
39
42
40
43
@@ -136,7 +139,14 @@ class MockTuningJobClientWithOverride(aiplatform_utils.ClientWithOverride):
136
139
)
137
140
138
141
139
- @pytest .mark .usefixtures ("google_auth_mock" )
142
+ @pytest .fixture ()
143
+ def experiment_init_mock ():
144
+ with patch .object (experiment_resources .Experiment , "__init__" ) as experiment_mock :
145
+ experiment_mock .return_value = None
146
+ yield experiment_mock
147
+
148
+
149
+ @pytest .mark .usefixtures ("google_auth_mock" , "experiment_init_mock" )
140
150
class TestgenerativeModelTuning :
141
151
"""Unit tests for generative model tuning."""
142
152
Original file line number Diff line number Diff line change 26
26
from google .cloud .aiplatform import initializer as aiplatform_initializer
27
27
from google .cloud .aiplatform import jobs
28
28
from google .cloud .aiplatform import utils as aiplatform_utils
29
+ from google .cloud .aiplatform .utils import _ipython_utils
29
30
from google .cloud .aiplatform_v1 .services import gen_ai_tuning_service as gen_ai_tuning_service_v1
30
31
from google .cloud .aiplatform_v1 .types import tuning_job as gca_tuning_job_types
31
32
from google .cloud .aiplatform_v1 import types as gca_types
@@ -57,6 +58,7 @@ class TuningJob(aiplatform_base._VertexAiResourceNounPlus):
57
58
_parse_resource_name_method = "parse_tuning_job_path"
58
59
_format_resource_name_method = "tuning_job_path"
59
60
_job_type = "tuning/tuningJob"
61
+ _has_displayed_experiments_button = False
60
62
61
63
client_class = TuningJobClientWithOverride
62
64
@@ -74,6 +76,9 @@ def refresh(self) -> "TuningJob":
74
76
self ._gca_resource : gca_tuning_job_types .TuningJob = (
75
77
self ._get_gca_resource (resource_name = self .resource_name )
76
78
)
79
+ if self .experiment and not self ._has_displayed_experiments_button :
80
+ self ._has_displayed_experiments_button = True
81
+ _ipython_utils .display_experiment_button (self .experiment )
77
82
return self
78
83
79
84
@property
You can’t perform that action at this time.
0 commit comments