Skip to content

Commit a0dec73

Browse files
authored
Merge pull request #677 from NVIDIA/am/click-cli
Re-work CLI implementation to use Click
2 parents 9b617e6 + 3863dce commit a0dec73

File tree

6 files changed

+293
-529
lines changed

6 files changed

+293
-529
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ dependencies = [
2727
"jinja2==3.1.6",
2828
"websockets==15.0.1",
2929
"rich==14.0.0",
30+
"click>=8.2.1",
3031
]
3132
requires-python = ">=3.10"
32-
scripts = { cloudai = "cloudai.__main__:main" }
33+
scripts = { cloudai = "cloudai.cli:main" }
3334

3435
[project.optional-dependencies]
3536
dev = [

src/cloudai/__main__.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/cloudai/cli/__init__.py

Lines changed: 3 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES
2-
# Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
33
# SPDX-License-Identifier: Apache-2.0
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,62 +14,9 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
import logging
18-
import logging.config
19-
20-
from .cli import CloudAICLI
21-
from .handlers import handle_dry_run_and_run, handle_generate_report, handle_install_and_uninstall
22-
23-
24-
def setup_logging(log_file: str, log_level: str) -> None:
25-
"""
26-
Configure logging for the application.
27-
28-
Args:
29-
log_level (str): The logging level (e.g., DEBUG, INFO).
30-
log_file (str): The name of the log file.
31-
"""
32-
numeric_level = getattr(logging, log_level.upper(), None)
33-
if not isinstance(numeric_level, int):
34-
raise ValueError(f"Invalid log level: {log_level}")
35-
36-
LOGGING_CONFIG = {
37-
"version": 1,
38-
"disable_existing_loggers": True,
39-
"formatters": {
40-
"standard": {"format": "%(asctime)s - %(levelname)s - %(message)s"},
41-
"short": {"format": "[%(levelname)s] %(message)s"},
42-
},
43-
"handlers": {
44-
"default": {
45-
"level": log_level.upper(),
46-
"formatter": "short",
47-
"class": "logging.StreamHandler",
48-
"stream": "ext://sys.stdout",
49-
},
50-
"debug_file": {
51-
"level": "DEBUG",
52-
"formatter": "standard",
53-
"class": "logging.FileHandler",
54-
"filename": log_file,
55-
"mode": "w",
56-
},
57-
},
58-
"loggers": {
59-
"": {
60-
"handlers": ["default", "debug_file"],
61-
"level": "DEBUG",
62-
"propagate": False,
63-
},
64-
},
65-
}
66-
logging.config.dictConfig(LOGGING_CONFIG)
67-
17+
from .cli import main, setup_logging
6818

6919
__all__ = [
70-
"CloudAICLI",
71-
"handle_dry_run_and_run",
72-
"handle_generate_report",
73-
"handle_install_and_uninstall",
20+
"main",
7421
"setup_logging",
7522
]

0 commit comments

Comments
 (0)