mirror of
https://github.com/clearml/clearml
synced 2025-02-12 07:35:08 +00:00
Fix Task.close() should remove current_task() reference
This commit is contained in:
parent
3c66c42157
commit
9a2d091849
@ -1364,6 +1364,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
def set_system_tags(self, tags):
|
def set_system_tags(self, tags):
|
||||||
# type: (Sequence[str]) -> ()
|
# type: (Sequence[str]) -> ()
|
||||||
assert isinstance(tags, (list, tuple))
|
assert isinstance(tags, (list, tuple))
|
||||||
|
tags = list(set(tags))
|
||||||
if Session.check_min_api_version('2.3'):
|
if Session.check_min_api_version('2.3'):
|
||||||
self._set_task_property("system_tags", tags)
|
self._set_task_property("system_tags", tags)
|
||||||
self._edit(system_tags=self.data.system_tags)
|
self._edit(system_tags=self.data.system_tags)
|
||||||
@ -2208,7 +2209,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __update_master_pid_task(cls, pid=None, task=None):
|
def __update_master_pid_task(cls, pid=None, task=None):
|
||||||
# type: (Optional[int], Union[str, Task]) -> None
|
# type: (Optional[int], Optional[Union[str, Task]]) -> None
|
||||||
pid = pid or os.getpid()
|
pid = pid or os.getpid()
|
||||||
if not task:
|
if not task:
|
||||||
PROC_MASTER_ID_ENV_VAR.set(str(pid) + ':')
|
PROC_MASTER_ID_ENV_VAR.set(str(pid) + ':')
|
||||||
@ -2223,11 +2224,11 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def __get_master_id_task_id(cls):
|
def __get_master_id_task_id(cls):
|
||||||
# type: () -> Optional[str]
|
# type: () -> Optional[str]
|
||||||
master_task_id = PROC_MASTER_ID_ENV_VAR.get().split(':')
|
master_pid, _, master_task_id = PROC_MASTER_ID_ENV_VAR.get('').partition(':')
|
||||||
# we could not find a task ID, revert to old stub behaviour
|
# we could not find a task ID, revert to old stub behaviour
|
||||||
if len(master_task_id) < 2 or not master_task_id[1]:
|
if not master_task_id:
|
||||||
return None
|
return None
|
||||||
return master_task_id[1]
|
return master_task_id
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __get_master_process_id(cls):
|
def __get_master_process_id(cls):
|
||||||
|
@ -184,7 +184,7 @@ class Task(_Task):
|
|||||||
:return: The current running Task (experiment).
|
:return: The current running Task (experiment).
|
||||||
"""
|
"""
|
||||||
# check if we have no main Task, but the main process created one.
|
# check if we have no main Task, but the main process created one.
|
||||||
if not cls.__main_task and PROC_MASTER_ID_ENV_VAR.get():
|
if not cls.__main_task and cls.__get_master_id_task_id():
|
||||||
# initialize the Task, connect to stdout
|
# initialize the Task, connect to stdout
|
||||||
Task.init()
|
Task.init()
|
||||||
# return main Task
|
# return main Task
|
||||||
@ -3061,6 +3061,7 @@ class Task(_Task):
|
|||||||
# this is so in theory we can close a main task and start a new one
|
# this is so in theory we can close a main task and start a new one
|
||||||
if self.is_main_task():
|
if self.is_main_task():
|
||||||
Task.__main_task = None
|
Task.__main_task = None
|
||||||
|
Task.__update_master_pid_task(task=None)
|
||||||
except Exception:
|
except Exception:
|
||||||
# make sure we do not interrupt the exit process
|
# make sure we do not interrupt the exit process
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user