Skip to content

Commit

Permalink
add support for rammalama rm model
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Aug 22, 2024
1 parent 5aec084 commit 4a1f64d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 15 deletions.
16 changes: 16 additions & 0 deletions docs/source/markdown/ramalama-rm.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
% ramalama-rm 1

## NAME
ramalama - Remove specified AI Model from system.

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

## DESCRIPTION
Remove specified AI Model from system

## SEE ALSO
**[ramalama(1)](ramalama.1.md)

## HISTORY
Aug 2024, Originally compiled by Dan Walsh <[email protected]>
16 changes: 8 additions & 8 deletions ramalama.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def main(args):
elif args[0] in ramalama.funcDict:
break
else:
print(f"Error: unrecognized command `{args[0]}`\n")
ramalama.eprint(f"Error: unrecognized command `{args[0]}`\n")
ramalama.usage()

port = "8080"
Expand Down Expand Up @@ -50,16 +50,16 @@ def main(args):
return print(*conman_args)

ramalama.exec_cmd(conman_args)

cmd = args.pop(0)
ramalama.funcDict[cmd](store, args, port)
except IndexError:
ramalama.usage()
except KeyError:
print(cmd + " not valid\n")
ramalama.usage()
except IndexError as e:
ramalama.eprint(str(e).strip("'"))
sys.exit(errno.EINVAL)
except KeyError as e:
ramalama.eprint(str(e).strip("'"))
sys.exit(1)
except NotImplementedError as e:
print(e)
ramalama.eprint(str(e).strip("'"))
sys.exit(errno.ENOTSUP)


Expand Down
11 changes: 11 additions & 0 deletions ramalama/ramalama.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ def pull_cli(store, args, port):
return ollama.pull(model, store)


def rm_cli(store, args, port):
if len(args) < 1:
usage()

model = args.pop(0).replace("://", "/")
model = f"{store}/models/{model}"
exec_cmd(["rm", model])


def run_cli(store, args, port):
if len(args) < 1:
usage()
Expand Down Expand Up @@ -155,6 +164,7 @@ def in_container():
funcDict["ls"] = list_cli
funcDict["pull"] = pull_cli
funcDict["run"] = run_cli
funcDict["rm"] = rm_cli
funcDict["serve"] = serve_cli


Expand All @@ -165,6 +175,7 @@ def usage():
print("Commands:")
print(" list List models")
print(" pull MODEL Pull a model")
print(" rm MODEL Remove a model")
print(" run MODEL Run a model")
print(" serve MODEL Serve a model")
sys.exit(1)
20 changes: 13 additions & 7 deletions test/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ main() {
fi
fi

binfile=ramalama.py
chmod +x ${binfile} install.py

# only for macOS for now, which doesn't have containers
if [ "$os" != "Linux" ]; then
if [ "$os" == "darwin" ]; then
/usr/bin/python3 --version
pip install "huggingface_hub[cli]==0.24.2"
huggingface-cli --help
pip install "omlmd==0.1.2"
omlmd --help
fi

binfile=ramalama.py
chmod +x ${binfile} install.py
if [ "$os" = "Linux" ]; then
./install.py # todo macos support
else
./container_build.sh
autopep8 --in-place --exit-code *.py ramalama/*py # Check style is correct
shellcheck -- *.sh
$maybe_sudo ./install.py # todo macos support
fi

$maybe_sudo ./install.py # todo macos support

set +o pipefail
./${binfile} -h | grep Usage:
Expand All @@ -56,6 +56,12 @@ main() {
./${binfile} list | grep tiny-vicuna-1b
./${binfile} list | grep NAME
./${binfile} list | grep oci://quay.io/mmortari/gguf-py-example/v1/example.gguf
./${binfile} rm ollama://ben1t0/tiny-llm:latest
if ./${binfile} list | grep ben1t0/tiny-llm; then
exit 1
else
exit 0
fi
# ramalama list | grep granite-code
# ramalama rm granite-code
}
Expand Down

0 comments on commit 4a1f64d

Please sign in to comment.