|
10 | 10 |
|
11 | 11 | from rich.logging import RichHandler |
12 | 12 |
|
| 13 | +from log import get_logger |
13 | 14 | from configuration import configuration |
| 15 | +from llama_stack_configuration import generate_configuration |
14 | 16 | from runners.uvicorn import start_uvicorn |
15 | 17 |
|
16 | 18 | FORMAT = "%(message)s" |
17 | 19 | logging.basicConfig( |
18 | 20 | level="INFO", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()] |
19 | 21 | ) |
20 | 22 |
|
21 | | -logger = logging.getLogger(__name__) |
| 23 | +logger = get_logger(__name__) |
22 | 24 |
|
23 | 25 |
|
24 | 26 | def create_argument_parser() -> ArgumentParser: |
@@ -47,6 +49,28 @@ def create_argument_parser() -> ArgumentParser: |
47 | 49 | help="path to configuration file (default: lightspeed-stack.yaml)", |
48 | 50 | default="lightspeed-stack.yaml", |
49 | 51 | ) |
| 52 | + parser.add_argument( |
| 53 | + "-g", |
| 54 | + "--generate-llama-stack-configuration", |
| 55 | + dest="generate_llama_stack_configuration", |
| 56 | + help="generate Llama Stack configuration based on LCORE configuration", |
| 57 | + action="store_true", |
| 58 | + default=False, |
| 59 | + ) |
| 60 | + parser.add_argument( |
| 61 | + "-i", |
| 62 | + "--input-config-file", |
| 63 | + dest="input_config_file", |
| 64 | + help="Llama Stack input configuration file", |
| 65 | + default="run.yaml", |
| 66 | + ) |
| 67 | + parser.add_argument( |
| 68 | + "-o", |
| 69 | + "--output-config-file", |
| 70 | + dest="output_config_file", |
| 71 | + help="Llama Stack output configuration file", |
| 72 | + default="run_.yaml", |
| 73 | + ) |
50 | 74 |
|
51 | 75 | return parser |
52 | 76 |
|
@@ -74,6 +98,24 @@ def main() -> None: |
74 | 98 | raise SystemExit(1) from e |
75 | 99 | return |
76 | 100 |
|
| 101 | + # -g or --generate-llama-stack-configuration CLI flags are used to (re)generate |
| 102 | + # configuration for Llama Stack |
| 103 | + if args.generate_llama_stack_configuration: |
| 104 | + try: |
| 105 | + generate_configuration( |
| 106 | + args.input_config_file, |
| 107 | + args.output_config_file, |
| 108 | + configuration.configuration, |
| 109 | + ) |
| 110 | + logger.info( |
| 111 | + "Llama Stack configuration generated and stored into %s", |
| 112 | + args.output_config_file, |
| 113 | + ) |
| 114 | + except Exception as e: |
| 115 | + logger.error("Failed to generate Llama Stack configuration: %s", e) |
| 116 | + raise SystemExit(1) from e |
| 117 | + return |
| 118 | + |
77 | 119 | # Store config path in env so each uvicorn worker can load it |
78 | 120 | # (step is needed because process context isn’t shared). |
79 | 121 | os.environ["LIGHTSPEED_STACK_CONFIG_PATH"] = args.config_file |
|
0 commit comments