mirror of
https://github.com/clearml/clearml
synced 2025-03-03 18:52:12 +00:00
Add status_message support to Task.mark_stopped()
This commit is contained in:
parent
0ebed74968
commit
be1478e67a
@ -573,11 +573,11 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
||||
""" The signal that this Task started. """
|
||||
return self.send(tasks.StartedRequest(self.id, force=force), ignore_errors=ignore_errors)
|
||||
|
||||
def stopped(self, ignore_errors=True, force=False, status_reason=None):
|
||||
# type: (bool, bool, Optional[str]) -> ()
|
||||
def stopped(self, ignore_errors=True, force=False, status_reason=None, status_message=None):
|
||||
# type: (bool, bool, Optional[str], Optional[str]) -> ()
|
||||
""" The signal that this Task stopped. """
|
||||
return self.send(
|
||||
tasks.StoppedRequest(self.id, force=force, status_reason=status_reason),
|
||||
tasks.StoppedRequest(self.id, force=force, status_reason=status_reason, status_message=status_message),
|
||||
ignore_errors=ignore_errors
|
||||
)
|
||||
|
||||
@ -591,7 +591,14 @@ class Task(IdObjectBase, AccessMixin, SetupUploadMixin):
|
||||
|
||||
def mark_completed(self, ignore_errors=True, status_message=None, force=False):
|
||||
# type: (bool, Optional[str], bool) -> ()
|
||||
""" The signal indicating that this Task completed. """
|
||||
"""
|
||||
Manually mark a Task as completed
|
||||
|
||||
:param bool ignore_errors: If True (default), ignore any errors raised
|
||||
:param bool force: If True the task status will be changed to `stopped` regardless of the current Task state.
|
||||
:param str status_message: Optional, add status change message to the stop request.
|
||||
This message will be stored as status_message on the Task's info panel
|
||||
"""
|
||||
if hasattr(tasks, 'CompletedRequest') and callable(tasks.CompletedRequest):
|
||||
return self.send(
|
||||
tasks.CompletedRequest(self.id, status_reason='completed', status_message=status_message, force=force),
|
||||
|
@ -1454,17 +1454,19 @@ class Task(_Task):
|
||||
self.started(force=force)
|
||||
self.reload()
|
||||
|
||||
def mark_stopped(self, force=False):
|
||||
# type: (bool) -> ()
|
||||
def mark_stopped(self, force=False, status_message=None):
|
||||
# type: (bool, Optional[str]) -> ()
|
||||
"""
|
||||
Manually mark a Task as stopped (also used in :meth:`_at_exit`)
|
||||
|
||||
:param bool force: If True the task status will be changed to `stopped` regardless of the current Task state.
|
||||
:param str status_message: Optional, add status change message to the stop request.
|
||||
This message will be stored as status_message on the Task's info panel
|
||||
"""
|
||||
# flush any outstanding logs
|
||||
self.flush(wait_for_uploads=True)
|
||||
# mark task as stopped
|
||||
self.stopped(force=force)
|
||||
self.stopped(force=force, status_message=str(status_message) if status_message else None)
|
||||
|
||||
def flush(self, wait_for_uploads=False):
|
||||
# type: (bool) -> bool
|
||||
|
Loading…
Reference in New Issue
Block a user