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: add line endings for python_packages(...) #5203

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Changes from 1 commit
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
13 changes: 11 additions & 2 deletions src/_bentoml_sdk/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ def python_packages(self, *packages: str) -> t.Self:
.python_packages("numpy", "pandas")\
.requirements_file("requirements.txt")
"""
self.python_requirements += "\n".join(packages)
if not packages:
raise BentoMLConfigException("No packages provided")
self.python_requirements += "\n".join(packages) + "\n"
self._after_pip_install = True
return self

Expand All @@ -82,7 +84,14 @@ def run(self, command: str) -> t.Self:
return self

def run_script(self, script: str) -> t.Self:
"""Run a script in the image. Supports chaining call."""
"""Run a script in the image. Supports chaining call.

Example:

.. code-block:: python

image = Image("debian:latest").run_script("script.sh")
"""
commands = self.post_commands if self._after_pip_install else self.commands
script = Path(script).resolve().as_posix()
# Files under /env/docker will be copied into the env image layer
Expand Down
Loading