Skip to content

Commit

Permalink
Include user of latest run in pipeline response (#3262)
Browse files Browse the repository at this point in the history
* Include user of latest run in pipeline response

* Linting

* Fix optional check
  • Loading branch information
schustmi authored Dec 13, 2024
1 parent 87cf23d commit 941dc81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/zenml/models/v2/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from zenml.models.v2.core.tag import TagResponse

if TYPE_CHECKING:
from zenml.models.v2.core.pipeline_run import PipelineRunResponse
from zenml.models import PipelineRunResponse, UserResponse
from zenml.zen_stores.schemas import BaseSchema

AnySchema = TypeVar("AnySchema", bound=BaseSchema)
Expand Down Expand Up @@ -119,6 +119,10 @@ class PipelineResponseMetadata(WorkspaceScopedResponseMetadata):
class PipelineResponseResources(WorkspaceScopedResponseResources):
"""Class for all resource models associated with the pipeline entity."""

latest_run_user: Optional["UserResponse"] = Field(
default=None,
title="The user that created the latest run of this pipeline.",
)
tags: List[TagResponse] = Field(
title="Tags associated with the pipeline.",
)
Expand Down
5 changes: 5 additions & 0 deletions src/zenml/zen_stores/schemas/pipeline_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ def to_model(

resources = None
if include_resources:
latest_run_user = self.runs[-1].user if self.runs else None

resources = PipelineResponseResources(
latest_run_user=latest_run_user.to_model()
if latest_run_user
else None,
tags=[t.tag.to_model() for t in self.tags],
)

Expand Down

0 comments on commit 941dc81

Please sign in to comment.