Skip to content

Commit 244c489

Browse files
authored
Snapshot response improvements (#3995)
* Include latest run user in snapshot response * Move some response attributes from metadata to resources * Fix logic for fetching latest snapshot run * Include source snapshot in run response * Tests * Formatting
1 parent 377040c commit 244c489

File tree

10 files changed

+261
-257
lines changed

10 files changed

+261
-257
lines changed

src/zenml/models/v2/core/pipeline_run.py

Lines changed: 82 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -203,32 +203,6 @@ class PipelineRunResponseBody(ProjectScopedResponseBody):
203203
default=None,
204204
title="The reason for the status of the pipeline run.",
205205
)
206-
stack: Optional["StackResponse"] = Field(
207-
default=None, title="The stack that was used for this run."
208-
)
209-
pipeline: Optional["PipelineResponse"] = Field(
210-
default=None, title="The pipeline this run belongs to."
211-
)
212-
build: Optional["PipelineBuildResponse"] = Field(
213-
default=None, title="The pipeline build that was used for this run."
214-
)
215-
schedule: Optional["ScheduleResponse"] = Field(
216-
default=None, title="The schedule that was used for this run."
217-
)
218-
code_reference: Optional["CodeReferenceResponse"] = Field(
219-
default=None, title="The code reference that was used for this run."
220-
)
221-
snapshot_id: Optional[UUID] = Field(
222-
default=None, title="The snapshot that was used for this run."
223-
)
224-
trigger_execution: Optional["TriggerExecutionResponse"] = Field(
225-
default=None, title="The trigger execution that triggered this run."
226-
)
227-
model_version_id: Optional[UUID] = Field(
228-
title="The ID of the model version that was "
229-
"configured by this pipeline run explicitly.",
230-
default=None,
231-
)
232206

233207
model_config = ConfigDict(protected_namespaces=())
234208

@@ -286,10 +260,6 @@ class PipelineRunResponseMetadata(ProjectScopedResponseMetadata):
286260
description="DEPRECATED: Template used for the pipeline run.",
287261
deprecated=True,
288262
)
289-
source_snapshot_id: Optional[UUID] = Field(
290-
default=None,
291-
description="Source snapshot used for the pipeline run.",
292-
)
293263
is_templatable: bool = Field(
294264
default=False,
295265
description="Whether a template can be created from this run.",
@@ -300,6 +270,25 @@ class PipelineRunResponseResources(ProjectScopedResponseResources):
300270
"""Class for all resource models associated with the pipeline run entity."""
301271

302272
snapshot: Optional["PipelineSnapshotResponse"] = None
273+
source_snapshot: Optional["PipelineSnapshotResponse"] = None
274+
stack: Optional["StackResponse"] = Field(
275+
default=None, title="The stack that was used for this run."
276+
)
277+
pipeline: Optional["PipelineResponse"] = Field(
278+
default=None, title="The pipeline this run belongs to."
279+
)
280+
build: Optional["PipelineBuildResponse"] = Field(
281+
default=None, title="The pipeline build that was used for this run."
282+
)
283+
schedule: Optional["ScheduleResponse"] = Field(
284+
default=None, title="The schedule that was used for this run."
285+
)
286+
code_reference: Optional["CodeReferenceResponse"] = Field(
287+
default=None, title="The code reference that was used for this run."
288+
)
289+
trigger_execution: Optional["TriggerExecutionResponse"] = Field(
290+
default=None, title="The trigger execution that triggered this run."
291+
)
303292
model_version: Optional[ModelVersionResponse] = None
304293
tags: List[TagResponse] = Field(
305294
title="Tags associated with the pipeline run.",
@@ -383,78 +372,6 @@ def status(self) -> ExecutionStatus:
383372
"""
384373
return self.get_body().status
385374

386-
@property
387-
def stack(self) -> Optional["StackResponse"]:
388-
"""The `stack` property.
389-
390-
Returns:
391-
the value of the property.
392-
"""
393-
return self.get_body().stack
394-
395-
@property
396-
def pipeline(self) -> Optional["PipelineResponse"]:
397-
"""The `pipeline` property.
398-
399-
Returns:
400-
the value of the property.
401-
"""
402-
return self.get_body().pipeline
403-
404-
@property
405-
def build(self) -> Optional["PipelineBuildResponse"]:
406-
"""The `build` property.
407-
408-
Returns:
409-
the value of the property.
410-
"""
411-
return self.get_body().build
412-
413-
@property
414-
def schedule(self) -> Optional["ScheduleResponse"]:
415-
"""The `schedule` property.
416-
417-
Returns:
418-
the value of the property.
419-
"""
420-
return self.get_body().schedule
421-
422-
@property
423-
def trigger_execution(self) -> Optional["TriggerExecutionResponse"]:
424-
"""The `trigger_execution` property.
425-
426-
Returns:
427-
the value of the property.
428-
"""
429-
return self.get_body().trigger_execution
430-
431-
@property
432-
def code_reference(self) -> Optional["CodeReferenceResponse"]:
433-
"""The `schedule` property.
434-
435-
Returns:
436-
the value of the property.
437-
"""
438-
return self.get_body().code_reference
439-
440-
@property
441-
def snapshot_id(self) -> Optional["UUID"]:
442-
"""The `snapshot_id` property.
443-
444-
Returns:
445-
the value of the property.
446-
"""
447-
return self.get_body().snapshot_id
448-
449-
@property
450-
def model_version_id(self) -> Optional[UUID]:
451-
"""The `model_version_id` property.
452-
453-
Returns:
454-
the value of the property.
455-
"""
456-
return self.get_body().model_version_id
457-
458375
@property
459376
def run_metadata(self) -> Dict[str, MetadataType]:
460377
"""The `run_metadata` property.
@@ -564,15 +481,6 @@ def template_id(self) -> Optional[UUID]:
564481
"""
565482
return self.get_metadata().template_id
566483

567-
@property
568-
def source_snapshot_id(self) -> Optional[UUID]:
569-
"""The `source_snapshot_id` property.
570-
571-
Returns:
572-
the value of the property.
573-
"""
574-
return self.get_metadata().source_snapshot_id
575-
576484
@property
577485
def is_templatable(self) -> bool:
578486
"""The `is_templatable` property.
@@ -591,6 +499,69 @@ def snapshot(self) -> Optional["PipelineSnapshotResponse"]:
591499
"""
592500
return self.get_resources().snapshot
593501

502+
@property
503+
def source_snapshot(self) -> Optional["PipelineSnapshotResponse"]:
504+
"""The `source_snapshot` property.
505+
506+
Returns:
507+
the value of the property.
508+
"""
509+
return self.get_resources().source_snapshot
510+
511+
@property
512+
def stack(self) -> Optional["StackResponse"]:
513+
"""The `stack` property.
514+
515+
Returns:
516+
the value of the property.
517+
"""
518+
return self.get_resources().stack
519+
520+
@property
521+
def pipeline(self) -> Optional["PipelineResponse"]:
522+
"""The `pipeline` property.
523+
524+
Returns:
525+
the value of the property.
526+
"""
527+
return self.get_resources().pipeline
528+
529+
@property
530+
def build(self) -> Optional["PipelineBuildResponse"]:
531+
"""The `build` property.
532+
533+
Returns:
534+
the value of the property.
535+
"""
536+
return self.get_resources().build
537+
538+
@property
539+
def schedule(self) -> Optional["ScheduleResponse"]:
540+
"""The `schedule` property.
541+
542+
Returns:
543+
the value of the property.
544+
"""
545+
return self.get_resources().schedule
546+
547+
@property
548+
def trigger_execution(self) -> Optional["TriggerExecutionResponse"]:
549+
"""The `trigger_execution` property.
550+
551+
Returns:
552+
the value of the property.
553+
"""
554+
return self.get_resources().trigger_execution
555+
556+
@property
557+
def code_reference(self) -> Optional["CodeReferenceResponse"]:
558+
"""The `schedule` property.
559+
560+
Returns:
561+
the value of the property.
562+
"""
563+
return self.get_resources().code_reference
564+
594565
@property
595566
def model_version(self) -> Optional[ModelVersionResponse]:
596567
"""The `model_version` property.

0 commit comments

Comments
 (0)