Skip to content

Commit 1c84464

Browse files
authored
fix(PipelineJob): use name as output only field (#719)
1 parent 9d1b01a commit 1c84464

File tree

2 files changed

+3
-23
lines changed

2 files changed

+3
-23
lines changed

google/cloud/aiplatform/pipeline_jobs.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@
4848
[gca_pipeline_state_v1beta1.PipelineState.PIPELINE_STATE_FAILED]
4949
)
5050

51-
# Vertex AI Pipelines service API job name relative name prefix pattern.
52-
_JOB_NAME_PATTERN = "{parent}/pipelineJobs/{job_id}"
53-
5451
# Pattern for valid names used as a Vertex resource name.
5552
_VALID_NAME_PATTERN = re.compile("^[a-z][-a-z0-9]{0,127}$")
5653

@@ -178,19 +175,18 @@ def __init__(
178175
)
179176

180177
pipeline_name = pipeline_job["pipelineSpec"]["pipelineInfo"]["name"]
181-
job_id = job_id or "{pipeline_name}-{timestamp}".format(
178+
self.job_id = job_id or "{pipeline_name}-{timestamp}".format(
182179
pipeline_name=re.sub("[^-0-9a-z]+", "-", pipeline_name.lower())
183180
.lstrip("-")
184181
.rstrip("-"),
185182
timestamp=_get_current_time().strftime("%Y%m%d%H%M%S"),
186183
)
187-
if not _VALID_NAME_PATTERN.match(job_id):
184+
if not _VALID_NAME_PATTERN.match(self.job_id):
188185
raise ValueError(
189186
"Generated job ID: {} is illegal as a Vertex pipelines job ID. "
190187
"Expecting an ID following the regex pattern "
191188
'"[a-z][-a-z0-9]{{0,127}}"'.format(job_id)
192189
)
193-
job_name = _JOB_NAME_PATTERN.format(parent=self._parent, job_id=job_id)
194190

195191
builder = pipeline_utils.PipelineRuntimeConfigBuilder.from_job_spec_json(
196192
pipeline_job
@@ -206,7 +202,6 @@ def __init__(
206202

207203
self._gca_resource = gca_pipeline_job_v1beta1.PipelineJob(
208204
display_name=display_name,
209-
name=job_name,
210205
pipeline_spec=pipeline_job["pipelineSpec"],
211206
labels=labels,
212207
runtime_config=runtime_config,
@@ -215,18 +210,6 @@ def __init__(
215210
),
216211
)
217212

218-
def _assert_gca_resource_is_available(self) -> None:
219-
# TODO(b/193800063) Change this to name after this fix
220-
if not getattr(self._gca_resource, "create_time", None):
221-
raise RuntimeError(
222-
f"{self.__class__.__name__} resource has not been created."
223-
+ (
224-
f" Resource failed with: {self._exception}"
225-
if self._exception
226-
else ""
227-
)
228-
)
229-
230213
@base.optional_sync()
231214
def run(
232215
self,
@@ -257,12 +240,10 @@ def run(
257240

258241
_LOGGER.log_create_with_lro(self.__class__)
259242

260-
# PipelineJob.name is not used by pipeline service
261-
pipeline_job_id = self._gca_resource.name.split("/")[-1]
262243
self._gca_resource = self.api_client.create_pipeline_job(
263244
parent=self._parent,
264245
pipeline_job=self._gca_resource,
265-
pipeline_job_id=pipeline_job_id,
246+
pipeline_job_id=self.job_id,
266247
)
267248

268249
_LOGGER.log_create_complete_with_getter(

tests/unit/aiplatform/test_pipeline_jobs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ def test_run_call_pipeline_service_create(
236236
# Construct expected request
237237
expected_gapic_pipeline_job = gca_pipeline_job_v1beta1.PipelineJob(
238238
display_name=_TEST_PIPELINE_JOB_DISPLAY_NAME,
239-
name=_TEST_PIPELINE_JOB_NAME,
240239
pipeline_spec={
241240
"components": {},
242241
"pipelineInfo": _TEST_PIPELINE_JOB_SPEC["pipelineSpec"]["pipelineInfo"],

0 commit comments

Comments
 (0)