Skip to content

Commit 2ac9fa2

Browse files
committed
fix: log run_duration in error jobs
1 parent cc0f398 commit 2ac9fa2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

datajoint/jobs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def complete(self, table_name, key, run_duration=None, run_version=""):
219219
ignore_extra_fields=True,
220220
)
221221

222-
def error(self, table_name, key, error_message, error_stack=None):
222+
def error(self, table_name, key, error_message, error_stack=None, run_duration=None, run_version=""):
223223
"""
224224
Log an error message. The job reservation is replaced with an error entry.
225225
if an error occurs, leave an entry describing the problem
@@ -228,6 +228,8 @@ def error(self, table_name, key, error_message, error_stack=None):
228228
:param key: the dict of the job's primary key
229229
:param error_message: string error message
230230
:param error_stack: stack trace
231+
:param run_duration: duration in second of the job run
232+
:param run_version: some string representation of the code/env version of a run (e.g. git commit hash)
231233
"""
232234
if len(error_message) > ERROR_MESSAGE_LENGTH:
233235
error_message = (
@@ -247,6 +249,8 @@ def error(self, table_name, key, error_message, error_stack=None):
247249
key=_jsonify(key),
248250
error_message=error_message,
249251
error_stack=error_stack,
252+
run_duration=run_duration,
253+
run_version=run_version,
250254
timestamp=datetime.datetime.utcnow(),
251255
),
252256
replace=True,

0 commit comments

Comments
 (0)