Skip to content
This repository was archived by the owner on Apr 15, 2022. It is now read-only.

Commit 4d68e10

Browse files
author
Epstein
authored
Dbaas 3708 (#48)
* adding DB transaction ID and run id * fixing run_id * tag key improvement
1 parent 2df1343 commit 4d68e10

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

splicemachine/mlflow_support/mlflow_support.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _check_for_splice_ctx():
6666
if not getattr(mlflow, '_splice_context'):
6767
raise SpliceMachineException(
6868
"You must run `mlflow.register_splice_context(py_splice_context) before "
69-
"you can run mlflow artifact operations!"
69+
"you can run this mlflow operation!"
7070
)
7171

7272

@@ -156,16 +156,26 @@ def _start_run(run_id=None, tags=None, experiment_id=None, run_name=None, nested
156156
:param experiment_id: if you would like to create an experiment/use one for this run
157157
:param nested: Controls whether run is nested in parent run. True creates a nest run
158158
"""
159-
160-
if not tags:
161-
tags = {}
159+
# Get the current running transaction ID for time travel/data governance
160+
_check_for_splice_ctx()
161+
db_connection = mlflow._splice_context.getConnection()
162+
prepared_statement = db_connection.prepareStatement('CALL SYSCS_UTIL.SYSCS_GET_CURRENT_TRANSACTION()')
163+
x = prepared_statement.executeQuery()
164+
x.next()
165+
timestamp = x.getInt(1)
166+
prepared_statement.close()
167+
168+
tags = tags if tags else {}
162169
tags['mlflow.user'] = get_user()
170+
tags['DB Transaction ID'] = timestamp
163171

164172
orig = gorilla.get_original_attribute(mlflow, "start_run")
165173
active_run = orig(run_id=run_id, experiment_id=experiment_id, run_name=run_name, nested=nested)
166174

167175
for key in tags:
168176
mlflow.set_tag(key, tags[key])
177+
if not run_id:
178+
mlflow.set_tag('Run ID', mlflow.active_run().info.run_uuid)
169179
if run_name:
170180
mlflow.set_tag('mlflow.runName', run_name)
171181

0 commit comments

Comments
 (0)