Skip to content

Commit

Permalink
Merge pull request #1062 from basetenlabs/bump-version-0.9.26
Browse files Browse the repository at this point in the history
Release 0.9.26
  • Loading branch information
squidarth authored Aug 1, 2024
2 parents bed5129 + 524934f commit 3756c20
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "truss"
version = "0.9.25"
version = "0.9.26"
description = "A seamless bridge from model development to model delivery"
license = "MIT"
readme = "README.md"
Expand Down
23 changes: 10 additions & 13 deletions truss/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,6 @@ def predict(
@click.argument("script", required=True)
@click.argument("target_directory", required=False, default=os.getcwd())
def run_python(script, target_directory):
from python_on_whales.exceptions import DockerException

if not Path(script).exists():
raise click.BadParameter(
f"File {script} does not exist. Please provide a valid file."
Expand All @@ -744,20 +742,19 @@ def run_python(script, target_directory):
)

tr = _get_truss_from_directory(target_directory=target_directory)
output_stream = tr.run_python_script(Path(script))
try:
for output in output_stream:
output_type = output[0]
output_content = output[1]
container = tr.run_python_script(Path(script))
for output in container.logs():
output_type = output[0]
output_content = output[1]

options = {}
options = {}

if output_type == "stderr":
options["fg"] = "red"
if output_type == "stderr":
options["fg"] = "red"

click.secho(output_content.decode("utf-8", "replace"), nl=False, **options)
except DockerException:
pass
click.secho(output_content.decode("utf-8", "replace"), nl=False, **options)
exit_code = container.wait()
sys.exit(exit_code)


@truss_cli.command()
Expand Down
17 changes: 16 additions & 1 deletion truss/truss_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,21 @@
logger.addHandler(logging.StreamHandler(sys.stdout))


class RunningContainer:
def __init__(self, container):
self.container = container

def logs(self):
from python_on_whales import docker

return docker.logs(self.container, follow=True, stream=True)

def wait(self):
from python_on_whales import docker

return docker.wait(self.container)


class TrussHandle:
def __init__(self, truss_dir: Path, validate: bool = True) -> None:
self._truss_dir = truss_dir
Expand Down Expand Up @@ -198,7 +213,7 @@ def _docker_run(gpus: Optional[str] = None):
add_hosts=[("host.docker.internal", "host-gateway")],
)

return Docker.client().logs(container, follow=True, stream=True)
return RunningContainer(container)

try:
return _docker_run("all" if self._spec.config.resources.use_gpu else None)
Expand Down

0 comments on commit 3756c20

Please sign in to comment.