@@ -46,8 +46,8 @@ class TestExperiments(e2e_base.TestEndToEnd): |
46 | 46 | _temp_prefix = "tmpvrtxsdk-e2e" |
47 | 47 |
|
48 | 48 | def setup_class(cls): |
49 | | - cls._experiment_name = cls._make_display_name("experiment")[:30] |
50 | | - cls._dataset_artifact_name = cls._make_display_name("ds-artifact")[:30] |
| 49 | + cls._experiment_name = cls._make_display_name("")[:64] |
| 50 | + cls._dataset_artifact_name = cls._make_display_name("")[:64] |
51 | 51 | cls._dataset_artifact_uri = cls._make_display_name("ds-uri") |
52 | 52 | cls._pipeline_job_id = cls._make_display_name("job-id") |
53 | 53 |
|
@@ -74,29 +74,63 @@ def test_create_experiment(self, shared_state): |
74 | 74 | ) |
75 | 75 |
|
76 | 76 | def test_get_experiment(self): |
77 | | - experiment = aiplatform.Experiment(experiment_name=self._experiment_name) |
| 77 | + experiment = aiplatform.Experiment( |
| 78 | + experiment_name=self._experiment_name, |
| 79 | + project=e2e_base._PROJECT, |
| 80 | + location=e2e_base._LOCATION, |
| 81 | + ) |
78 | 82 | assert experiment.name == self._experiment_name |
79 | 83 |
|
80 | 84 | def test_start_run(self): |
| 85 | + aiplatform.init( |
| 86 | + project=e2e_base._PROJECT, |
| 87 | + location=e2e_base._LOCATION, |
| 88 | + experiment=self._experiment_name, |
| 89 | + ) |
81 | 90 | run = aiplatform.start_run(_RUN) |
82 | 91 | assert run.name == _RUN |
83 | 92 |
|
84 | 93 | def test_get_run(self): |
85 | | - run = aiplatform.ExperimentRun(run_name=_RUN, experiment=self._experiment_name) |
| 94 | + run = aiplatform.ExperimentRun( |
| 95 | + run_name=_RUN, |
| 96 | + experiment=self._experiment_name, |
| 97 | + project=e2e_base._PROJECT, |
| 98 | + location=e2e_base._LOCATION, |
| 99 | + ) |
86 | 100 | assert run.name == _RUN |
87 | 101 | assert run.state == aiplatform.gapic.Execution.State.RUNNING |
88 | 102 |
|
89 | 103 | def test_log_params(self): |
| 104 | + aiplatform.init( |
| 105 | + project=e2e_base._PROJECT, |
| 106 | + location=e2e_base._LOCATION, |
| 107 | + experiment=self._experiment_name, |
| 108 | + ) |
| 109 | + aiplatform.start_run(_RUN, resume=True) |
90 | 110 | aiplatform.log_params(_PARAMS) |
91 | 111 | run = aiplatform.ExperimentRun(run_name=_RUN, experiment=self._experiment_name) |
92 | 112 | assert run.get_params() == _PARAMS |
93 | 113 |
|
94 | 114 | def test_log_metrics(self): |
| 115 | + aiplatform.init( |
| 116 | + project=e2e_base._PROJECT, |
| 117 | + location=e2e_base._LOCATION, |
| 118 | + experiment=self._experiment_name, |
| 119 | + ) |
| 120 | + aiplatform.start_run(_RUN, resume=True) |
95 | 121 | aiplatform.log_metrics(_METRICS) |
96 | 122 | run = aiplatform.ExperimentRun(run_name=_RUN, experiment=self._experiment_name) |
97 | 123 | assert run.get_metrics() == _METRICS |
98 | 124 |
|
99 | 125 | def test_log_time_series_metrics(self): |
| 126 | + aiplatform.init( |
| 127 | + project=e2e_base._PROJECT, |
| 128 | + location=e2e_base._LOCATION, |
| 129 | + experiment=self._experiment_name, |
| 130 | + ) |
| 131 | + |
| 132 | + aiplatform.start_run(_RUN, resume=True) |
| 133 | + |
100 | 134 | for i in range(5): |
101 | 135 | aiplatform.log_time_series_metrics({_TIME_SERIES_METRIC_KEY: i}) |
102 | 136 |
|
@@ -116,26 +150,41 @@ def test_create_artifact(self, shared_state): |
116 | 150 | schema_title="system.Dataset", |
117 | 151 | resource_id=self._dataset_artifact_name, |
118 | 152 | uri=self._dataset_artifact_uri, |
| 153 | + project=e2e_base._PROJECT, |
| 154 | + location=e2e_base._LOCATION, |
119 | 155 | ) |
120 | 156 |
|
121 | 157 | shared_state["resources"].append(ds) |
122 | 158 | assert ds.uri == self._dataset_artifact_uri |
123 | 159 |
|
124 | 160 | def test_get_artifact_by_uri(self): |
125 | | - ds = aiplatform.Artifact.get_with_uri(uri=self._dataset_artifact_uri) |
| 161 | + ds = aiplatform.Artifact.get_with_uri( |
| 162 | + uri=self._dataset_artifact_uri, |
| 163 | + project=e2e_base._PROJECT, |
| 164 | + location=e2e_base._LOCATION, |
| 165 | + ) |
126 | 166 |
|
127 | 167 | assert ds.uri == self._dataset_artifact_uri |
128 | 168 | assert ds.name == self._dataset_artifact_name |
129 | 169 |
|
130 | 170 | def test_log_execution_and_artifact(self, shared_state): |
| 171 | + aiplatform.init( |
| 172 | + project=e2e_base._PROJECT, |
| 173 | + location=e2e_base._LOCATION, |
| 174 | + experiment=self._experiment_name, |
| 175 | + ) |
| 176 | + aiplatform.start_run(_RUN, resume=True) |
| 177 | + |
131 | 178 | with aiplatform.start_execution( |
132 | 179 | schema_title="system.ContainerExecution", |
133 | 180 | resource_id=self._make_display_name("execution"), |
134 | 181 | ) as execution: |
135 | 182 |
|
136 | 183 | shared_state["resources"].append(execution) |
137 | 184 |
|
138 | | - ds = aiplatform.Artifact(artifact_name=self._dataset_artifact_name) |
| 185 | + ds = aiplatform.Artifact( |
| 186 | + artifact_name=self._dataset_artifact_name, |
| 187 | + ) |
139 | 188 | execution.assign_input_artifacts([ds]) |
140 | 189 |
|
141 | 190 | model = aiplatform.Artifact.create(schema_title="system.Model") |
@@ -188,11 +237,22 @@ def test_log_execution_and_artifact(self, shared_state): |
188 | 237 | ) |
189 | 238 |
|
190 | 239 | def test_end_run(self): |
| 240 | + aiplatform.init( |
| 241 | + project=e2e_base._PROJECT, |
| 242 | + location=e2e_base._LOCATION, |
| 243 | + experiment=self._experiment_name, |
| 244 | + ) |
| 245 | + aiplatform.start_run(_RUN, resume=True) |
191 | 246 | aiplatform.end_run() |
192 | 247 | run = aiplatform.ExperimentRun(run_name=_RUN, experiment=self._experiment_name) |
193 | 248 | assert run.state == aiplatform.gapic.Execution.State.COMPLETE |
194 | 249 |
|
195 | 250 | def test_run_context_manager(self): |
| 251 | + aiplatform.init( |
| 252 | + project=e2e_base._PROJECT, |
| 253 | + location=e2e_base._LOCATION, |
| 254 | + experiment=self._experiment_name, |
| 255 | + ) |
196 | 256 | with aiplatform.start_run(_RUN_2) as run: |
197 | 257 | run.log_params(_PARAMS_2) |
198 | 258 | run.log_metrics(_METRICS_2) |
@@ -226,15 +286,25 @@ def pipeline(learning_rate: float, dropout_rate: float): |
226 | 286 | job_id=self._pipeline_job_id, |
227 | 287 | pipeline_root=f'gs://{shared_state["staging_bucket_name"]}', |
228 | 288 | parameter_values={"learning_rate": 0.1, "dropout_rate": 0.2}, |
| 289 | + project=e2e_base._PROJECT, |
| 290 | + location=e2e_base._LOCATION, |
229 | 291 | ) |
230 | 292 |
|
231 | | - job.submit(experiment=self._experiment_name) |
| 293 | + job.submit( |
| 294 | + experiment=self._experiment_name, |
| 295 | + ) |
232 | 296 |
|
233 | 297 | shared_state["resources"].append(job) |
234 | 298 |
|
235 | 299 | job.wait() |
236 | 300 |
|
237 | 301 | def test_get_experiments_df(self): |
| 302 | + aiplatform.init( |
| 303 | + project=e2e_base._PROJECT, |
| 304 | + location=e2e_base._LOCATION, |
| 305 | + experiment=self._experiment_name, |
| 306 | + ) |
| 307 | + |
238 | 308 | df = aiplatform.get_experiment_df() |
239 | 309 |
|
240 | 310 | pipelines_param_and_metrics = { |
@@ -264,8 +334,6 @@ def test_get_experiments_df(self): |
264 | 334 | true_df_dict_2["run_type"] = aiplatform.metadata.constants.SYSTEM_EXPERIMENT_RUN |
265 | 335 | true_df_dict_2[f"time_series_metric.{_TIME_SERIES_METRIC_KEY}"] = 0.0 |
266 | 336 |
|
267 | | - # TODO(remove when running CI) |
268 | | - |
269 | 337 | true_df_dict_3 = { |
270 | 338 | "experiment_name": self._experiment_name, |
271 | 339 | "run_name": self._pipeline_job_id, |
@@ -292,14 +360,23 @@ def test_get_experiments_df(self): |
292 | 360 | ) == sorted(df.fillna(0.0).to_dict("records"), key=lambda d: d["run_name"]) |
293 | 361 |
|
294 | 362 | def test_delete_run(self): |
295 | | - run = aiplatform.ExperimentRun(run_name=_RUN, experiment=self._experiment_name) |
| 363 | + run = aiplatform.ExperimentRun( |
| 364 | + run_name=_RUN, |
| 365 | + experiment=self._experiment_name, |
| 366 | + project=e2e_base._PROJECT, |
| 367 | + location=e2e_base._LOCATION, |
| 368 | + ) |
296 | 369 | run.delete(delete_backing_tensorboard_run=True) |
297 | 370 |
|
298 | 371 | with pytest.raises(exceptions.NotFound): |
299 | 372 | aiplatform.ExperimentRun(run_name=_RUN, experiment=self._experiment_name) |
300 | 373 |
|
301 | 374 | def test_delete_experiment(self): |
302 | | - experiment = aiplatform.Experiment(experiment_name=self._experiment_name) |
| 375 | + experiment = aiplatform.Experiment( |
| 376 | + experiment_name=self._experiment_name, |
| 377 | + project=e2e_base._PROJECT, |
| 378 | + location=e2e_base._LOCATION, |
| 379 | + ) |
303 | 380 | experiment.delete(delete_backing_tensorboard_runs=True) |
304 | 381 |
|
305 | 382 | with pytest.raises(exceptions.NotFound): |
|