From 504dfd8f3294337b6986eec4f99d198eac529f9d Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Sun, 10 Jan 2021 12:48:16 +0200 Subject: [PATCH] Fix reusing task after its project was deleted (issue #274) --- clearml/task.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/clearml/task.py b/clearml/task.py index 16921b55..15aa03a1 100644 --- a/clearml/task.py +++ b/clearml/task.py @@ -3245,20 +3245,28 @@ class Task(_Task): if not task_id: return False - task = cls.__get_task_api_obj(task_id, ('id', 'name', 'project', 'type')) + # noinspection PyBroadException + try: + task = cls.__get_task_api_obj(task_id, ('id', 'name', 'project', 'type')) + except Exception: + task = None if task is None: return False project_name = None if task.project: - project = cls._send( - cls._get_default_session(), - projects.GetByIdRequest(project=task.project) - ).response.project + # noinspection PyBroadException + try: + project = cls._send( + cls._get_default_session(), + projects.GetByIdRequest(project=task.project) + ).response.project - if project: - project_name = project.name + if project: + project_name = project.name + except Exception: + pass if task_data.get('type') and \ task_data.get('type') not in (cls.TaskTypes.training, cls.TaskTypes.testing) and \