Skip to content

Commit b08d653

Browse files
committed
log cells tagged with "mlflow_log" as artifacts
1 parent da97fa2 commit b08d653

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
@@ -180,6 +180,17 @@ def create_output_files(self, job: DescribeJob, notebook_node):
180180
ep.preprocess(nb)
181181
if job.parameters:
182182
mlflow.log_params(job.parameters)
183+
184+
for index, cell in enumerate(nb.cells):
185+
if "tags" in cell.metadata and "mlflow_log" in cell.metadata["tags"]:
186+
mlflow.log_text(cell.source, f"source_cell_{index}.txt")
187+
if cell.cell_type == "code" and cell.outputs:
188+
for output in cell.outputs:
189+
if "text/plain" in output.data:
190+
mlflow.log_text(
191+
output.data["text/plain"], f"output_cell_{cell.cell_id}.txt"
192+
)
193+
183194
except CellExecutionError as e:
184195
raise e
185196
finally:

0 commit comments

Comments
 (0)