[Fix] local runner debug (#238)

This commit is contained in:
Leymore 2023-08-21 16:58:36 +08:00 committed by GitHub
parent 8d368d1cd6
commit fdc69f9d58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,7 +59,18 @@ class LocalRunner(BaseRunner):
for task in tasks: for task in tasks:
task = TASKS.build(dict(type=self.task_cfg.type, cfg=task)) task = TASKS.build(dict(type=self.task_cfg.type, cfg=task))
task_name = task.name task_name = task.name
task.run() # get cmd
mmengine.mkdir_or_exist('tmp/')
param_file = f'tmp/{os.getpid()}_params.py'
task.cfg.dump(param_file)
cmd = task.get_command(cfg_path=param_file,
template='{task_cmd}')
# run in subprocess if starts with torchrun etc.
if cmd.startswith('python'):
task.run()
else:
subprocess.run(cmd, shell=True, text=True)
os.remove(param_file)
status.append((task_name, 0)) status.append((task_name, 0))
else: else:
import torch import torch