prefect_databricks.flows
Module containing flows for interacting with Databricks
Functions
jobs_runs_submit_and_wait_for_completion
databricks_credentials: Credentials to use for authentication with Databricks.tasks: A list of task specifications (RunSubmitTaskSettings) to run. Each task defines its key, the cluster it runs on, and the work to do (a notebook, JAR, Python, SQL, or dbt task).run_name: An optional name for the run. Defaults toUntitled.git_source: An optional remote Git repository (GitSource) containing the notebooks used by the run’s notebook tasks. This functionality is in Public Preview.timeout_seconds: An optional timeout, in seconds, applied to the run. The default is no timeout.idempotency_token: An optional token (at most 64 characters) guaranteeing the idempotency of the request. If a run with the token already exists, the existing run’s ID is returned instead of creating a new run. See the Databricks docs on job idempotency for details.access_control_list: A list of permissions (AccessControlRequest) to set on the run.max_wait_seconds: The maximum number of seconds to wait for the entire flow to complete.poll_frequency_seconds: The number of seconds to wait between checks for run completion.return_metadata: If True, return a tuple of the notebook output and the run metadata. By default, only the notebook output is returned.job_submission_handler: An optional callable to intercept job submission.**jobs_runs_submit_kwargs: Additional keyword arguments to pass tojobs_runs_submit.
- Either a dict or a tuple (depends on
return_metadata) comprised of -
- task_notebook_outputs: dictionary of task keys to its corresponding notebook output; this is the only object returned by default from this method
-
- jobs_runs_metadata: dictionary containing IDs of the jobs runs tasks; this is only
returned if
return_metadata=True.
- jobs_runs_metadata: dictionary containing IDs of the jobs runs tasks; this is only
returned if
jobs_runs_wait_for_completion
run_name: The name of the jobs runs task.multi_task_jobs_runs_id: The ID of the jobs runs task to watch.databricks_credentials: Credentials to use for authentication with Databricks.max_wait_seconds: Maximum number of seconds to wait for the entire flow to complete.poll_frequency_seconds: Number of seconds to wait in between checks for run completion.
- A dict containing the jobs runs life cycle state and message.
- A dict containing IDs of the jobs runs tasks.
jobs_runs_submit_by_id_and_wait_for_completion
databricks_credentials: Credentials to use for authentication with Databricks.job_id: The ID of the Databricks job to run.idempotency_token: An optional token (at most 64 characters) guaranteeing the idempotency of the request. If a run with the token already exists, the existing run’s ID is returned instead of creating a new run. See the Databricks docs on job idempotency for details.jar_params: A list of command-line parameters for Spark JAR tasks, used to invoke the main class. Cannot be combined withnotebook_params, and its JSON representation cannot exceed 10,000 bytes.max_wait_seconds: The maximum number of seconds to wait for the entire flow to complete.poll_frequency_seconds: The number of seconds to wait between checks for run completion.notebook_params: A map of key-value parameters for notebook tasks, accessible throughdbutils.widgets.get. Cannot be combined withjar_params, and its JSON representation cannot exceed 10,000 bytes.python_params: A list of command-line parameters for Python tasks. ASCII characters only; its JSON representation cannot exceed 10,000 bytes.spark_submit_params: A list of parameters passed to thespark-submitscript. ASCII characters only; its JSON representation cannot exceed 10,000 bytes.python_named_params: A map of named parameters for Python wheel tasks.pipeline_params: Parameters for Delta Live Tables pipeline tasks, such as whether to trigger a full refresh.sql_params: A map of key-value parameters for SQL tasks. SQL alert tasks do not support custom parameters.dbt_commands: A list of dbt commands to run for dbt tasks, for example["dbt deps", "dbt seed", "dbt run"].job_submission_handler: An optional callable to intercept job submission.
DatabricksJobTerminated: Raised when the Databricks job run is terminated with a non-successful result state.DatabricksJobSkipped: Raised when the Databricks job run is skipped.DatabricksJobInternalError: Raised when the Databricks job run encounters an internal error.
- A dictionary containing information about the completed job run.