mirror of
https://github.com/clearml/clearml
synced 2025-02-07 21:33:25 +00:00
Add internal Task._get_task_status()
This commit is contained in:
parent
bb648bdb02
commit
49ba89587f
@ -2133,3 +2133,19 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
||||
:return: boolean offline-mode state
|
||||
"""
|
||||
return cls._offline_mode
|
||||
|
||||
@classmethod
|
||||
def _get_task_status(cls, task_id):
|
||||
# type: (str) -> (Optional[str], Optional[str])
|
||||
if cls._offline_mode:
|
||||
return tasks.TaskStatusEnum.created, 'offline'
|
||||
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
all_tasks = cls._get_default_session().send(
|
||||
tasks.GetAllRequest(id=[task_id], only_fields=['status', 'status_message']),
|
||||
).response.tasks
|
||||
return all_tasks[0].status, all_tasks[0].status_message
|
||||
except Exception:
|
||||
return None, None
|
||||
|
||||
|
@ -56,7 +56,7 @@ def get_or_create_project(session, project_name, description=None):
|
||||
return None
|
||||
if res.response.projects:
|
||||
return res.response.projects[0].id
|
||||
res = session.send(projects.CreateRequest(name=project_name, description=description))
|
||||
res = session.send(projects.CreateRequest(name=project_name, description=description or ''))
|
||||
return res.response.id
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user