From 480fd7a81cd529e25638092d77f587643d18ece9 Mon Sep 17 00:00:00 2001 From: Kush Gupta Date: Thu, 30 Jan 2025 19:01:45 -0500 Subject: [PATCH 1/6] Update _get_source to pull the source if it doesn't exist already Added a condition to check if the source model already exists, otherwise pull it down for the convert or push (convert and push were the only cli functions that used _get_source as far as I could tell) Signed-off-by: Kush Gupta --- ramalama/cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ramalama/cli.py b/ramalama/cli.py index e6afd28e..69f404d0 100644 --- a/ramalama/cli.py +++ b/ramalama/cli.py @@ -663,6 +663,8 @@ def _get_source(args): if smodel.type == "OCI": return src else: + if not smodel.exists(args): + return smodel.pull(args) return smodel.path(args) From 79701438d49b37636a2bfb9ac7d4dfcdca504446 Mon Sep 17 00:00:00 2001 From: Kush Gupta Date: Thu, 30 Jan 2025 19:38:12 -0500 Subject: [PATCH 2/6] Update error handling in Ollama's pull function Give the user a more descriptive error if getting a HTTP Error 404: Not Found Signed-off-by: Kush Gupta --- ramalama/ollama.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ramalama/ollama.py b/ramalama/ollama.py index 32aa4565..4432cb4d 100644 --- a/ramalama/ollama.py +++ b/ramalama/ollama.py @@ -107,6 +107,8 @@ def pull(self, args): try: return init_pull(repos, accept, registry_head, model_name, model_tag, models, model_path, self.model) except urllib.error.HTTPError as e: + if "Not Found" in e.reason: + raise KeyError(f"{self.model} was not found in the Ollama registry") raise KeyError(f"failed to pull {registry_head}: " + str(e).strip("'")) def model_path(self, args): From 4f56f45c9cae6b111fefafcc0005914333fa47ac Mon Sep 17 00:00:00 2001 From: Kush Gupta Date: Thu, 30 Jan 2025 19:39:33 -0500 Subject: [PATCH 3/6] Update 055-convert.bats Update new error message for not finding an Ollama model in the convert test Signed-off-by: Kush Gupta --- test/system/055-convert.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/055-convert.bats b/test/system/055-convert.bats index c6afdcab..7a331b20 100644 --- a/test/system/055-convert.bats +++ b/test/system/055-convert.bats @@ -10,7 +10,7 @@ load helpers run_ramalama 2 convert tiny is "$output" ".*ramalama convert: error: the following arguments are required: TARGET" run_ramalama 1 convert bogus foobar - is "$output" "Error: bogus does not exist" + is "$output" "Error: bogus was not found in the Ollama registry" } @test "ramalama convert file to image" { From 7dc07fa80503c5a2532bc52bad0b57964f675491 Mon Sep 17 00:00:00 2001 From: Kush Gupta Date: Thu, 30 Jan 2025 19:49:15 -0500 Subject: [PATCH 4/6] Update pull test expected output Gives the user a clearer message on HTTP 404 Not Found Errors when trying and failing to pull from Ollama Signed-off-by: Kush Gupta --- test/system/050-pull.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/050-pull.bats b/test/system/050-pull.bats index 30299780..8559f32c 100644 --- a/test/system/050-pull.bats +++ b/test/system/050-pull.bats @@ -26,7 +26,7 @@ load setup_suite random_image_name=i_$(safename) run_ramalama 1 pull ${random_image_name} - is "$output" "Error: failed to pull https://registry.ollama.ai/v2/library/${random_image_name}: HTTP Error 404: Not Found" "image does not exist" + is "$output" "Error: ${random_image_name} was not found in the Ollama registry" } # bats test_tags=distro-integration From 2619a16e418f9b73462b4c99d7a7727a38f5c7fa Mon Sep 17 00:00:00 2001 From: Kush Gupta Date: Thu, 30 Jan 2025 19:57:21 -0500 Subject: [PATCH 5/6] Change serve error output to better reflect the error Signed-off-by: Kush Gupta --- install.sh | 4 ++-- test/system/040-serve.bats | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 3f32dce0..0168ba9d 100755 --- a/install.sh +++ b/install.sh @@ -89,8 +89,8 @@ setup_ramalama() { local binfile="ramalama" local from_file="${binfile}" local host="https://raw.githubusercontent.com" - local branch="${BRANCH:-s}" - local url="${host}/containers/ramalama/${branch}/bin/${from_file}" + local branch="main" + local url="${host}/kush-gupt/ramalama/${branch}/bin/${from_file}" local to_file="${2}/${from_file}" if [ "$os" == "Darwin" ]; then diff --git a/test/system/040-serve.bats b/test/system/040-serve.bats index f3680703..311e9c26 100755 --- a/test/system/040-serve.bats +++ b/test/system/040-serve.bats @@ -45,7 +45,7 @@ verify_begin=".*run --rm -i --label RAMALAMA --security-opt=label=disable --name fi run_ramalama 1 serve MODEL - is "$output" ".*Error: failed to pull .*MODEL" "failed to pull model" + is "$output" "Error: MODEL was not found in the Ollama registry" } @test "ramalama --detach serve" { From 574ac2a4e37f6eeb9206c4c4ea3e037064ae007a Mon Sep 17 00:00:00 2001 From: Kush Gupta Date: Thu, 30 Jan 2025 20:13:14 -0500 Subject: [PATCH 6/6] accidentally overwrote install.sh Signed-off-by: Kush Gupta --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 0168ba9d..3f32dce0 100755 --- a/install.sh +++ b/install.sh @@ -89,8 +89,8 @@ setup_ramalama() { local binfile="ramalama" local from_file="${binfile}" local host="https://raw.githubusercontent.com" - local branch="main" - local url="${host}/kush-gupt/ramalama/${branch}/bin/${from_file}" + local branch="${BRANCH:-s}" + local url="${host}/containers/ramalama/${branch}/bin/${from_file}" local to_file="${2}/${from_file}" if [ "$os" == "Darwin" ]; then