Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GET step run endpoint to return unhydrated response if requested #3240

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/zenml/zen_server/routers/steps_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,16 @@ def get_step(
Returns:
The step.
"""
step = zen_store().get_run_step(step_id, hydrate=hydrate)
# We always fetch the step hydrated because we need the pipeline_run_id
# for the permission checks. If the user requested an unhydrated response,
# we later remove the metadata
step = zen_store().get_run_step(step_id, hydrate=True)
pipeline_run = zen_store().get_run(step.pipeline_run_id)
bcdurak marked this conversation as resolved.
Show resolved Hide resolved
verify_permission_for_model(pipeline_run, action=Action.READ)

if hydrate is False:
step.metadata = None

return dehydrate_response_model(step)


Expand Down
18 changes: 12 additions & 6 deletions src/zenml/zen_stores/schemas/pipeline_run_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def to_model(
)

if self.deployment is not None:
deployment = self.deployment.to_model()
deployment = self.deployment.to_model(include_metadata=True)
bcdurak marked this conversation as resolved.
Show resolved Hide resolved

config = deployment.pipeline_configuration
new_substitutions = config._get_full_substitutions(self.start_time)
Expand Down Expand Up @@ -365,12 +365,18 @@ def to_model(
):
is_templatable = True

steps = {step.name: step.to_model() for step in self.step_runs}

step_substitutions = {
step_name: step.config.substitutions
for step_name, step in steps.items()
steps = {
step.name: step.to_model(include_metadata=True)
for step in self.step_runs
}

step_substitutions = {}
for step_name, step in steps.items():
step_substitutions[step_name] = step.config.substitutions
# We fetch the steps hydrated before, but want them unhydrated
# in the response -> We need to reset the metadata here
step.metadata = None

metadata = PipelineRunResponseMetadata(
workspace=self.workspace.to_model(),
run_metadata=self.fetch_metadata(),
Expand Down
6 changes: 5 additions & 1 deletion src/zenml/zen_stores/sql_zen_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -8633,7 +8633,11 @@ def _update_pipeline_run_status(

# Deployment always exists for pipeline runs of newer versions
assert pipeline_run.deployment
num_steps = len(pipeline_run.deployment.to_model().step_configurations)
num_steps = len(
pipeline_run.deployment.to_model(
include_metadata=True
).step_configurations
)
new_status = get_pipeline_run_status(
step_statuses=[
ExecutionStatus(step_run.status) for step_run in step_runs
Expand Down
Loading