Skip to content

Commit

Permalink
Allow filtering pipeline runs by stack component
Browse files Browse the repository at this point in the history
  • Loading branch information
schustmi committed Oct 24, 2024
1 parent 024d612 commit ee8c0b4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/zenml/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3778,6 +3778,7 @@ def list_pipeline_runs(
code_repository: Optional[Union[UUID, str]] = None,
model: Optional[Union[UUID, str]] = None,
stack: Optional[Union[UUID, str]] = None,
stack_component: Optional[Union[UUID, str]] = None,
hydrate: bool = False,
) -> Page[PipelineRunResponse]:
"""List all pipeline runs.
Expand Down Expand Up @@ -3816,6 +3817,7 @@ def list_pipeline_runs(
code_repository: Filter by code repository name/ID.
model: Filter by model name/ID.
stack: Filter by stack name/ID.
stack_component: Filter by stack component name/ID.
hydrate: Flag deciding whether to hydrate the output model(s)
by including metadata fields in the response.
Expand Down Expand Up @@ -3854,6 +3856,7 @@ def list_pipeline_runs(
code_repository=code_repository,
stack=stack,
model=model,
stack_component=stack_component,
templatable=templatable,
)
runs_filter_model.set_scope_workspace(self.active_workspace.id)
Expand Down
20 changes: 20 additions & 0 deletions src/zenml/models/v2/core/pipeline_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ class PipelineRunFilter(WorkspaceScopedTaggableFilter):
"stack",
"code_repository",
"model",
"component",
"pipeline_name",
"templatable",
]
Expand Down Expand Up @@ -688,6 +689,10 @@ class PipelineRunFilter(WorkspaceScopedTaggableFilter):
default=None,
description="Name/ID of the model associated with the run.",
)
stack_component: Optional[Union[UUID, str]] = Field(
default=None,
description="Name/ID of the stack component associated with the run.",
)
templatable: Optional[bool] = Field(
default=None, description="Whether the run is templatable."
)
Expand Down Expand Up @@ -716,6 +721,8 @@ def get_custom_filters(
PipelineRunSchema,
PipelineSchema,
ScheduleSchema,
StackComponentSchema,
StackCompositionSchema,
StackSchema,
UserSchema,
)
Expand Down Expand Up @@ -821,6 +828,19 @@ def get_custom_filters(
)
custom_filters.append(model_filter)

if self.stack_component:
component_filter = and_(
PipelineRunSchema.deployment_id == PipelineDeploymentSchema.id,
PipelineDeploymentSchema.stack_id == StackSchema.id,
StackSchema.id == StackCompositionSchema.stack_id,
StackCompositionSchema.component_id == StackComponentSchema.id,
self.generate_name_or_id_query_conditions(
value=self.stack_component,
table=StackComponentSchema,
),
)
custom_filters.append(component_filter)

if self.pipeline_name:
pipeline_name_filter = and_(
PipelineRunSchema.pipeline_id == PipelineSchema.id,
Expand Down

0 comments on commit ee8c0b4

Please sign in to comment.