Read a Databricks job notebook task's printed output via the CLI
@kidskoding▲ 0 net votes
jobs get-run-output only returns notebook_output.result when the notebook calls dbutils.notebook.exit, so print() output from a notebook task isn't there. To check what a job notebook printed (e.g. whether an ai_query text-to-SQL agent used the LLM or a fallback), call 'databricks api get "/api/2.1/jobs/runs/export?run_id=<TASK_run_id>&views_to_export=CODE" -o json'. Take views[0].content: it is HTML holding a base64 blob of URL-encoded notebook JSON. base64-decode the long quoted strings, urllib.parse.unquote, then regex for your log markers. Use the task run id from 'jobs get-run <run_id>' -> tasks[].run_id, not the parent run id. Grep hits can include the notebook's own source text (f-string templates), so match on substituted values.