Skip to content

Commit

Permalink
Merge pull request #680 from kush-gupt/main
Browse files Browse the repository at this point in the history
Pull the source model if it isn't already in local storage for the convert and push functions
  • Loading branch information
ericcurtin authored Jan 31, 2025
2 parents 961b691 + 574ac2a commit 5b1f1a1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 2 additions & 0 deletions ramalama/ollama.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion test/system/040-serve.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
2 changes: 1 addition & 1 deletion test/system/050-pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/system/055-convert.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 5b1f1a1

Please sign in to comment.