mirror of
https://github.com/clearml/clearml
synced 2025-04-22 07:15:57 +00:00
Add support for task progress using Task.set_progress()
This commit is contained in:
parent
1080d2a840
commit
7a1b42c5ed
@ -671,6 +671,7 @@ class Task(_Task):
|
|||||||
# monitoring are: Resource monitoring and Dev Worker monitoring classes
|
# monitoring are: Resource monitoring and Dev Worker monitoring classes
|
||||||
BackgroundMonitor.start_all(task=task)
|
BackgroundMonitor.start_all(task=task)
|
||||||
|
|
||||||
|
task.set_progress(0)
|
||||||
return task
|
return task
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -1207,6 +1208,29 @@ class Task(_Task):
|
|||||||
resp = res.response
|
resp = res.response
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
def set_progress(self, progress):
|
||||||
|
# type: (int) -> ()
|
||||||
|
"""
|
||||||
|
Sets Task's progress (0 - 100)
|
||||||
|
Progress is a field computed and reported by the user.
|
||||||
|
|
||||||
|
:param progress: numeric value (0 - 100)
|
||||||
|
"""
|
||||||
|
if not isinstance(progress, int) or progress < 0 or progress > 100:
|
||||||
|
self.log.warning("Can't set progress {} as it is not and int between 0 and 100".format(progress))
|
||||||
|
return
|
||||||
|
self._set_runtime_properties({"progress": str(progress)})
|
||||||
|
|
||||||
|
def get_progress(self):
|
||||||
|
# type: () -> (Optional[int])
|
||||||
|
"""
|
||||||
|
Gets Task's progress (0 - 100)
|
||||||
|
|
||||||
|
:return: Task's progress as an int.
|
||||||
|
In case the progress doesn't exist, None will be returned
|
||||||
|
"""
|
||||||
|
return self._get_runtime_properties().get("progress")
|
||||||
|
|
||||||
def add_tags(self, tags):
|
def add_tags(self, tags):
|
||||||
# type: (Union[Sequence[str], str]) -> None
|
# type: (Union[Sequence[str], str]) -> None
|
||||||
"""
|
"""
|
||||||
@ -3367,6 +3391,8 @@ class Task(_Task):
|
|||||||
pass
|
pass
|
||||||
self._edit_lock = None
|
self._edit_lock = None
|
||||||
|
|
||||||
|
self.set_progress(100)
|
||||||
|
|
||||||
# make sure no one will re-enter the shutdown method
|
# make sure no one will re-enter the shutdown method
|
||||||
self._at_exit_called = True
|
self._at_exit_called = True
|
||||||
if not is_sub_process and BackgroundMonitor.is_subprocess_enabled():
|
if not is_sub_process and BackgroundMonitor.is_subprocess_enabled():
|
||||||
|
Loading…
Reference in New Issue
Block a user