Replies: 1 comment
-
|
Hi @kyrre! Your current approach (searching by name) works but has a few fragilities. Here are the recommended patterns for triggering DAB-managed workflows via the Python SDK: Your current approach — improved: from databricks.sdk import WorkspaceClient w = WorkspaceClient(profile="security") Use next() with a generator for safety (avoids IndexError if job not found)job_name = "[dev kyrre_wahl_kongsgard] azure_applications_job" job = next( if job is None: run = w.jobs.run_now_and_wait( Better approach — use the job_id from DAB outputs: After databricks bundle deploy, the bundle stores the created job IDs in the bundle state. You can retrieve them: Get job ID from bundle metadatadatabricks bundle summary --output json | jq '.resources.jobs.<job_key>.id' Then hardcode or inject that ID into your SDK call — avoids the name search entirely. Recommended pattern for CI/CD integration: import os w = WorkspaceClient(profile="security") Inject job_id from environment (set by your CI/CD pipeline from DAB outputs)job_id = int(os.environ["MY_JOB_ID"]) run = w.jobs.run_now_and_wait( For listing with pagination (important for large workspaces): w.jobs.list() returns a generator — works fine, but add a name filter for speedjobs = w.jobs.list(name=job_name) # server-side filter, much faster Note: w.jobs.list(limit=1, name=job_name) with exact name match is actually the fastest approach — no need to iterate all jobs. The name parameter in the API does server-side filtering. Let me know if you're triggering this from a CI pipeline or from another Databricks notebook! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to use the SDK to trigger a workflows defined using DAB (in the same project), e.g., the layout is as follows:
where the file
[service_principal_name].parquet.pyshould run the job:is there any way do this in a seamless way so I easily switch between the different targets without manually specifying the target name? 🤔
Beta Was this translation helpful? Give feedback.
All reactions