-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add operator to create jobs in Databricks (#35156)
* Provider Databricks add jobs create operator. * run black formatter with breeze * added support for databricks sdk to use the latest set of objects for type hints * remove without precommit * added databricks-sdk with precommit * use the databricks sdk objects * fixed type hints and adjusted tests * fixed as dict * fixed tests with proper testing logic * added jobs_create to provider.yaml file * resoved comments on pr * fixed imports in test_databricks.py * added correct type hint for reset_job * change type hint for json arg in DatabricksCreateJobsOperator * fixed CI errors * fixed broken tests and imports. also pinned databricks sdk to a specific version ==0.10.0 * fixed broken tests and imports. also pinned databricks sdk to a specific version ==0.10.0 * Fix CI static checks * Remove databricks-sdk dependency This was agreed with @stikkireddy, since there the SDK interfaces are changing ATM. When it becomes stable, we can re-introduce this dependency --------- Co-authored-by: Kyle Winkelman <[email protected]> Co-authored-by: Sri Tikkireddy <[email protected]> Co-authored-by: stikkireddy <[email protected]>
- Loading branch information
1 parent
da2fdbb
commit a8784e3
Showing
7 changed files
with
776 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
docs/apache-airflow-providers-databricks/operators/jobs_create.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
.. Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
.. http://www.apache.org/licenses/LICENSE-2.0 | ||
.. Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
DatabricksCreateJobsOperator | ||
============================ | ||
|
||
Use the :class:`~airflow.providers.databricks.operators.DatabricksCreateJobsOperator` to create | ||
(or reset) a Databricks job. This operator relies on past XComs to remember the ``job_id`` that | ||
was created so that repeated calls with this operator will update the existing job rather than | ||
creating new ones. When paired with the DatabricksRunNowOperator all runs will fall under the same | ||
job within the Databricks UI. | ||
|
||
|
||
Using the Operator | ||
------------------ | ||
|
||
There are three ways to instantiate this operator. In the first way, you can take the JSON payload that you typically use | ||
to call the ``api/2.1/jobs/create`` endpoint and pass it directly to our ``DatabricksCreateJobsOperator`` through the | ||
``json`` parameter. With this approach you get full control over the underlying payload to Jobs REST API, including | ||
execution of Databricks jobs with multiple tasks, but it's harder to detect errors because of the lack of the type checking. | ||
|
||
The second way to accomplish the same thing is to use the named parameters of the ``DatabricksCreateJobsOperator`` directly. Note that there is exactly | ||
one named parameter for each top level parameter in the ``api/2.1/jobs/create`` endpoint. | ||
|
||
The third way is to use both the json parameter **AND** the named parameters. They will be merged | ||
together. If there are conflicts during the merge, the named parameters will take precedence and | ||
override the top level ``json`` keys. | ||
|
||
Currently the named parameters that ``DatabricksCreateJobsOperator`` supports are: | ||
- ``name`` | ||
- ``tags`` | ||
- ``tasks`` | ||
- ``job_clusters`` | ||
- ``email_notifications`` | ||
- ``webhook_notifications`` | ||
- ``timeout_seconds`` | ||
- ``schedule`` | ||
- ``max_concurrent_runs`` | ||
- ``git_source`` | ||
- ``access_control_list`` | ||
|
||
|
||
Examples | ||
-------- | ||
|
||
Specifying parameters as JSON | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
An example usage of the DatabricksCreateJobsOperator is as follows: | ||
|
||
.. exampleinclude:: /../../tests/system/providers/databricks/example_databricks.py | ||
:language: python | ||
:start-after: [START howto_operator_databricks_jobs_create_json] | ||
:end-before: [END howto_operator_databricks_jobs_create_json] | ||
|
||
Using named parameters | ||
^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
You can also use named parameters to initialize the operator and run the job. | ||
|
||
.. exampleinclude:: /../../tests/system/providers/databricks/example_databricks.py | ||
:language: python | ||
:start-after: [START howto_operator_databricks_jobs_create_named] | ||
:end-before: [END howto_operator_databricks_jobs_create_named] | ||
|
||
Pairing with DatabricksRunNowOperator | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
You can use the ``job_id`` that is returned by the DatabricksCreateJobsOperator in the | ||
return_value XCom as an argument to the DatabricksRunNowOperator to run the job. | ||
|
||
.. exampleinclude:: /../../tests/system/providers/databricks/example_databricks.py | ||
:language: python | ||
:start-after: [START howto_operator_databricks_run_now] | ||
:end-before: [END howto_operator_databricks_run_now] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.