Skip to content

Commit aabe816

Browse files
racinmatcopybara-github
authored andcommitted
Copybara import of the project:
-- 0f3c83e by Matěj Račinský <racinsky.matej@seznam.cz>: fix: custom job url after rebrand -- b58531e by Matěj Račinský <racinsky.matej@seznam.cz>: style: format COPYBARA_INTEGRATE_REVIEW=#6639 from racinmat:racinsky/fix-custom-job-url a682d8e PiperOrigin-RevId: 907702997
1 parent 0bb2ecd commit aabe816

6 files changed

Lines changed: 47 additions & 5 deletions

File tree

agentplatform/batch_prediction/_batch_prediction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ def _dashboard_uri(self) -> Optional[str]:
287287
project = fields.pop("project")
288288
job = list(fields.values())[0]
289289
return (
290-
"https://console.cloud.google.com/ai/platform/locations/"
290+
"https://console.cloud.google.com/agent-platform/locations/"
291291
f"{location}/{self._job_type}/{job}?project={project}"
292292
)
293293

google/cloud/aiplatform/jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def _dashboard_uri(self) -> Optional[str]:
212212
location = fields.pop("location")
213213
project = fields.pop("project")
214214
job = list(fields.values())[0]
215-
url = f"https://console.cloud.google.com/ai/platform/locations/{location}/{self._job_type}/{job}?project={project}"
215+
url = f"https://console.cloud.google.com/agent-platform/locations/{location}/{self._job_type}/{job}?project={project}"
216216
return url
217217

218218
def _log_job_state(self):

google/cloud/aiplatform/training_jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ def _dashboard_uri(self) -> str:
10111011
"""Helper method to compose the dashboard uri where training can be
10121012
viewed."""
10131013
fields = self._parse_resource_name(self.resource_name)
1014-
url = f"https://console.cloud.google.com/ai/platform/locations/{fields['location']}/training/{fields['training_pipeline']}?project={fields['project']}"
1014+
url = f"https://console.cloud.google.com/agent-platform/locations/{fields['location']}/training/{fields['training_pipeline']}?project={fields['project']}"
10151015
return url
10161016

10171017
@property

google/cloud/aiplatform/utils/console_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
def custom_job_console_uri(custom_job_resource_name: str) -> str:
2323
"""Helper method to create console uri from custom job resource name."""
2424
fields = jobs.CustomJob._parse_resource_name(custom_job_resource_name)
25-
return f"https://console.cloud.google.com/ai/platform/locations/{fields['location']}/training/{fields['custom_job']}?project={fields['project']}"
25+
return f"https://console.cloud.google.com/agent-platform/locations/{fields['location']}/training/{fields['custom_job']}?project={fields['project']}"
2626

2727

2828
def custom_job_tensorboard_console_uri(

tests/unit/aiplatform/test_jobs.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,24 @@ def test_cancel_mock_job(self, fake_job_cancel_mock):
380380

381381
fake_job_cancel_mock.assert_called_once_with(name=_TEST_JOB_RESOURCE_NAME)
382382

383+
@pytest.mark.usefixtures("fake_job_getter_mock")
384+
def test_dashboard_uri_uses_agent_platform_path(self):
385+
fake_job = self.FakeJob(job_name=_TEST_JOB_RESOURCE_NAME)
386+
uri = fake_job._dashboard_uri()
387+
assert "/agent-platform/" in uri
388+
assert "/ai/platform/" not in uri
389+
390+
@pytest.mark.usefixtures("fake_job_getter_mock")
391+
def test_dashboard_uri_format(self):
392+
fake_job = self.FakeJob(job_name=_TEST_JOB_RESOURCE_NAME)
393+
uri = fake_job._dashboard_uri()
394+
expected = (
395+
f"https://console.cloud.google.com/agent-platform/locations/"
396+
f"{_TEST_LOCATION}/{self.FakeJob._job_type}/{_TEST_ID}"
397+
f"?project={_TEST_PROJECT}"
398+
)
399+
assert uri == expected
400+
383401

384402
@pytest.fixture
385403
def get_batch_prediction_job_mock():
@@ -1321,6 +1339,30 @@ def test_batch_predict_job_with_publisher_model(
13211339
== _TEST_PUBLISHER_MODEL_NAME
13221340
)
13231341

1342+
def test_batch_prediction_dashboard_uri_uses_agent_platform_path(
1343+
self, get_batch_prediction_job_mock
1344+
):
1345+
aiplatform.init(project=_TEST_PROJECT, location=_TEST_LOCATION)
1346+
bp = jobs.BatchPredictionJob(
1347+
batch_prediction_job_name=_TEST_BATCH_PREDICTION_JOB_NAME
1348+
)
1349+
uri = bp._dashboard_uri()
1350+
assert "/agent-platform/" in uri
1351+
assert "/ai/platform/" not in uri
1352+
1353+
def test_batch_prediction_dashboard_uri_format(self, get_batch_prediction_job_mock):
1354+
aiplatform.init(project=_TEST_PROJECT, location=_TEST_LOCATION)
1355+
bp = jobs.BatchPredictionJob(
1356+
batch_prediction_job_name=_TEST_BATCH_PREDICTION_JOB_NAME
1357+
)
1358+
uri = bp._dashboard_uri()
1359+
expected = (
1360+
f"https://console.cloud.google.com/agent-platform/locations/"
1361+
f"{_TEST_LOCATION}/batch-predictions/{_TEST_ID}"
1362+
f"?project={_TEST_PROJECT}"
1363+
)
1364+
assert uri == expected
1365+
13241366

13251367
@pytest.fixture
13261368
def get_mdm_job_mock():

vertexai/batch_prediction/_batch_prediction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def _dashboard_uri(self) -> Optional[str]:
292292
project = fields.pop("project")
293293
job = list(fields.values())[0]
294294
return (
295-
"https://console.cloud.google.com/ai/platform/locations/"
295+
"https://console.cloud.google.com/agent-platform/locations/"
296296
f"{location}/{self._job_type}/{job}?project={project}"
297297
)
298298

0 commit comments

Comments
 (0)