-
Notifications
You must be signed in to change notification settings - Fork 717
FIX: CLI fixes and minor updates #1559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,7 +33,7 @@ class PyRITShell(cmd.Cmd): | |||||||||||||||||||||||||||||||||||||||||||
| Commands: | ||||||||||||||||||||||||||||||||||||||||||||
| list-scenarios - List all available scenarios | ||||||||||||||||||||||||||||||||||||||||||||
| list-initializers - List all available initializers | ||||||||||||||||||||||||||||||||||||||||||||
| list-targets - List all available targets from the registry | ||||||||||||||||||||||||||||||||||||||||||||
| list-targets [opts] - List all available targets from the registry | ||||||||||||||||||||||||||||||||||||||||||||
| run <scenario> [opts] - Run a scenario with optional parameters | ||||||||||||||||||||||||||||||||||||||||||||
| scenario-history - List all previous scenario runs | ||||||||||||||||||||||||||||||||||||||||||||
| print-scenario [N] - Print detailed results for scenario run(s) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -189,6 +189,9 @@ def cmdloop(self, intro: Optional[str] = None) -> None: | |||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| def do_list_scenarios(self, arg: str) -> None: | ||||||||||||||||||||||||||||||||||||||||||||
| """List all available scenarios.""" | ||||||||||||||||||||||||||||||||||||||||||||
| if arg.strip(): | ||||||||||||||||||||||||||||||||||||||||||||
| print(f"Error: list-scenarios does not accept arguments, got: {arg.strip()}") | ||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||
| self._ensure_initialized() | ||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||
| asyncio.run(self._fc.print_scenarios_list_async(context=self.context)) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -197,17 +200,59 @@ def do_list_scenarios(self, arg: str) -> None: | |||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| def do_list_initializers(self, arg: str) -> None: | ||||||||||||||||||||||||||||||||||||||||||||
| """List all available initializers.""" | ||||||||||||||||||||||||||||||||||||||||||||
| if arg.strip(): | ||||||||||||||||||||||||||||||||||||||||||||
| print(f"Error: list-initializers does not accept arguments, got: {arg.strip()}") | ||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||
| self._ensure_initialized() | ||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||
| asyncio.run(self._fc.print_initializers_list_async(context=self.context)) | ||||||||||||||||||||||||||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||||||||||||||||||||||||||
| print(f"Error listing initializers: {e}") | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| def do_list_targets(self, arg: str) -> None: | ||||||||||||||||||||||||||||||||||||||||||||
| """List all available targets from the TargetRegistry.""" | ||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||
| List all available targets from the TargetRegistry. | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| Usage: | ||||||||||||||||||||||||||||||||||||||||||||
| list-targets | ||||||||||||||||||||||||||||||||||||||||||||
| list-targets --initializers <name> [<name> ...] | ||||||||||||||||||||||||||||||||||||||||||||
| list-targets --initialization-scripts <path> [<path> ...] | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| Options: | ||||||||||||||||||||||||||||||||||||||||||||
| --initializers <name> ... Built-in initializers to run first | ||||||||||||||||||||||||||||||||||||||||||||
| --initialization-scripts <...> Custom Python scripts to run first | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| Examples: | ||||||||||||||||||||||||||||||||||||||||||||
| list-targets --initializers target | ||||||||||||||||||||||||||||||||||||||||||||
| list-targets --initializers target:tags=default,scorer | ||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||
| self._ensure_initialized() | ||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||
| asyncio.run(self._fc.print_targets_list_async(context=self.context)) | ||||||||||||||||||||||||||||||||||||||||||||
| context_to_use = self.context | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if arg.strip(): | ||||||||||||||||||||||||||||||||||||||||||||
| args = self._fc.parse_list_targets_arguments(args_string=arg) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| resolved_scripts = None | ||||||||||||||||||||||||||||||||||||||||||||
| if args["initialization_scripts"]: | ||||||||||||||||||||||||||||||||||||||||||||
| resolved_scripts = self._fc.resolve_initialization_scripts( | ||||||||||||||||||||||||||||||||||||||||||||
| script_paths=args["initialization_scripts"] | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| context_to_use = self._fc.FrontendCore( | ||||||||||||||||||||||||||||||||||||||||||||
| initialization_scripts=resolved_scripts, | ||||||||||||||||||||||||||||||||||||||||||||
| initializer_names=args["initializers"], | ||||||||||||||||||||||||||||||||||||||||||||
| log_level=self.default_log_level, | ||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||
| context_to_use._scenario_registry = self.context._scenario_registry | ||||||||||||||||||||||||||||||||||||||||||||
| context_to_use._initializer_registry = self.context._initializer_registry | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+242
to
+248
|
||||||||||||||||||||||||||||||||||||||||||||
| context_to_use = self._fc.FrontendCore( | |
| initialization_scripts=resolved_scripts, | |
| initializer_names=args["initializers"], | |
| log_level=self.default_log_level, | |
| ) | |
| context_to_use._scenario_registry = self.context._scenario_registry | |
| context_to_use._initializer_registry = self.context._initializer_registry | |
| frontend_core_kwargs: dict[str, Any] = { | |
| "initialization_scripts": resolved_scripts, | |
| "initializer_names": args["initializers"], | |
| "log_level": self.default_log_level, | |
| } | |
| for attribute_name in ("config_file", "database", "env_files"): | |
| attribute_value = getattr(self.context, attribute_name, None) | |
| if attribute_value is not None: | |
| frontend_core_kwargs[attribute_name] = attribute_value | |
| context_to_use = self._fc.FrontendCore(**frontend_core_kwargs) | |
| context_to_use._scenario_registry = self.context._scenario_registry | |
| context_to_use._initializer_registry = self.context._initializer_registry | |
| context_to_use._silent_reinit = getattr(self.context, "_silent_reinit", False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment now says initializers are needed to populate the target registry, but
--initialization-scriptsare also supported in this code path. Updating the comment will avoid misleading future maintainers about the accepted inputs for--list-targets.