mirror of
https://github.com/clearml/clearml
synced 2025-06-26 18:16:07 +00:00
Fix access to default output destination when project can't be loaded, add warning message but do not fail
This commit is contained in:
parent
40bd979db1
commit
d98155a4e3
@ -1923,7 +1923,7 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
self._project_name = (self.project, res.response.project.name)
|
self._project_name = (self.project, res.response.project.name)
|
||||||
return self._project_name[1]
|
return self._project_name[1]
|
||||||
|
|
||||||
def get_project_object(self) -> dict:
|
def get_project_object(self) -> "projects.Project":
|
||||||
"""Get the current Task's project as a python object."""
|
"""Get the current Task's project as a python object."""
|
||||||
if self.project is None:
|
if self.project is None:
|
||||||
return self._project_object[1] if self._project_object and len(self._project_object) > 1 else None
|
return self._project_object[1] if self._project_object and len(self._project_object) > 1 else None
|
||||||
@ -1933,7 +1933,8 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
|
|
||||||
res = self.send(projects.GetByIdRequest(project=self.project), raise_on_errors=False)
|
res = self.send(projects.GetByIdRequest(project=self.project), raise_on_errors=False)
|
||||||
if not res or not res.response or not res.response.project:
|
if not res or not res.response or not res.response.project:
|
||||||
return {}
|
self.log.warning("Project {} not found or no read access available".format(self.project))
|
||||||
|
return None
|
||||||
self._project_object = (self.project, res.response.project)
|
self._project_object = (self.project, res.response.project)
|
||||||
return self._project_object[1]
|
return self._project_object[1]
|
||||||
|
|
||||||
|
@ -590,6 +590,10 @@ class Task(_Task):
|
|||||||
)
|
)
|
||||||
task_type = Task.TaskTypes.__members__[str(task_type)]
|
task_type = Task.TaskTypes.__members__[str(task_type)]
|
||||||
|
|
||||||
|
def safe_project_default_output_destination(task_, default=None):
|
||||||
|
project_ = task_.get_project_object()
|
||||||
|
return project_.default_output_destination if project_ else default
|
||||||
|
|
||||||
is_deferred = False
|
is_deferred = False
|
||||||
try:
|
try:
|
||||||
if not running_remotely():
|
if not running_remotely():
|
||||||
@ -670,10 +674,10 @@ class Task(_Task):
|
|||||||
Path(task._get_default_report_storage_uri()).mkdir(parents=True, exist_ok=True)
|
Path(task._get_default_report_storage_uri()).mkdir(parents=True, exist_ok=True)
|
||||||
elif output_uri is not None:
|
elif output_uri is not None:
|
||||||
if output_uri is True:
|
if output_uri is True:
|
||||||
output_uri = task.get_project_object().default_output_destination or True
|
output_uri = safe_project_default_output_destination(task) or True
|
||||||
task.output_uri = output_uri
|
task.output_uri = output_uri
|
||||||
elif task.get_project_object().default_output_destination:
|
elif safe_project_default_output_destination(task):
|
||||||
task.output_uri = task.get_project_object().default_output_destination
|
task.output_uri = safe_project_default_output_destination(task)
|
||||||
elif cls.__default_output_uri:
|
elif cls.__default_output_uri:
|
||||||
task.output_uri = str(cls.__default_output_uri)
|
task.output_uri = str(cls.__default_output_uri)
|
||||||
# store new task ID
|
# store new task ID
|
||||||
@ -693,8 +697,8 @@ class Task(_Task):
|
|||||||
# Setting output_uri=False argument will disable using any default when running remotely
|
# Setting output_uri=False argument will disable using any default when running remotely
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if task.get_project_object().default_output_destination and not task.output_uri:
|
if safe_project_default_output_destination(task) and not task.output_uri:
|
||||||
task.output_uri = task.get_project_object().default_output_destination
|
task.output_uri = safe_project_default_output_destination(task)
|
||||||
if cls.__default_output_uri and not task.output_uri:
|
if cls.__default_output_uri and not task.output_uri:
|
||||||
task.output_uri = cls.__default_output_uri
|
task.output_uri = cls.__default_output_uri
|
||||||
# store new task ID
|
# store new task ID
|
||||||
|
Loading…
Reference in New Issue
Block a user