in torchx/cli/cmd_run.py [0:0]
def _run(self, runner: Runner, args: argparse.Namespace) -> None:
if args.scheduler == "local":
logger.warning(
"`local` scheduler is deprecated and will be"
" removed in the near future,"
" please use other variants of the local scheduler"
" (e.g. `local_cwd`)"
)
run_opts = runner.run_opts()
scheduler_opts = run_opts[args.scheduler]
cfg = _parse_run_config(args.scheduler_args, scheduler_opts)
config.apply(scheduler=args.scheduler, cfg=cfg)
config_files = config.find_configs()
workspace = (
"file://" + os.path.dirname(config_files[0]) if config_files else None
)
component, component_args = _parse_component_name_and_args(
args.component_name_and_args,
none_throws(self._subparser),
)
try:
if args.dryrun:
if isinstance(runner, WorkspaceRunner):
dryrun_info = runner.dryrun_component(
component,
component_args,
args.scheduler,
workspace=workspace,
cfg=cfg,
)
else:
dryrun_info = runner.dryrun_component(
component, component_args, args.scheduler, cfg=cfg
)
logger.info(
"\n=== APPLICATION ===\n"
f"{pformat(asdict(dryrun_info._app), indent=2, width=80)}"
)
logger.info("\n=== SCHEDULER REQUEST ===\n" f"{dryrun_info}")
else:
if isinstance(runner, WorkspaceRunner):
app_handle = runner.run_component(
component,
component_args,
args.scheduler,
workspace=workspace,
cfg=cfg,
)
else:
app_handle = runner.run_component(
component,
component_args,
args.scheduler,
cfg=cfg,
)
# DO NOT delete this line. It is used by slurm tests to retrieve the app id
print(app_handle)
if args.scheduler.startswith("local"):
self._wait_and_exit(runner, app_handle, log=True)
else:
logger.info(f"Launched app: {app_handle}")
status = runner.status(app_handle)
logger.info(status)
logger.info(f"Job URL: {none_throws(status).ui_url}")
if args.wait:
self._wait_and_exit(runner, app_handle, log=args.log)
except (ComponentValidationException, ComponentNotFoundException) as e:
error_msg = f"\nFailed to run component `{component}` got errors: \n {e}"
logger.error(error_msg)
sys.exit(1)
except specs.InvalidRunConfigException as e:
error_msg = (
f"Scheduler arg is incorrect or missing required option: `{e.cfg_key}`\n"
f"Run `torchx runopts` to check configuration for `{args.scheduler}` scheduler\n"
f"Use `-cfg` to specify run cfg as `key1=value1,key2=value2` pair\n"
"of setup `.torchxconfig` file, see: https://pytorch.org/torchx/main/experimental/runner.config.html"
)
logger.error(error_msg)
sys.exit(1)