Skip to content

Commit

Permalink
Merge pull request #324 from containers/hf-abbrev
Browse files Browse the repository at this point in the history
Add hf:// as an alias to huggingface://
  • Loading branch information
rhatdan authored Oct 18, 2024
2 parents 2601763 + 25335fc commit 07a53c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
10 changes: 5 additions & 5 deletions ramalama/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def login_parser(subparsers):
def login_cli(args):
transport = args.TRANSPORT
if transport != "":
transport = os.getenv("RAMALAMA_TRANSPORT")
transport = os.getenv("RAMALAMA_TRANSPORT") + "://"
model = New(str(transport))
return model.login(args)

Expand All @@ -182,7 +182,7 @@ def logout_parser(subparsers):
def logout_cli(args):
transport = args.TRANSPORT
if transport != "":
transport = os.getenv("RAMALAMA_TRANSPORT")
transport = os.getenv("RAMALAMA_TRANSPORT") + "://"
model = New(str(transport))
return model.logout(args)

Expand Down Expand Up @@ -652,11 +652,11 @@ def dry_run(args):


def New(model):
if model.startswith("huggingface"):
if model.startswith("huggingface://") or model.startswith("hf://"):
return Huggingface(model)
if model.startswith("ollama"):
if model.startswith("ollama://"):
return Ollama(model)
if model.startswith("oci") | model.startswith("docker"):
if model.startswith("oci://") or model.startswith("docker://"):
return OCI(model)

transport = os.getenv("RAMALAMA_TRANSPORT")
Expand Down
4 changes: 3 additions & 1 deletion ramalama/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

class Huggingface(Model):
def __init__(self, model):
super().__init__(model.removeprefix("huggingface://"))
model = model.removeprefix("huggingface://")
model = model.removeprefix("hf://")
super().__init__(model)
self.type = "HuggingFace"
split = self.model.rsplit("/", 1)
self.directory = ""
Expand Down
5 changes: 5 additions & 0 deletions test/system/050-pull.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ load helpers

# bats test_tags=distro-integration
@test "ramalama pull huggingface" {
run_ramalama pull hf://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf
run_ramalama list
is "$output" ".*afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k" "image was actually pulled locally"
run_ramalama rm hf://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf

run_ramalama pull huggingface://afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k.gguf
run_ramalama list
is "$output" ".*afrideva/Tiny-Vicuna-1B-GGUF/tiny-vicuna-1b.q2_k" "image was actually pulled locally"
Expand Down

0 comments on commit 07a53c4

Please sign in to comment.