forked from phoenix-oss/llama-stack-mirror
# What does this PR do? It is important to verify large checkpoints downloaded via `llama model download` because subtle corruptions can easily happen with large file system writes. This PR adds a `verify-download` subcommand. Note that verification itself is a very time consuming process (and will take several **minutes** for the 405B model), hence this is a separate subcommand (and not part of the download which can already be time-consuming) and there are spinners and a bit of a "show" around it in the implementation. ## Test Plan <img width="1012" alt="image" src="https://github.com/user-attachments/assets/f82b0d42-2a15-4917-b85e-6d3cd7d31e55">
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
|
|
import argparse
|
|
|
|
from .download import Download
|
|
from .model import ModelParser
|
|
from .stack import StackParser
|
|
from .verify_download import VerifyDownload
|
|
|
|
|
|
class LlamaCLIParser:
|
|
"""Defines CLI parser for Llama CLI"""
|
|
|
|
def __init__(self):
|
|
self.parser = argparse.ArgumentParser(
|
|
prog="llama",
|
|
description="Welcome to the Llama CLI",
|
|
add_help=True,
|
|
)
|
|
|
|
# Default command is to print help
|
|
self.parser.set_defaults(func=lambda args: self.parser.print_help())
|
|
|
|
subparsers = self.parser.add_subparsers(title="subcommands")
|
|
|
|
# Add sub-commands
|
|
ModelParser.create(subparsers)
|
|
StackParser.create(subparsers)
|
|
Download.create(subparsers)
|
|
VerifyDownload.create(subparsers)
|
|
|
|
def parse_args(self) -> argparse.Namespace:
|
|
return self.parser.parse_args()
|
|
|
|
def run(self, args: argparse.Namespace) -> None:
|
|
args.func(args)
|
|
|
|
|
|
def main():
|
|
parser = LlamaCLIParser()
|
|
args = parser.parse_args()
|
|
parser.run(args)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|