Skip to content

Commit

Permalink
fix: add line endings for python_packages(...) (#5203)
Browse files Browse the repository at this point in the history
* fix: add line endings for python_packages(...)

Signed-off-by: Frost Ming <[email protected]>

* fix: pin test dep

Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming authored Feb 7, 2025
1 parent cdbc29c commit c94f281
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def run_unittest(session: nox.Session):
def run_framework_integration_test(session: nox.Session, framework: str):
session.run("pdm", "sync", "-G", "testing", external=True)
session.install(
"torch",
"torch<2.6",
"torchaudio",
"torchvision",
"-i",
Expand Down
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

0 comments on commit c94f281

Please sign in to comment.