AnonymousSpottedToad/securityPatternsRecovery / codebase /repos /python /autonomi-ai_nos /nos /cli /hub.py
| from pathlib import Path | |
| import typer | |
| from rich import print | |
| from rich.tree import Tree | |
| from nos import hub | |
| from nos.common.spec import ModelSpec | |
| from nos.constants import NOS_MODELS_DIR | |
| hub_cli = typer.Typer(name="hub", help="NOS Hub CLI.", no_args_is_help=True) | |
| DEFAULT_MODEL_CACHE_DIR = NOS_MODELS_DIR | |
| def _list_models(private: bool = typer.Option(False, "-p", "--private", help="List private models.")) -> None: | |
| tree = Tree("[bold white]Models[/bold white]") | |
| for model in hub.list(private=private): | |
| spec: ModelSpec = hub.load_spec(model) | |
| tree.add(f"[green]{str(model)}[/green]").add(str(spec)) | |
| print(tree) | |
| def _download_hf_model( | |
| model_name: str = typer.Option(..., "-m", "--model-name", help="Huggingface model name."), | |
| token: str = typer.Option("", "-t", "--token", help="HF access token"), | |
| output_directory: str = typer.Option( | |
| DEFAULT_MODEL_CACHE_DIR, | |
| "-d", | |
| "--output-directory", | |
| help="Download huggingface models locally.", | |
| ), | |
| ) -> None: | |
| from nos import hub | |
| output_directory = Path(output_directory) / model_name | |
| output_directory.mkdir(parents=True, exist_ok=True) | |
| # Downloads the model from the hub and loads it (also caches). | |
| hub.load(model_name) | |
| # TODO (spillai): Save model to output_directory | |
| # model.save_pretrained(output_directory) | |
Xet Storage Details
- Size:
- 1.42 kB
- Xet hash:
- 380fd7eede35bee70b81108103dcfb8dd93f21b8a3334193e6a003508229e53a
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.