Skip to content

Commit a95669c

Browse files
committed
new: more verbose error if docker is missing
1 parent 3435563 commit a95669c

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

src/core/docker/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn run_command(command: &str, args: &[&str]) -> anyhow::Result<(String, String)>
2828
}
2929
}
3030

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

src/core/handlers/pytorch/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ impl Handler for PyTorchHandler {
5353
detail: DetailLevel,
5454
filter: Option<String>,
5555
) -> anyhow::Result<Inspection> {
56+
if !docker::docker_exists() {
57+
return Err(anyhow::anyhow!(
58+
"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."
59+
));
60+
}
61+
5662
docker::Inspector::new(
5763
include_str!("inspect.Dockerfile"),
5864
include_str!("inspect.py"),

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn main() {
1616
};
1717

1818
if let Err(e) = ret {
19-
eprintln!("error: {}", e);
19+
eprintln!("Error: {}", e);
2020
std::process::exit(1);
2121
}
2222
}

0 commit comments

Comments
 (0)