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

Skypilot with Kubernetes #3033

Merged
merged 23 commits into from
Sep 25, 2024
Merged

Skypilot with Kubernetes #3033

merged 23 commits into from
Sep 25, 2024

Conversation

safoinme
Copy link
Contributor

@safoinme safoinme commented Sep 22, 2024

Describe changes

I implemented/fixed _ to achieve _.

Pre-requisites

Please ensure you have done the following:

  • I have read the CONTRIBUTING.md document.
  • If my change requires a change to docs, I have updated the documentation accordingly.
  • 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.
  • If my changes require changes to the dashboard, these changes are communicated/requested.

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)

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a comprehensive guide for integrating SkyPilot with Kubernetes in the documentation.
    • Added the SkypilotKubernetesIntegration to enhance ZenML's integration capabilities.
    • Implemented the SkypilotKubernetesOrchestrator for managing pipeline execution in Kubernetes environments.
  • Documentation

    • Expanded documentation detailing installation, configuration, and limitations of the Kubernetes orchestrator.
    • Included a code example for setting up Kubernetes orchestrator settings.
  • Bug Fixes

    • Added warnings regarding unsupported features in the Kubernetes orchestrator.

This commit adds the Skypilot Kubernetes integration to enable remote orchestration of ZenML pipelines on VMs. The integration includes the necessary initialization, configuration, and flavor classes. It also adds the Skypilot Kubernetes orchestrator and its settings. This integration provides an alternative to the local orchestrator for running pipelines on Kubernetes.
Copy link
Contributor

coderabbitai bot commented Sep 22, 2024

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.

Walkthrough

Walkthrough

The changes introduce a new Kubernetes orchestrator for the SkyPilot integration within the ZenML framework. This includes comprehensive documentation updates, the addition of new classes and constants, and enhancements to existing orchestrator functionalities. The new orchestrator facilitates the execution of ZenML pipelines on virtual machines in Kubernetes environments, with specific configurations and settings tailored for this deployment model.

Changes

Files Change Summary
docs/book/component-guide/orchestrators/skypilot-vm.md Added a section for Kubernetes orchestrator documentation, including installation, configuration, limitations, and examples.
src/zenml/integrations/__init__.py Introduced SkypilotKubernetesIntegration to the ZenML integrations module.
src/zenml/integrations/constants.py Added constant SKYPILOT_KUBERNETES for SkyPilot Kubernetes integration.
src/zenml/integrations/skypilot/orchestrators/skypilot_base_vm_orchestrator.py Modified prepare_or_run_pipeline to enhance command execution and environment variable handling for Kubernetes.
src/zenml/integrations/skypilot_kubernetes/__init__.py Created SkypilotKubernetesIntegration class with attributes and installation checks for the integration.
src/zenml/integrations/skypilot_kubernetes/flavors/__init__.py Introduced module for Skypilot Kubernetes orchestrator flavors, importing necessary classes.
src/zenml/integrations/skypilot_kubernetes/flavors/skypilot_orchestrator_kubernetes_vm_flavor.py Defined classes for orchestrator settings, configuration, and flavor specific to Kubernetes.
src/zenml/integrations/skypilot_kubernetes/orchestrators/__init__.py Initialized Skypilot Kubernetes orchestrators, specifying public interface.
src/zenml/integrations/skypilot_kubernetes/orchestrators/skypilot_kubernetes_vm_orchestrator.py Implemented SkypilotKubernetesOrchestrator class with methods for managing Kubernetes pipeline execution.

Possibly related PRs

Poem

🐰 In the meadow, changes bloom,
Kubernetes joins the orchestration room.
Pipelines dance on virtual air,
With SkyPilot, we have flair!
New settings, flavors, all in line,
ZenML's future, oh so fine! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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.
    -- Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    -- @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 generate unit testing code.
    -- @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.

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 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 Sep 22, 2024
Copy link
Contributor

@htahir1 htahir1 left a comment

Choose a reason for hiding this comment

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

In addition to my comments, we also need to add docs :-)

"DOCKER_USERNAME": docker_username,
"DOCKER_PASSWORD": docker_password,
}
task_envs["DOCKER_USERNAME"] = (docker_username,)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this a tuple now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not I haven't pushed the latest stuff


# Run the entire pipeline

# Set the service connector AWS profile ENV variable
self.prepare_environment_variable(set=True)

try:
if isinstance(self.cloud, sky.clouds.Kubernetes):
image = image
run_command = f"/opt/venv/bin/{entrypoint_str} {arguments_str}"
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems like a weird entrypoint.. have you tested it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now this is a tricky one, Not sure what would be the exact solution long term but if we give skypilot the entrypoint it would use the default Python which is Miniconada but we want to use the one we have already set when building docker image in pipeline run and that python version is in /opt/venv/bin/

Copy link
Contributor

Choose a reason for hiding this comment

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

then i would at lest make it configurable from the outside in case something weird changes

Copy link
Contributor

Choose a reason for hiding this comment

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

Not just something weird, but anyone using a custom image which does not magically use the same venv.
What is skypilot doing exactly? Because just calling python should just use the venv/system python that's active, or do they do some magic to prevent that?

Copy link
Contributor Author

@safoinme safoinme Sep 23, 2024

Choose a reason for hiding this comment

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

They actually do some magic which basically forces us to either figure out which env to use or stop building the image as it is and use skypilot image to build on top of it and consider it like lightning studio where we only run command afterward, @htahir1 @michael-zenml which means stop building docker image for this integration and have pip install and zenml install a commands that get's passed to skypilot setup argument

…otKubernetesOrchestrator prepare_environment_variable method

# Run the entire pipeline

# Set the service connector AWS profile ENV variable
self.prepare_environment_variable(set=True)

try:
if isinstance(self.cloud, sky.clouds.Kubernetes):
Copy link
Contributor

Choose a reason for hiding this comment

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

This might seem mostly cosmetic, but I'll say it anyway: you're adding implementation specific conditions in the base class, which is supposed to be implementation agnostic. The correct way to do this is through static attributes, properties or methods that the implementations can override.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well i think i want to re-work the whole Skypilot integration if possible so instead of have a base abstraction and many sub integration which blocks one of the most important features of skypilot cross-cloud/env failover, tho I totally agree with your comment


# Run the entire pipeline

# Set the service connector AWS profile ENV variable
self.prepare_environment_variable(set=True)

try:
if isinstance(self.cloud, sky.clouds.Kubernetes):
run_command = f"$VIRTUAL_ENV{entrypoint_str} {arguments_str}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this doesn't work right, $VIRTUAL_ENV is for example /opt/venv and the python is in /opt/venv/bin/python. So this needs the bin directory to work, and then also a fallback in case $VIRTUAL_ENV is not set.

And we need to make sure this is actually working

Copy link
Contributor

Choose a reason for hiding this comment

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

yes this is important @safoinme

Raises:
ValueError: If no service connector is found.
"""
connector = self.get_connector()
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a misuse of the method, this isn't actually preparing any environment variables.

Maybe this should be in SkypilotKubernetesOrchestrator.prepare_pipeline_deployment(...)? This method gets called for each stack component before a pipeline run

@htahir1
Copy link
Contributor

htahir1 commented Sep 24, 2024

@coderabbitai summary

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Actions performed

Summary regeneration triggered.

Copy link
Contributor

@htahir1 htahir1 left a comment

Choose a reason for hiding this comment

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

Approved barring michaels comment


# Run the entire pipeline

# Set the service connector AWS profile ENV variable
self.prepare_environment_variable(set=True)

try:
if isinstance(self.cloud, sky.clouds.Kubernetes):
run_command = f"${{VIRTUAL_ENV:+$VIRTUAL_ENV/bin/}}{entrypoint_str} {arguments_str}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Which shell should this run in? Doesn't work for me somehow

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah it's the double brackets because of the f-string, my bad. If you tested this and it works, feel free to merge.

@safoinme safoinme merged commit b711963 into develop Sep 25, 2024
79 of 83 checks passed
@safoinme safoinme deleted the feature/skypilot-kubernetes branch September 25, 2024 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants