Run a workflow
This recipe triggers a Databricks Workflows job using the Databricks SDK for Python.
Code snippet
app.py
import streamlit as st
from databricks.sdk import WorkspaceClient
w = WorkspaceClient()
job_id = st.text_input(
label="Specify job id:",
placeholder="921773893211960",
help="You can find the job ID under job details after opening a job in the UI.",
)
parameters_input = st.text_area(
label="Specify job parameters as JSON:",
placeholder='{"param1": "value1", "param2": "value2"}',
)
parameters = eval(parameters_input.strip())
if st.button(label="Trigger job"):
try:
run = w.jobs.run_now(job_id=job_id, job_parameters=parameters)
st.text(f"Started run with ID {run.run_id}")
except Exception as e:
st.warning(e)
Resources
Permissions
Your app service principal needs the following permissions:
CAN MANAGE RUN
permission on the job
See Control access to a job for more information.
Dependencies
- Databricks SDK for Python -
databricks-sdk
- Streamlit -
streamlit
requirements.txt
databricks-sdk
streamlit