Skip to content

Commit

Permalink
Allow the removal of one then one models via rm command
Browse files Browse the repository at this point in the history
Fixes: #339

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Oct 21, 2024
1 parent 529d655 commit c6e2090
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions docs/ramalama-rm.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
ramalama\-rm - remove AI Models from local storage

## SYNOPSIS
**ramalama rm** [*options*] *model*
**ramalama rm** [*options*] *model* [...]

## DESCRIPTION
remove AI Model from local storage
Specity one or more AI Models to be removed from local storage

## OPTIONS

Expand Down
18 changes: 9 additions & 9 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,26 +503,26 @@ def rm_parser(subparsers):
parser = subparsers.add_parser("rm", help="remove AI Model from local storage")
parser.add_argument("-a", "--all", action="store_true", help="remove all local Models")
parser.add_argument("--ignore", action="store_true", help="ignore errors when specified Model does not exist")
parser.add_argument("MODEL", nargs="?")
parser.add_argument("MODELS", nargs="*")
parser.set_defaults(func=rm_cli)


def _rm_model(model, args):
model = New(model)
model.remove(args)
def _rm_model(models, args):
for model in models:
model = New(model)
model.remove(args)


def rm_cli(args):
if not args.all:
return _rm_model(args.MODEL, args)
return _rm_model(args.MODELS, args)

if args.MODEL == "":
if len(args.MODELS) > 0:
raise IndexError("can not specify --all as well MODEL")

args.noheading = True
for model in _list_models(args):
_rm_model(model["name"], args)

models = [k['name'] for k in _list_models(args) ]
_rm_model(models, args)

def get_store():
if os.geteuid() == 0:
Expand Down
3 changes: 1 addition & 2 deletions test/system/050-pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ load helpers
run_ramalama pull ollama://tinyllama:1.1b
run_ramalama list
is "$output" ".*ollama://tinyllama:1.1b" "image was actually pulled locally"
run_ramalama rm ollama://tinyllama
run_ramalama rm ollama://tinyllama:1.1b
run_ramalama rm ollama://tinyllama ollama://tinyllama:1.1b
}

# bats test_tags=distro-integration
Expand Down

0 comments on commit c6e2090

Please sign in to comment.