diff --git a/src/core/docker/mod.rs b/src/core/docker/mod.rs index 0da4391..5ad6f45 100644 --- a/src/core/docker/mod.rs +++ b/src/core/docker/mod.rs @@ -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() } diff --git a/src/core/handlers/pytorch/mod.rs b/src/core/handlers/pytorch/mod.rs index c17a51e..31e13c0 100644 --- a/src/core/handlers/pytorch/mod.rs +++ b/src/core/handlers/pytorch/mod.rs @@ -53,6 +53,12 @@ impl Handler for PyTorchHandler { detail: DetailLevel, filter: Option, ) -> anyhow::Result { + 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"), diff --git a/src/main.rs b/src/main.rs index 675f50d..b2b5dfb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ fn main() { }; if let Err(e) = ret { - eprintln!("error: {}", e); + eprintln!("Error: {}", e); std::process::exit(1); } }