From daccf9489d6a10c61769b786f64bdf03270c6255 Mon Sep 17 00:00:00 2001 From: Sergey Serebryakov Date: Sun, 23 Jul 2023 23:39:31 -0700 Subject: [PATCH] Removing "sha256:" prefix in hash values returned by docker's runner inspect command. (#318) --- runners/mlcube_docker/mlcube_docker/docker_run.py | 5 ++++- .../mlcube_docker/mlcube_docker/tests/test_docker_runner.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/runners/mlcube_docker/mlcube_docker/docker_run.py b/runners/mlcube_docker/mlcube_docker/docker_run.py index 1e2cf9f..1d73bfa 100644 --- a/runners/mlcube_docker/mlcube_docker/docker_run.py +++ b/runners/mlcube_docker/mlcube_docker/docker_run.py @@ -376,4 +376,7 @@ def inspect(self, force: bool = False) -> t.Dict: f"Unexpected output from `{' '.join(docker_inspect_cmd)}`. Expected a list of dicts of length 1." ) - return {"hash": image_info[0].get("Id", None)} + image_id: str = image_info[0].get("Id", None) + if image_id and image_id.startswith("sha256:"): + image_id = image_id[7:] + return {"hash": image_id} diff --git a/runners/mlcube_docker/mlcube_docker/tests/test_docker_runner.py b/runners/mlcube_docker/mlcube_docker/tests/test_docker_runner.py index 20389be..1134c93 100644 --- a/runners/mlcube_docker/mlcube_docker/tests/test_docker_runner.py +++ b/runners/mlcube_docker/mlcube_docker/tests/test_docker_runner.py @@ -32,7 +32,7 @@ class TestDockerRunner(TestCase): def _check_inspect_output(self, info: t.Dict) -> None: self.assertIsInstance(info, dict) self.assertIn("hash", info) - self.assertTrue(info["hash"].startswith("sha256:")) + self.assertFalse(info["hash"].startswith("sha256:")) @staticmethod def noop(*args, **kwargs) -> None: