|
19 | 19 | from torchx.cli.argparse_util import CONFIG_DIRS, torchxconfig_run
|
20 | 20 | from torchx.cli.cmd_base import SubCommand
|
21 | 21 | from torchx.cli.cmd_log import get_logs
|
22 |
| -from torchx.runner import config, get_runner, Runner |
23 |
| -from torchx.runner.config import load_sections |
| 22 | +from torchx.config import get_config_store |
| 23 | +from torchx.runner import get_runner, Runner |
24 | 24 | from torchx.schedulers import get_default_scheduler_name, get_scheduler_factories
|
25 | 25 | from torchx.specs.finder import (
|
26 | 26 | _Component,
|
@@ -63,7 +63,11 @@ def _parse_component_name_and_args(
|
63 | 63 | looks like an option (e.g. starts with "-")
|
64 | 64 |
|
65 | 65 | """
|
66 |
| - component = config.get_config(prefix="cli", name="run", key="component", dirs=dirs) |
| 66 | + component = get_config_store(dirs).get_key( |
| 67 | + collection="run", key="component", label="cli" |
| 68 | + ) |
| 69 | + |
| 70 | + component = str(component) if component else None |
67 | 71 | component_args = []
|
68 | 72 |
|
69 | 73 | # make a copy of the input list to guard against side-effects
|
@@ -177,7 +181,12 @@ def _run(self, runner: Runner, args: argparse.Namespace) -> None:
|
177 | 181 | run_opts = runner.run_opts()
|
178 | 182 | scheduler_opts = run_opts[args.scheduler]
|
179 | 183 | cfg = scheduler_opts.cfg_from_str(args.scheduler_args)
|
180 |
| - config.apply(scheduler=args.scheduler, cfg=cfg, dirs=CONFIG_DIRS) |
| 184 | + |
| 185 | + type_hints = {x[0]: x[1].opt_type for x in scheduler_opts} |
| 186 | + config_data = get_config_store(CONFIG_DIRS).get( |
| 187 | + args.scheduler, type_hints=type_hints |
| 188 | + ) |
| 189 | + cfg = config_data.apply_to(cfg) |
181 | 190 |
|
182 | 191 | component, component_args = _parse_component_name_and_args(
|
183 | 192 | args.component_name_and_args,
|
@@ -226,18 +235,22 @@ def _run(self, runner: Runner, args: argparse.Namespace) -> None:
|
226 | 235 | logger.error(error_msg)
|
227 | 236 | sys.exit(1)
|
228 | 237 | except specs.InvalidRunConfigException as e:
|
| 238 | + logger.error(e) |
229 | 239 | error_msg = (
|
230 | 240 | f"Scheduler arg is incorrect or missing required option: `{e.cfg_key}`\n"
|
231 | 241 | f"Run `torchx runopts` to check configuration for `{args.scheduler}` scheduler\n"
|
232 | 242 | f"Use `-cfg` to specify run cfg as `key1=value1,key2=value2` pair\n"
|
233 |
| - "of setup `.torchxconfig` file, see: https://pytorch.org/torchx/main/experimental/runner.config.html" |
| 243 | + "of setup `.torchxconfig` file, see: https://pytorch.org/torchx/main/runner.config.html" |
234 | 244 | )
|
235 | 245 | logger.error(error_msg)
|
236 | 246 | sys.exit(1)
|
237 | 247 |
|
238 | 248 | def run(self, args: argparse.Namespace) -> None:
|
239 | 249 | os.environ["TORCHX_CONTEXT_NAME"] = os.getenv("TORCHX_CONTEXT_NAME", "cli_run")
|
240 |
| - component_defaults = load_sections(prefix="component", dirs=CONFIG_DIRS) |
| 250 | + config_data = get_config_store(CONFIG_DIRS).get_all(label="component") |
| 251 | + component_defaults = {} |
| 252 | + for conf in config_data: |
| 253 | + component_defaults[conf.coll_name] = dict(conf) |
241 | 254 | with get_runner(component_defaults=component_defaults) as runner:
|
242 | 255 | self._run(runner, args)
|
243 | 256 |
|
|
0 commit comments