Skip to content

Commit

Permalink
Merge pull request #316 from rhatdan/docker
Browse files Browse the repository at this point in the history
Add ramalama info command
  • Loading branch information
ericcurtin authored Oct 16, 2024
2 parents 54b8ec8 + 65a6c3a commit 60c37b4
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ curl -fsSL https://raw.githubusercontent.com/containers/ramalama/s/install.sh |
| ------------------------------------------------------ | ---------------------------------------------------------- |
| [ramalama(1)](docs/ramalama.1.md) | primary RamaLama man page |
| [ramalama-containers(1)](docs/ramalama-containers.1.md)| list all RamaLama containers |
| [ramalama-info(1)](ramalama-info.1.md) | display RamaLama configuration information |
| [ramalama-list(1)](docs/ramalama-list.1.md) | list all downloaded AI Models |
| [ramalama-login(1)](docs/ramalama-login.1.md) | login to remote registry |
| [ramalama-logout(1)](docs/ramalama-logout.1.md) | logout from remote registry |
Expand Down
36 changes: 36 additions & 0 deletions docs/ramalama-info.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
% ramalama-info 1

## NAME
ramalama\-info - Display RamaLama configuration information


## SYNOPSIS
**ramalama info** [*options*]

## DESCRIPTION
Display configuration information in a json format.

## OPTIONS

#### **--help**, **-h**
show this help message and exit

## EXAMPLE

Info all Models downloaded to users homedir
```
$ ramalama info
{
"Engine": "podman",
"Image": "quay.io/ramalama/ramalama:latest",
"Runtime": "llama.cpp",
"Store": "/home/dwalsh/.local/share/ramalama",
"Version": "0.0.18"
}
```

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

## HISTORY
Oct 2024, Originally compiled by Dan Walsh <[email protected]>
1 change: 1 addition & 0 deletions docs/ramalama.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ store AI Models in the specified directory (default rootless: `$HOME/.local/shar
| Command | Description |
| ------------------------------------------------- | ---------------------------------------------------------- |
| [ramalama-containers(1)](ramalama-containers.1.md)| list all RamaLama containers |
| [ramalama-info(1)](ramalama-info.1.md) | Display RamaLama configuration information |
| [ramalama-list(1)](ramalama-list.1.md) | list all downloaded AI Models |
| [ramalama-login(1)](ramalama-login.1.md) | login to remote registry |
| [ramalama-logout(1)](ramalama-logout.1.md) | logout from remote registry |
Expand Down
19 changes: 17 additions & 2 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def use_container():

if sys.platform == "darwin":
conman = container_manager()
krunkit_configured = ai_support_in_vm(conman)
return krunkit_configured
return ai_support_in_vm(conman)

return True

Expand Down Expand Up @@ -151,6 +150,7 @@ def init_cli():

help_parser(subparsers)
containers_parser(subparsers)
info_parser(subparsers)
list_parser(subparsers)
login_parser(subparsers)
logout_parser(subparsers)
Expand Down Expand Up @@ -309,6 +309,11 @@ def list_containers(args):
print("\n".join(_list_containers(args)))


def info_parser(subparsers):
parser = subparsers.add_parser("info", help="Display information pertaining to setup of RamaLama.")
parser.add_argument("--container", default=False, action="store_false", help=argparse.SUPPRESS)
parser.set_defaults(func=info_cli)

def list_parser(subparsers):
parser = subparsers.add_parser("list", aliases=["ls"], help="list all downloaded AI Models")
parser.add_argument("-n", "--noheading", dest="noheading", action="store_true", help="do not display heading")
Expand Down Expand Up @@ -352,6 +357,16 @@ def _list_models(args):
return models


def info_cli(args):
info = {
"Engine": args.engine,
"Image": args.image,
"Runtime": args.runtime,
"Store": args.store,
"Version": version(),
}
print(json.dumps(info, sort_keys=True, indent=4))

def list_cli(args):
models = _list_models(args)

Expand Down
2 changes: 1 addition & 1 deletion test/system/010-list.bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ load helpers
}

@test "ramalama list - json" {
#FIXME don't know why this blows upon macs
#FIXME jq version on mac does not like regex handling
skip_if_darwin
# 'created': ramalama includes fractional seconds, ramalama-remote does not
tests="
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 @@ -2,7 +2,7 @@

load helpers

verify_begin="podman run --rm -i --label RAMALAMA --security-opt=label=disable -e RAMALAMA_TRANSPORT --name"
verify_begin=".*run --rm -i --label RAMALAMA --security-opt=label=disable -e RAMALAMA_TRANSPORT --name"

@test "ramalama --dryrun serve basic output" {
skip_if_nocontainer
Expand Down
56 changes: 56 additions & 0 deletions test/system/060-info.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bats

load helpers

# bats test_tags=distro-integration
@test "ramalama info" {
#FIXME jq version on mac does not like regex handling
skip_if_darwin
run_ramalama 2 info bogus
is "$output" ".*ramalama: error: unrecognized arguments: bogus"

run_ramalama -v
version=$(cut -f3 -d " " <<<"$output")

run_ramalama info

# FIXME Engine (podman|docker|'')
tests="
Image | "quay.io/ramalama/ramalama:latest"
Runtime | "llama.cpp"
Version | "${version}"
Store | "${HOME}/.local/share/ramalama"
"

defer-assertion-failures

while read field expect; do
actual=$(echo "$output" | jq -r ".$field")
dprint "# actual=<$actual> expect=<$expect>"
is "$actual" "$expect" "jq .$field"
done < <(parse_table "$tests")

image=i_$(safename)
runtime=vllm
engine=e_$(safename)
store=s_$(safename)

run_ramalama --store $store --runtime $runtime --engine $engine --image $image info
tests="
Engine | $engine
Image | $image
Runtime | $runtime
Store | $store
"

defer-assertion-failures

while read field expect; do
actual=$(echo "$output" | jq -r ".$field")
dprint "# actual=<$actual> expect=<$expect>"
is "$actual" "$expect" "jq .$field"
done < <(parse_table "$tests")

}

# vim: filetype=sh

0 comments on commit 60c37b4

Please sign in to comment.