mirror of
https://github.com/clearml/clearml
synced 2025-02-07 13:23:40 +00:00
Add project_name argument to Task.set_project()
This commit is contained in:
parent
17f9fa512f
commit
c51faca0c7
@ -1105,8 +1105,20 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
# fixed seed for the time being
|
# fixed seed for the time being
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def set_project(self, project_id):
|
def set_project(self, project_id=None, project_name=None):
|
||||||
# type: (str) -> ()
|
# type: (Optional[str], Optional[str]) -> ()
|
||||||
|
|
||||||
|
# if running remotely and we are the main task, skip setting ourselves.
|
||||||
|
if self._is_main_remote_task():
|
||||||
|
return
|
||||||
|
|
||||||
|
if not project_id:
|
||||||
|
assert isinstance(project_name, six.string_types)
|
||||||
|
res = self.send(projects.GetAllRequest(name=exact_match_regex(project_name)), raise_on_errors=False)
|
||||||
|
if not res or not res.response or not res.response.projects or len(res.response.projects) != 1:
|
||||||
|
return False
|
||||||
|
project_id = res.response.projects[0].id
|
||||||
|
|
||||||
assert isinstance(project_id, six.string_types)
|
assert isinstance(project_id, six.string_types)
|
||||||
self._set_task_property("project", project_id)
|
self._set_task_property("project", project_id)
|
||||||
self._edit(project=project_id)
|
self._edit(project=project_id)
|
||||||
@ -1616,6 +1628,9 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
|||||||
return None
|
return None
|
||||||
return text_to_config_dict(config_text)
|
return text_to_config_dict(config_text)
|
||||||
|
|
||||||
|
def _is_main_remote_task(self):
|
||||||
|
return running_remotely() and get_remote_task_id() == self.id
|
||||||
|
|
||||||
def get_offline_mode_folder(self):
|
def get_offline_mode_folder(self):
|
||||||
# type: () -> (Optional[Path])
|
# type: () -> (Optional[Path])
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user