Skip to content

Conversation

schustmi
Copy link
Contributor

@schustmi schustmi commented May 15, 2025

Describe changes

This PR improves the performance of the ZenML server by optimizing responses and DB queries.

Breaking changes

  • Model.get_pipeline_run(...) as well as ModelVersionResponse.get_pipeline_run(...) have been removed. Use Client().list_pipeline_runs(name=...) instead.
  • All response changes below are breaking on the API level and also mean client/server will be incompatible with previous ZenML versions.

Response changes

  • The pipeline run response does not include steps anymore. For large pipelines, this unpaginated list was the main cause of the huge run response.
  • The pipeline run response does not include the substitutions for all its steps anymore. This was included to avoid hydration calls of the steps themselves. Instead, each step now includes its own substitutions on the body.
  • The model version response does not include a list of all artifact IDs and run IDs anymore.
  • Many attributes moved from body to resources, which means they will not be included anymore if this model is included in a different response.

Detailed list of response changes:

  • For all user-scoped responses, body.user was moved to resources.user and a new attribute body.user_id was added.
  • For all project-scoped responses, metadata.project was removed. A new body.project_id attribute has been added as replacement.
  • Artifact response:
    • body.tags got moved to resources.tags
    • body.latest_version_name got moved to resources.latest_version_name
    • body.latest_version_id got moved to resources.latest_version_id
  • ArtifactVersion response:
    • body.tags got moved to resources.tags
    • body.producer_pipeline_run_id got moved to resources.producer_pipeline_run_id
    • metadata.producer_step_run_id got moved to resources.producer_step_run_id
  • Model response:
    • body.tags got moved to resources.tags
    • body.latest_version_name got moved to resources.latest_version_name
    • body.latest_version_id got moved to resources.latest_version_id
  • ModelVersion response:
    • body.model_artifact_ids, body.data_artifact_ids, body.deployment_artifact_ids and body.pipeline_run_ids got removed
    • body.tags got moved to resources.tags
  • Pipeline response:
    • body.latest_run_id got moved to resources.latest_run_id
    • body.latest_run_status got moved to resources.latest_run_status
  • PipelineDeployment response:
    • resources.triggers got removed
  • PipelineRun response:
    • metadata.steps and metadata.step_substitutions got removed
  • RunTemplate response:
    • body.latest_run_id got moved to resources.latest_run_id
    • body.latest_run_status got moved to resources.latest_run_status
  • StepRun response:
    • body.inputs moved to resources.inputs and changed type to allow multiple inputs for one name
    • body.outputs moved to resources.outputs
    • New attribute body.substitutions
  • Tag response:
    • body.tagged_count moved to metadata.tagged_count

Database changes:

  • In some places where we know that we need to fetch additional related objects from the database, we now use joined loads to avoid unnecessary DB calls.
  • The query to fetch the producer run of an artifact version has been improved to only fetch that run instead of looping over all runs associated with the artifact.
  • The query to fetch the amount resources that a tag is applied to has been optimized.

Misc other changes:

  • When fetching pipeline runs, there is now an option that controls whether the metadata of all its steps should be included. By default this is set to False, which reduces the amount of DB entries that need to be fetched especially for pipelines with many steps.
  • A new endpoint GET /runs/<ID>/dag has been added. This allows the frontend to fetch only relevant information for the DAG visualizer screen without fetching details about all steps in the pipeline run.
  • Step run responses now correctly include all their inputs even if multiple for a name exist. Previously only one for each name was returned. Additionally, the input type is now correctly inferred for cached steps with multiple inputs for the same name.

Pre-requisites

Please ensure you have done the following:

  • I have read the CONTRIBUTING.md document.
  • I have added tests to cover my changes.
  • I have based my new branch on develop and the open PR is targeting develop. If your branch wasn't based on develop read Contribution guide on rebasing branch to develop.
  • IMPORTANT: I made sure that my changes are reflected properly in the following resources:
    • ZenML Docs
    • Dashboard: Needs to be communicated to the frontend team.
    • Templates: Might need adjustments (that are not reflected in the template tests) in case of non-breaking changes and deprecations.
    • Projects: Depending on the version dependencies, different projects might get affected.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Other (add details above)

Copy link
Contributor

coderabbitai bot commented May 15, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added internal To filter out internal PRs and issues enhancement New feature or request labels May 15, 2025
@schustmi schustmi force-pushed the feature/response-sizes branch from 5196571 to 57d45b5 Compare May 16, 2025 10:22
@schustmi schustmi changed the title Optimize response sizes Performance optimizations May 16, 2025
@schustmi schustmi changed the title Performance optimizations Performance improvements May 16, 2025
@schustmi schustmi force-pushed the feature/response-sizes branch from 7ce68dc to 953c1d7 Compare May 21, 2025 15:59
Copy link
Contributor

ZenML CLI Performance Comparison (Threshold: 1.0s, Timeout: 60s, Slow: 5s)

❌ Failed Commands on Current Branch (feature/response-sizes)

  • zenml stack list: Command failed on run 1 (exit code: 1)
  • zenml pipeline list: Command failed on run 1 (exit code: 1)
  • zenml model list: Command failed on run 1 (exit code: 1)

🚨 New Failures Introduced

The following commands fail on your branch but worked on the target branch:

  • zenml stack list
  • zenml pipeline list
  • zenml model list

Performance Comparison

Command develop Time (s) feature/response-sizes Time (s) Difference Status
zenml --help 1.557516 ± 0.014933 1.510112 ± 0.010724 -0.047s ✓ No significant change
zenml model list Not tested Failed N/A ❌ Broken in current branch
zenml pipeline list Not tested Failed N/A ❌ Broken in current branch
zenml stack --help 1.539052 ± 0.005099 1.498210 ± 0.016703 -0.041s ✓ No significant change
zenml stack list Not tested Failed N/A ❌ Broken in current branch

Summary

  • Total commands analyzed: 5
  • Commands compared for timing: 2
  • Commands improved: 0 (0.0% of compared)
  • Commands degraded: 0 (0.0% of compared)
  • Commands unchanged: 2 (100.0% of compared)
  • Failed commands: 3 (NEW FAILURES INTRODUCED)
  • Timed out commands: 0
  • Slow commands: 0

Environment Info

  • Target branch: Linux 6.11.0-1014-azure
  • Current branch: Linux 6.11.0-1014-azure
  • Test timestamp: 2025-05-22T09:27:38Z
  • Timeout: 60 seconds
  • Slow threshold: 5 seconds

@schustmi schustmi force-pushed the feature/response-sizes branch from 70f923e to 9a5c558 Compare May 22, 2025 09:44
@schustmi schustmi force-pushed the feature/response-sizes branch from 91925d4 to 4970a35 Compare May 22, 2025 09:55
@schustmi schustmi force-pushed the feature/response-sizes branch from 77283a1 to 598b651 Compare May 23, 2025 10:30
@schustmi schustmi force-pushed the feature/response-sizes branch from 598b651 to d1c959b Compare May 23, 2025 12:49
Copy link
Contributor

@stefannica stefannica left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't do a thorough review, as many of these changes need deep model and DB schema knowledge. Looks alright otherwise.

Comment on lines +360 to +362
from zenml.client import Client

return Client().get_project(self.project_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saving this in the object might help reduce the number of API/DB calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used just once in our code, which is why I decided to not cache this. Do you still think it's necessary?

@schustmi schustmi requested a review from stefannica May 26, 2025 12:00
@schustmi schustmi merged commit 26430a9 into develop May 27, 2025
96 of 110 checks passed
@schustmi schustmi deleted the feature/response-sizes branch May 27, 2025 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change enhancement New feature or request internal To filter out internal PRs and issues run-slow-ci
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants