From ad04b63648c1e458f23133b04b22a779c019f5f2 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 22 Aug 2024 11:56:35 -0400 Subject: [PATCH] Move push code to transport python Signed-off-by: Daniel J Walsh --- ramalama.py | 3 +++ ramalama/cli.py | 9 +++++---- ramalama/huggingface.py | 3 +++ ramalama/ollama.py | 3 +++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ramalama.py b/ramalama.py index be4b7558..75643ad5 100755 --- a/ramalama.py +++ b/ramalama.py @@ -18,6 +18,9 @@ def main(args): ramalama.usage() while len(args) > 0: + if args[0] == "-h" or args[0] == "--help": + ramalama.usage() + if args[0] == "--dryrun": args.pop(0) dryrun = True diff --git a/ramalama/cli.py b/ramalama/cli.py index 4acda2c4..7cb72c6f 100644 --- a/ramalama/cli.py +++ b/ramalama/cli.py @@ -209,11 +209,12 @@ def push_cli(store, args, port): target = args.pop(0) if model.startswith("oci://"): return oci.push(store, model, target) + if model.startswith("huggingface://"): + return huggingface.push(store, model, target) + if model.startswith("ollama://"): + return ollama.push(store, model, target) - # TODO: Additional repository types can be added here, e.g., Ollama, HuggingFace, etc. - else: - raise NotImplementedError( - f"Unsupported repository type for model: {model}") + raise KeyError(f"Unsupported transport model must have ollama://, oci://, or huggingface:// prefix: {model}") def run_cli(store, args, port): diff --git a/ramalama/huggingface.py b/ramalama/huggingface.py index c372bae5..00f36557 100644 --- a/ramalama/huggingface.py +++ b/ramalama/huggingface.py @@ -30,3 +30,6 @@ def pull(model, ramalama_store): run_cmd(["ln", "-sf", relative_target_path, symlink_path]) return symlink_path + +def push(store, model, target): + raise NotImplementedError("ramalama push not implemented for huggingface transport") diff --git a/ramalama/ollama.py b/ramalama/ollama.py index 1f54cc40..8cb6fa9f 100644 --- a/ramalama/ollama.py +++ b/ramalama/ollama.py @@ -92,3 +92,6 @@ def init_pull(repos, manifests, accept, registry_head, model_name, model_tag, mo symlink_path) return symlink_path + +def push(store, model, target): + raise NotImplementedError("ramalama push not implemented for ollama transport")