Skip to content

Commit 1b9f406

Browse files
committed
Added casing for inventory verbs
1 parent ff28c1e commit 1b9f406

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

cli.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def add_arguments_for_verb(parser, verb: str) -> None:
4949
# an explicit --checkpoint-dir, --checkpoint-path, or --tokenizer-path.
5050

5151
if verb in INVENTORY_VERBS:
52-
_configure_artifact_inventory_args(parser, verb)
53-
return
52+
_configure_artifact_inventory_args(parser, verb)
53+
_add_cli_metadata_args(parser)
54+
return
5455

5556
parser.add_argument(
5657
"model",
@@ -200,12 +201,6 @@ def add_arguments_for_verb(parser, verb: str) -> None:
200201
choices=allowable_dtype_names(),
201202
help="Override the dtype of the model (default is the checkpoint dtype). Options: bf16, fp16, fp32, fast16, fast",
202203
)
203-
parser.add_argument(
204-
"-v",
205-
"--verbose",
206-
action="store_true",
207-
help="Verbose output",
208-
)
209204
parser.add_argument(
210205
"--quantize",
211206
type=str,
@@ -261,7 +256,17 @@ def add_arguments_for_verb(parser, verb: str) -> None:
261256
default=5000,
262257
help="Port for the web server in browser mode",
263258
)
259+
_add_cli_metadata_args(parser)
260+
264261

262+
# Add CLI Args that are relevant to any subcommand execution
263+
def _add_cli_metadata_args(parser) -> None:
264+
parser.add_argument(
265+
"-v",
266+
"--verbose",
267+
action="store_true",
268+
help="Verbose output",
269+
)
265270

266271
# Configure CLI Args specific to Model Artifact Management
267272
def _configure_artifact_inventory_args(parser, verb: str) -> None:
@@ -314,6 +319,7 @@ def _add_evaluation_args(parser) -> None:
314319
)
315320

316321

322+
# TODO: Refactor arg_init to be more modular
317323
def arg_init(args):
318324
if not (torch.__version__ > "2.3"):
319325
raise RuntimeError(
@@ -323,6 +329,11 @@ def arg_init(args):
323329
if sys.version_info.major != 3 or sys.version_info.minor < 10:
324330
raise RuntimeError("Please use Python 3.10 or later.")
325331

332+
# TODO: Don't initialize for Inventory management subcommands
333+
# Remove when arg_init is refactored
334+
if args.command in INVENTORY_VERBS:
335+
return args
336+
326337
if hasattr(args, "quantize") and Path(args.quantize).is_file():
327338
with open(args.quantize, "r") as f:
328339
args.quantize = json.loads(f.read())

download.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,6 @@ def is_model_downloaded(model: str, models_dir: Path) -> bool:
125125

126126
# Subcommand to list available models.
127127
def list_main(args) -> None:
128-
# TODO It would be nice to have argparse validate this. However, we have
129-
# model as an optional named parameter for all subcommands, so we'd
130-
# probably need to move it to be registered per-command.
131-
if args.model:
132-
print("Usage: torchchat.py list")
133-
return
134-
135128
model_configs = load_model_configs()
136129

137130
# Build the table in-memory so that we can align the text nicely.

0 commit comments

Comments
 (0)