Add Task._set_runtime_property

This commit is contained in:
allegroai 2021-09-03 03:23:51 +03:00
parent f9d1bebf3d
commit 3e767fd304
2 changed files with 15 additions and 4 deletions

View File

@ -1801,6 +1801,20 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
except Exception:
return None
def _set_runtime_properties(self, runtime_properties):
# type: (Mapping[str, str]) -> bool
if not Session.check_min_api_version('2.13') or not runtime_properties:
return False
with self._edit_lock:
self.reload()
current_runtime_properties = self.data.runtime or {}
current_runtime_properties.update(runtime_properties)
# noinspection PyProtectedMember
self._edit(runtime=current_runtime_properties)
return True
def _clear_task(self, system_tags=None, comment=None):
# type: (Optional[Sequence[str]], Optional[str]) -> ()
self._data.script = tasks.Script(

View File

@ -76,11 +76,8 @@ class ResourceMonitor(BackgroundMonitor):
try:
machine_spec = self._get_machine_specs()
if machine_spec:
self._task.reload()
runtime_properties = self._task.data.runtime or {}
runtime_properties.update(machine_spec)
# noinspection PyProtectedMember
self._task._edit(runtime=runtime_properties)
self._task._set_runtime_properties(runtime_properties=machine_spec)
except Exception as ex:
logging.getLogger('clearml.resource_monitor').debug(
'Failed logging machine specification: {}'.format(ex))