Skip to content

Commit b6c0b73

Browse files
authored
Merge pull request #2263 from tisnik/lcore-3141-models-group-schema-export
LCORE-3141: models group schema export ability
2 parents 07be965 + 516dfb9 commit b6c0b73

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,8 @@ options:
860860
dump actual configuration into JSON file and quit
861861
-s, --dump-schema dump configuration schema into OpenAPI-compatible file and quit
862862
-m, --dump-models dump schemas for all models into OpenAPI-compatible file and quit
863+
-gr, --dump-models-group DUMP_MODELS_GROUP
864+
dump schemas for selected models group into OpenAPI-compatible file and quit
863865
-c, --config CONFIG_FILE
864866
path to configuration file (default: lightspeed-stack.yaml)
865867
--synthesized-config-output SYNTHESIZED_CONFIG_OUTPUT

src/lightspeed_stack.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def create_argument_parser() -> ArgumentParser:
2727
- -v / --verbose: enable verbose output
2828
- -d / --dump-configuration: dump the loaded configuration to JSON and exit
2929
- -s / --dump-schema: dump the configuration schema to OpenAPI JSON and exit
30+
- -m / --dump-models: dump schemas for all models into OpenAPI-compatible file and quit
31+
- -gr / --dump-models-group DUMP_MODELS_GROUP
32+
dump schemas for selected models group into OpenAPI-compatible file and quit
3033
- -c / --config: path to the configuration file (default "lightspeed-stack.yaml")
3134
- -g / --generate-llama-stack-configuration: generate a Llama Stack
3235
configuration from the service configuration
@@ -69,6 +72,14 @@ def create_argument_parser() -> ArgumentParser:
6972
action="store_true",
7073
default=False,
7174
)
75+
parser.add_argument(
76+
"-gr",
77+
"--dump-models-group",
78+
dest="dump_models_group",
79+
help="dump schemas for selected models group into OpenAPI-compatible file and quit",
80+
action="store",
81+
default=None,
82+
)
7283
parser.add_argument(
7384
"-c",
7485
"--config",
@@ -213,6 +224,18 @@ def main() -> None:
213224
raise SystemExit(1) from e
214225
return
215226

227+
# -gr or --dump-models-group CLI parameter is used to dump schema for
228+
# selected models into a JSON file that is compatible with OpenAPI schema
229+
# specification
230+
if args.dump_models_group is not None:
231+
try:
232+
models_dumper.dump_models_group(args.dump_models_group)
233+
logger.info("Schema for group %s of models dumped", args.dump_models_group)
234+
except Exception as e:
235+
logger.error("Failed to dump schema for models: %s", e)
236+
raise SystemExit(1) from e
237+
return
238+
216239
# Store config path in env so each uvicorn worker can load it
217240
# (step is needed because process context isn't shared).
218241
os.environ[constants.CONFIG_PATH_ENV_VAR] = args.config_file

0 commit comments

Comments
 (0)