Skip to content

Commit 823bc17

Browse files
committed
log cells tagged with "mlflow_log" as artifacts
1 parent 7de3ff5 commit 823bc17

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

jupyter_scheduler/executors.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ def execute(self):
144144
ep.preprocess(nb, {"metadata": {"path": staging_dir}})
145145
if job.parameters:
146146
mlflow.log_params(job.parameters)
147+
148+
for index, cell in enumerate(nb.cells):
149+
if "tags" in cell.metadata and "mlflow_log" in cell.metadata["tags"]:
150+
mlflow.log_text(cell.source, f"source_cell_{index}.txt")
151+
if cell.cell_type == "code" and cell.outputs:
152+
for output in cell.outputs:
153+
if "text/plain" in output.data:
154+
mlflow.log_text(
155+
output.data["text/plain"], f"output_cell_{cell.cell_id}.txt"
156+
)
157+
147158
except CellExecutionError as e:
148159
raise e
149160
finally:

0 commit comments

Comments
 (0)