Debug a workflow implementation.
(
config: Annotated[
str,
typer.Option("--config", "-c", help="Path to the config file."),
],
module: Annotated[
str,
typer.Option(
"--module",
"-m",
help="The module to debug: 'inference_model', 'workflow', or 'viewer'.",
),
],
plugin_dir: Annotated[
Optional[str],
typer.Option("--plugin-dir", help="Path to the directory containing plugin modules."),
] = None,
output_dir: Annotated[
str,
typer.Option("--output-dir", "-o", help="The output directory for debug files."),
] = "debug_output",
disable_overwrite: Annotated[
bool,
typer.Option("--disable-overwrite", help="Disable overwriting the output directory."),
] = False,
enable_profiling: Annotated[
bool,
typer.Option("--enable-profiling", help="Whether to use viztracer for workflow profiling."),
] = False,
port: Annotated[
int,
typer.Option("--port", "-p", help="The port for Experience Viewer."),
] = 8502,
)
| 58 | |
| 59 | |
| 60 | def debug( |
| 61 | config: Annotated[ |
| 62 | str, |
| 63 | typer.Option("--config", "-c", help="Path to the config file."), |
| 64 | ], |
| 65 | module: Annotated[ |
| 66 | str, |
| 67 | typer.Option( |
| 68 | "--module", |
| 69 | "-m", |
| 70 | help="The module to debug: 'inference_model', 'workflow', or 'viewer'.", |
| 71 | ), |
| 72 | ], |
| 73 | plugin_dir: Annotated[ |
| 74 | Optional[str], |
| 75 | typer.Option("--plugin-dir", help="Path to the directory containing plugin modules."), |
| 76 | ] = None, |
| 77 | output_dir: Annotated[ |
| 78 | str, |
| 79 | typer.Option("--output-dir", "-o", help="The output directory for debug files."), |
| 80 | ] = "debug_output", |
| 81 | disable_overwrite: Annotated[ |
| 82 | bool, |
| 83 | typer.Option("--disable-overwrite", help="Disable overwriting the output directory."), |
| 84 | ] = False, |
| 85 | enable_profiling: Annotated[ |
| 86 | bool, |
| 87 | typer.Option("--enable-profiling", help="Whether to use viztracer for workflow profiling."), |
| 88 | ] = False, |
| 89 | port: Annotated[ |
| 90 | int, |
| 91 | typer.Option("--port", "-p", help="The port for Experience Viewer."), |
| 92 | ] = 8502, |
| 93 | ) -> None: |
| 94 | """Debug a workflow implementation.""" |
| 95 | valid_modules = ("inference_model", "workflow", "viewer") |
| 96 | if module not in valid_modules: |
| 97 | raise typer.BadParameter(f"Only support {valid_modules} for debugging, got '{module}'") |
| 98 | |
| 99 | if plugin_dir: |
| 100 | os.environ[PLUGIN_DIRS_ENV_VAR] = plugin_dir |
| 101 | load_plugins() |
| 102 | cfg = load_config(config) |
| 103 | cfg.mode = "explore" |
| 104 | cfg.ray_namespace = DEBUG_NAMESPACE |
| 105 | cfg.explorer.rollout_model.engine_num = 1 |
| 106 | for auxiliary_model_config in cfg.explorer.auxiliary_models: |
| 107 | auxiliary_model_config.engine_num = 1 |
| 108 | cfg.check_and_update() |
| 109 | sys.path.insert(0, os.getcwd()) |
| 110 | ray.init( |
| 111 | namespace=cfg.ray_namespace, |
| 112 | runtime_env={"env_vars": cfg.get_envs()}, |
| 113 | ignore_reinit_error=True, |
| 114 | ) |
| 115 | |
| 116 | if module == "inference_model": |
| 117 | asyncio.run(create_debug_models(cfg)) |
nothing calls this directly
no test coverage detected