mirror of
https://github.com/clearml/clearml
synced 2025-06-25 09:36:04 +00:00
Fix deferred configuration support
This commit is contained in:
parent
75dfed6022
commit
c046acb816
@ -167,7 +167,7 @@ class Reporter(InterfaceBase, AbstractContextManager, SetupUploadMixin, AsyncMan
|
|||||||
"""
|
"""
|
||||||
log = metrics.log.getChild('reporter')
|
log = metrics.log.getChild('reporter')
|
||||||
log.setLevel(log.level)
|
log.setLevel(log.level)
|
||||||
if self.__class__.max_float_num_digits is -1:
|
if self.__class__.max_float_num_digits == -1:
|
||||||
self.__class__.max_float_num_digits = config.get('metrics.plot_max_num_digits', None)
|
self.__class__.max_float_num_digits = config.get('metrics.plot_max_num_digits', None)
|
||||||
|
|
||||||
super(Reporter, self).__init__(session=metrics.session, log=log)
|
super(Reporter, self).__init__(session=metrics.session, log=log)
|
||||||
|
@ -60,10 +60,11 @@ def deferred_config(key=None, default=Config._MISSING, transform=None, multi=Non
|
|||||||
return LazyEvalWrapper(
|
return LazyEvalWrapper(
|
||||||
callback=lambda:
|
callback=lambda:
|
||||||
(ConfigSDKWrapper.get(key, default) if not multi else
|
(ConfigSDKWrapper.get(key, default) if not multi else
|
||||||
next(ConfigSDKWrapper.get(*a) for a in multi if ConfigSDKWrapper.get(*a)))
|
next((ConfigSDKWrapper.get(*a) for a in multi if ConfigSDKWrapper.get(*a)), None))
|
||||||
if transform is None
|
if transform is None
|
||||||
else (transform() if key is None else transform(ConfigSDKWrapper.get(key, default) if not multi else # noqa
|
else (transform() if key is None else transform(ConfigSDKWrapper.get(key, default) if not multi else # noqa
|
||||||
next(ConfigSDKWrapper.get(*a) for a in multi if ConfigSDKWrapper.get(*a)))))
|
next((ConfigSDKWrapper.get(*a) for a in multi if ConfigSDKWrapper.get(*a)), None)))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
config_obj = ConfigWrapper
|
config_obj = ConfigWrapper
|
||||||
|
@ -1050,16 +1050,18 @@ class Logger(object):
|
|||||||
# noinspection PyProtectedMember
|
# noinspection PyProtectedMember
|
||||||
return self._default_upload_destination or self._task._get_default_report_storage_uri()
|
return self._default_upload_destination or self._task._get_default_report_storage_uri()
|
||||||
|
|
||||||
def flush(self):
|
def flush(self, wait=False):
|
||||||
# type: () -> bool
|
# type: (bool) -> bool
|
||||||
"""
|
"""
|
||||||
Flush cached reports and console outputs to backend.
|
Flush cached reports and console outputs to backend.
|
||||||
|
|
||||||
|
:param wait: Wait for all outstanding uploads and events to be sent (default False)
|
||||||
|
|
||||||
:return: True, if successfully flushed the cache. False, if failed.
|
:return: True, if successfully flushed the cache. False, if failed.
|
||||||
"""
|
"""
|
||||||
self._flush_stdout_handler()
|
self._flush_stdout_handler()
|
||||||
if self._task:
|
if self._task:
|
||||||
return self._task.flush()
|
return self._task.flush(wait_for_uploads=wait)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_flush_period(self):
|
def get_flush_period(self):
|
||||||
|
@ -542,7 +542,7 @@ class BackgroundMonitor(object):
|
|||||||
return self._instances.setdefault(self._task_obj_id, [])
|
return self._instances.setdefault(self._task_obj_id, [])
|
||||||
|
|
||||||
def _is_subprocess_mode_and_not_parent_process(self):
|
def _is_subprocess_mode_and_not_parent_process(self):
|
||||||
return self.is_subprocess_mode() and self._main_process != os.getpid()
|
return self.is_subprocess_mode() and self._parent_pid != os.getpid()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_subprocess_enabled(cls, task=None):
|
def is_subprocess_enabled(cls, task=None):
|
||||||
|
@ -191,6 +191,16 @@ class WrapperBase(type):
|
|||||||
cb = object.__getattribute__(self, "_callback")
|
cb = object.__getattribute__(self, "_callback")
|
||||||
obj = cb()
|
obj = cb()
|
||||||
object.__setattr__(self, '_wrapped', obj)
|
object.__setattr__(self, '_wrapped', obj)
|
||||||
|
|
||||||
|
# we have to convert the instance to the real type
|
||||||
|
if args and len(args) == 1 and (
|
||||||
|
type(args[0]) == LazyEvalWrapper or hasattr(type(args[0]), '_base_class_')):
|
||||||
|
try:
|
||||||
|
int(args[0]) # force loading the instance
|
||||||
|
except: # noqa
|
||||||
|
pass
|
||||||
|
args = (object.__getattribute__(args[0], "_wrapped"), )
|
||||||
|
|
||||||
mtd = getattr(obj, name)
|
mtd = getattr(obj, name)
|
||||||
return mtd(*args, **kwargs)
|
return mtd(*args, **kwargs)
|
||||||
return method
|
return method
|
||||||
|
Loading…
Reference in New Issue
Block a user