@@ -43,7 +43,7 @@ def __init__(self, conn, database):
4343 connection_id = 0 : bigint unsigned # connection_id()
4444 timestamp :timestamp # timestamp of the job status change or scheduled time
4545 run_duration=null : float # run duration in seconds
46- run_version="" : varchar(255) # some string representation of the code/env version of a run (e.g. git commit hash )
46+ run_metadata=null :json # metadata about the run (e.g. code version, environment info )
4747 index(table_name, status)
4848 index(status)
4949 index(timestamp) # for ordering jobs
@@ -185,14 +185,15 @@ def ignore(self, table_name, key, message=""):
185185
186186 return True
187187
188- def complete (self , table_name , key , run_duration = None , run_version = "" ):
188+ def complete (self , table_name , key , run_duration = None , run_metadata = None ):
189189 """
190190 Log a completed job. When a job is completed, its reservation entry is deleted.
191191
192- :param table_name: `database`.`table_name`
193- :param key: the dict of the job's primary key
194- :param run_duration: duration in second of the job run
195- :param run_version: some string representation of the code/env version of a run (e.g. git commit hash)
192+ Args:
193+ table_name: `database`.`table_name`
194+ key: the dict of the job's primary key
195+ run_duration: duration in second of the job run
196+ run_metadata: dict containing metadata about the run (e.g. code version, environment info)
196197 """
197198 job_key = dict (table_name = table_name , key_hash = key_hash (key ))
198199 if self & job_key :
@@ -212,24 +213,25 @@ def complete(self, table_name, key, run_duration=None, run_version=""):
212213 user = self ._user ,
213214 key = _jsonify (key ),
214215 run_duration = run_duration ,
215- run_version = run_version ,
216+ run_metadata = _jsonify ( run_metadata ) if run_metadata else None ,
216217 timestamp = datetime .datetime .utcnow (),
217218 ),
218219 replace = True ,
219220 ignore_extra_fields = True ,
220221 )
221222
222- def error (self , table_name , key , error_message , error_stack = None , run_duration = None , run_version = "" ):
223+ def error (self , table_name , key , error_message , error_stack = None , run_duration = None , run_metadata = None ):
223224 """
224225 Log an error message. The job reservation is replaced with an error entry.
225226 if an error occurs, leave an entry describing the problem
226227
227- :param table_name: `database`.`table_name`
228- :param key: the dict of the job's primary key
229- :param error_message: string error message
230- :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)
228+ Args:
229+ table_name: `database`.`table_name`
230+ key: the dict of the job's primary key
231+ error_message: string error message
232+ error_stack: stack trace
233+ run_duration: duration in second of the job run
234+ run_metadata: dict containing metadata about the run (e.g. code version, environment info)
233235 """
234236 if len (error_message ) > ERROR_MESSAGE_LENGTH :
235237 error_message = (
@@ -250,7 +252,7 @@ def error(self, table_name, key, error_message, error_stack=None, run_duration=N
250252 error_message = error_message ,
251253 error_stack = error_stack ,
252254 run_duration = run_duration ,
253- run_version = run_version ,
255+ run_metadata = _jsonify ( run_metadata ) if run_metadata else None ,
254256 timestamp = datetime .datetime .utcnow (),
255257 ),
256258 replace = True ,
0 commit comments