Skip to content

Commit

Permalink
Add version command
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 26, 2024
1 parent 7379d46 commit 785713a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 3 deletions.
16 changes: 16 additions & 0 deletions docs/ramalama-version.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
% ramalama-version 1

## NAME
ramalama - Print version of ramalama

## SYNOPSIS
**ramalama version**

## DESCRIPTION
Print version of ramalama

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

## HISTORY
Aug 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 @@ -41,6 +41,7 @@ Individual model transports can be modifies when specifying a model via the `hug
| [ramalama-push(1)](ramalama-push.1.md) | Push specified AI Model (OCI-only at present) |
| [ramalama-run(1)](ramalama-run.1.md) | Run a chatbot on AI Model. |
| [ramalama-serve(1)](ramalama-serve.1.md)| Serve local AI Model as an API Service. |
| [ramalama-version(1)](ramalama-version.1.md)| Print ramalama version |

## CONFIGURATION FILES

Expand Down
5 changes: 4 additions & 1 deletion ramalama.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def main(args):

while len(args) > 0:
if args[0] == "-h" or args[0] == "--help":
ramalama.usage()
return ramalama.usage()

if args[0] == "-v" or args[0] == "version":
return ramalama.version()

if args[0] == "--dryrun":
args.pop(0)
Expand Down
4 changes: 2 additions & 2 deletions ramalama/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from ramalama.common import container_manager, exec_cmd, perror
from ramalama.cli import create_store, funcDict, usage
from ramalama.version import __version__
from ramalama.version import version
import subprocess
import sys
import os
Expand All @@ -12,4 +12,4 @@


__all__ = ['container_manager', 'create_store', 'perror',
'funcDict', 'usage', '__version__', 'exec_cmd']
'funcDict', 'usage', 'exec_cmd', 'version']
10 changes: 10 additions & 0 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ramalama.huggingface import Huggingface
from ramalama.oci import OCI
from ramalama.ollama import Ollama
from ramalama.version import version


def usage(exit=0):
Expand All @@ -27,6 +28,7 @@ def usage(exit=0):
print(" push MODEL TARGET Push a model to target")
print(" run MODEL Run a model")
print(" serve MODEL Serve a model")
print(" version Version of ramalama")
sys.exit(exit)


Expand Down Expand Up @@ -234,6 +236,13 @@ def serve_cli(store, args, port):
model.serve(store, args)


def version_cli():
if len(args) > 1:
usage(1)

version()


def get_store():
if os.geteuid() == 0:
return "/var/lib/ramalama"
Expand All @@ -256,6 +265,7 @@ def create_store():
funcDict["push"] = push_cli
funcDict["run"] = run_cli
funcDict["serve"] = serve_cli
funcDict["version"] = version_cli


def New(model):
Expand Down
4 changes: 4 additions & 0 deletions ramalama/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""Version of RamalamaPy."""

__version__ = "0.1.0"


def version():
print("ramalama version " + __version__)
1 change: 1 addition & 0 deletions test/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ main() {
./${binfile} -h | grep Usage:
set -o pipefail

./${binfile} version
./${binfile} pull ollama://tinyllama
RAMALAMA_TRANSPORT=ollama ./${binfile} pull ben1t0/tiny-llm
./${binfile} pull ollama://tinyllama:1.1b
Expand Down

0 comments on commit 785713a

Please sign in to comment.