-
Notifications
You must be signed in to change notification settings - Fork 459
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
Add CLI command to export stack requirements #3158
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
.../how-to/infrastructure-deployment/stack-deployment/export-stack-requirements.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
description: Export stack requirements | ||
--- | ||
|
||
You can get the `pip` requirements of your stack by running the `zenml stack export-requirements <STACK-NAME>` CLI command. | ||
|
||
To install those requirements, it's best to write them to a file and then install them like this: | ||
```bash | ||
zenml stack export-requirements <STACK-NAME> --output-file stack_requirements.txt | ||
pip install -r stack_requirements.txt | ||
``` | ||
|
||
<figure><img src="https://static.scarf.sh/a.png?x-pxid=f0b4f458-0a54-4fcd-aa95-d5ee424815bc" alt="ZenML Scarf"><figcaption></figcaption></figure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright (c) ZenML GmbH 2024. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at: | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
# or implied. See the License for the specific language governing | ||
# permissions and limitations under the License. | ||
"""Requirement utils.""" | ||
|
||
from typing import TYPE_CHECKING, List, Set, Tuple | ||
|
||
from zenml.integrations.utils import get_integration_for_module | ||
|
||
if TYPE_CHECKING: | ||
from zenml.models import ComponentResponse, StackResponse | ||
|
||
|
||
def get_requirements_for_stack( | ||
stack: "StackResponse", | ||
) -> Tuple[List[str], List[str]]: | ||
"""Get requirements for a stack model. | ||
|
||
Args: | ||
stack: The stack for which to get the requirements. | ||
|
||
Returns: | ||
Tuple of PyPI and APT requirements of the stack. | ||
""" | ||
pypi_requirements: Set[str] = set() | ||
apt_packages: Set[str] = set() | ||
|
||
for component_list in stack.components.values(): | ||
assert len(component_list) == 1 | ||
component = component_list[0] | ||
( | ||
component_pypi_requirements, | ||
component_apt_packages, | ||
) = get_requirements_for_component(component=component) | ||
pypi_requirements = pypi_requirements.union( | ||
component_pypi_requirements | ||
) | ||
apt_packages = apt_packages.union(component_apt_packages) | ||
|
||
return sorted(pypi_requirements), sorted(apt_packages) | ||
|
||
|
||
def get_requirements_for_component( | ||
component: "ComponentResponse", | ||
) -> Tuple[List[str], List[str]]: | ||
"""Get requirements for a component model. | ||
|
||
Args: | ||
component: The component for which to get the requirements. | ||
|
||
Returns: | ||
Tuple of PyPI and APT requirements of the component. | ||
""" | ||
integration = get_integration_for_module( | ||
module_name=component.flavor.source | ||
) | ||
|
||
if integration: | ||
return integration.get_requirements(), integration.APT_PACKAGES | ||
else: | ||
return [], [] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This chapter IMO is not about exporting stack requirements. It's about telling a story about: