Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failover to OCI when push fails with default push mechanism #476

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
perror,
run_cmd,
)
from ramalama.model import model_types
from ramalama.oci import OCI
from ramalama.ollama import Ollama
from ramalama.shortnames import Shortnames
Expand Down Expand Up @@ -584,8 +585,19 @@ def push_cli(args):
if not tgt:
tgt = target

model = New(tgt, args)
model.push(source, args)
try:
model = New(tgt, args)
model.push(source, args)
except KeyError as e:
for mtype in model_types:
if model.startswith(mtype + "://"):
raise e
try:
# attempt to push as a container image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider adding logging or user feedback when falling back to container image handling for better debugging experience.

Suggested change
# attempt to push as a container image
logger.info("Falling back to container image handling for model push")
# attempt to push as a container image

m = OCI(model, config.get('engine', container_manager()))
m.push(args)
except Exception:
raise e


def run_parser(subparsers):
Expand Down
1 change: 0 additions & 1 deletion ramalama/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def remove(self, args):

self.garbage_collection(args)


def _image(self, args):
if args.image != default_image():
return args.image
Expand Down
Loading