Skip to content

Commit

Permalink
new: added verbose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Jan 10, 2025
1 parent 859f6dc commit 1a61821
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions dyana_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def trace(
no_gpu: bool = typer.Option(help="Do not use GPUs.", default=False),
allow_network: bool = typer.Option(help="Allow network access to the model container.", default=False),
allow_volume_write: bool = typer.Option(help="Mount volumes as read-write.", default=False),
verbose: bool = typer.Option(help="Verbose mode.", default=False),
) -> None:
# disable GPU on non-Linux systems
if not no_gpu and platform_pkg.system() != "Linux":
Expand Down
5 changes: 3 additions & 2 deletions dyana_cli/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def build(
platform: str | None = None,
build_args: dict[str, str] | None = None,
force_rebuild: bool = False,
verbose: bool = False,
) -> Image:
if client is None:
raise Exception("Docker not available")
Expand All @@ -55,12 +56,12 @@ def build(
# remove intermediate containers
rm=True,
):
# TODO: find a way to be less verbose when using cached images
if "error" in item:
print()
raise Exception(item["error"])
elif "stream" in item:
print("[dim]" + item["stream"].strip() + "[/]")
if verbose:
print("[dim]" + item["stream"].strip() + "[/]")
elif "aux" in item:
id = item["aux"].get("ID")

Expand Down
12 changes: 10 additions & 2 deletions dyana_cli/loaders/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ class Run(BaseModel):

class Loader:
def __init__(
self, name: str, timeout: int, build: bool = True, platform: str | None = None, args: list[str] | None = None
self,
name: str,
timeout: int,
build: bool = True,
platform: str | None = None,
args: list[str] | None = None,
verbose: bool = False,
):
# make sure that name does not include a path traversal
if "/" in name or ".." in name:
Expand Down Expand Up @@ -76,7 +82,9 @@ def __init__(

if build:
print(f":whale: [bold]loader[/]: initializing loader [bold]{name}[/]")
self.image = docker.build(self.path, self.image_name, platform=self.platform, build_args=self.build_args)
self.image = docker.build(
self.path, self.image_name, platform=self.platform, build_args=self.build_args, verbose=verbose
)
if self.platform:
print(
f":whale: [bold]loader[/]: using image [green]{self.image.tags[0]}[/] [dim]({self.image.id})[/] ({self.platform})"
Expand Down

0 comments on commit 1a61821

Please sign in to comment.