Skip to content

Commit

Permalink
new: more verbose error if docker is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Oct 30, 2024
1 parent 3435563 commit a95669c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/docker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn run_command(command: &str, args: &[&str]) -> anyhow::Result<(String, String)>
}
}

fn docker_exists() -> bool {
pub(crate) fn docker_exists() -> bool {
run_command("docker", &["version"]).is_ok()
}

Expand Down
6 changes: 6 additions & 0 deletions src/core/handlers/pytorch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ impl Handler for PyTorchHandler {
detail: DetailLevel,
filter: Option<String>,
) -> anyhow::Result<Inspection> {
if !docker::docker_exists() {
return Err(anyhow::anyhow!(
"docker is required to inspect pytorch models, make sure the docker binary is in $PATH and that /var/run/docker.sock is shared from the host if you are running tensor-man itself inside a container."
));
}

docker::Inspector::new(
include_str!("inspect.Dockerfile"),
include_str!("inspect.py"),
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {
};

if let Err(e) = ret {
eprintln!("error: {}", e);
eprintln!("Error: {}", e);
std::process::exit(1);
}
}

0 comments on commit a95669c

Please sign in to comment.