mirror of
https://github.com/clearml/clearml
synced 2025-02-07 13:23:40 +00:00
Fix Hydra support both Hydra section overrides and
This commit is contained in:
parent
c15f012e1b
commit
2c44bff461
@ -1,7 +1,7 @@
|
|||||||
import io
|
import io
|
||||||
import sys
|
import sys
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
import yaml
|
||||||
from ..config import running_remotely, get_remote_task_id, DEV_TASK_NO_REUSE
|
from ..config import running_remotely, get_remote_task_id, DEV_TASK_NO_REUSE
|
||||||
from ..debugging.log import LoggerRoot
|
from ..debugging.log import LoggerRoot
|
||||||
|
|
||||||
@ -81,7 +81,14 @@ class PatchHydra(object):
|
|||||||
stored_config = {k[len(PatchHydra._parameter_section)+1:]: v for k, v in full_parameters.items()
|
stored_config = {k[len(PatchHydra._parameter_section)+1:]: v for k, v in full_parameters.items()
|
||||||
if k.startswith(PatchHydra._parameter_section+'/')}
|
if k.startswith(PatchHydra._parameter_section+'/')}
|
||||||
stored_config.pop(PatchHydra._parameter_allow_full_edit, None)
|
stored_config.pop(PatchHydra._parameter_allow_full_edit, None)
|
||||||
overrides = ['{}={}'.format(k, v) for k, v in stored_config.items()]
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
|
overrides = yaml.safe_load(full_parameters.get("Args/overrides", "")) or []
|
||||||
|
except Exception:
|
||||||
|
overrides = []
|
||||||
|
if overrides and not isinstance(overrides, (list, tuple)):
|
||||||
|
overrides = [overrides]
|
||||||
|
overrides += ['{}={}'.format(k, v) for k, v in stored_config.items()]
|
||||||
else:
|
else:
|
||||||
# We take care of it inside the _patched_run_job
|
# We take care of it inside the _patched_run_job
|
||||||
pass
|
pass
|
||||||
@ -119,7 +126,8 @@ class PatchHydra(object):
|
|||||||
else:
|
else:
|
||||||
PatchHydra._last_untracked_state['connect'] = dict(
|
PatchHydra._last_untracked_state['connect'] = dict(
|
||||||
mutable=stored_config, name=PatchHydra._parameter_section)
|
mutable=stored_config, name=PatchHydra._parameter_section)
|
||||||
# todo: remove the overrides section from the Args (we have it here)
|
# Maybe ?! remove the overrides section from the Args (we have it here)
|
||||||
|
# But when used with a Pipeline this is the only section we get... so we leave it here anyhow
|
||||||
# PatchHydra._current_task.delete_parameter('Args/overrides')
|
# PatchHydra._current_task.delete_parameter('Args/overrides')
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user