prefect-databricks 0.2.3__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. prefect_databricks-0.2.4/PKG-INFO +210 -0
  2. prefect_databricks-0.2.4/README.md +172 -0
  3. prefect_databricks-0.2.4/prefect_databricks/__init__.py +1 -0
  4. prefect_databricks-0.2.4/prefect_databricks/_version.py +16 -0
  5. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks/credentials.py +6 -5
  6. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks/flows.py +11 -225
  7. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks/jobs.py +1 -6
  8. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks/models/jobs.py +3 -21
  9. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks/rest.py +9 -5
  10. prefect_databricks-0.2.4/prefect_databricks/schemas/jobs-2.1-aws.yaml +4199 -0
  11. prefect_databricks-0.2.4/prefect_databricks/schemas/original/jobs-2.1-aws.yaml +4184 -0
  12. prefect_databricks-0.2.4/prefect_databricks.egg-info/PKG-INFO +210 -0
  13. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks.egg-info/SOURCES.txt +5 -9
  14. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks.egg-info/requires.txt +9 -11
  15. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks.egg-info/top_level.txt +0 -1
  16. prefect_databricks-0.2.4/pyproject.toml +79 -0
  17. prefect_databricks-0.2.4/setup.cfg +4 -0
  18. prefect_databricks-0.2.4/tests/conftest.py +23 -0
  19. prefect_databricks-0.2.4/tests/mock_schema.yaml +31 -0
  20. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/tests/test_block_standards.py +1 -0
  21. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/tests/test_credentials.py +0 -1
  22. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/tests/test_flows.py +25 -312
  23. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/tests/test_jobs.py +0 -1
  24. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/tests/test_rest.py +1 -7
  25. prefect-databricks-0.2.3/LICENSE +0 -202
  26. prefect-databricks-0.2.3/MANIFEST.in +0 -14
  27. prefect-databricks-0.2.3/PKG-INFO +0 -286
  28. prefect-databricks-0.2.3/README.md +0 -245
  29. prefect-databricks-0.2.3/prefect_databricks/__init__.py +0 -4
  30. prefect-databricks-0.2.3/prefect_databricks/_version.py +0 -21
  31. prefect-databricks-0.2.3/prefect_databricks.egg-info/PKG-INFO +0 -286
  32. prefect-databricks-0.2.3/requirements-dev.txt +0 -16
  33. prefect-databricks-0.2.3/requirements.txt +0 -1
  34. prefect-databricks-0.2.3/scripts/__init__.py +0 -0
  35. prefect-databricks-0.2.3/scripts/generate.py +0 -88
  36. prefect-databricks-0.2.3/setup.cfg +0 -43
  37. prefect-databricks-0.2.3/setup.py +0 -47
  38. prefect-databricks-0.2.3/versioneer.py +0 -2163
  39. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks/models/__init__.py +0 -0
  40. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks.egg-info/dependency_links.txt +0 -0
  41. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/prefect_databricks.egg-info/entry_points.txt +0 -0
  42. {prefect-databricks-0.2.3 → prefect_databricks-0.2.4}/tests/test_generate.py +0 -0
@@ -0,0 +1,210 @@
1
+ Metadata-Version: 2.1
2
+ Name: prefect-databricks
3
+ Version: 0.2.4
4
+ Summary: Prefect integrations with Databricks
5
+ Author-email: "Prefect Technologies, Inc." <help@prefect.io>
6
+ License: Apache License 2.0
7
+ Project-URL: Homepage, https://github.com/PrefectHQ/prefect/tree/main/src/integrations/prefect-databricks
8
+ Keywords: prefect
9
+ Classifier: Natural Language :: English
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Intended Audience :: System Administrators
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Requires-Python: >=3.8
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: prefect>=2.14.10
23
+ Provides-Extra: dev
24
+ Requires-Dist: coverage; extra == "dev"
25
+ Requires-Dist: interrogate; extra == "dev"
26
+ Requires-Dist: mkdocs-gen-files; extra == "dev"
27
+ Requires-Dist: mkdocs-material; extra == "dev"
28
+ Requires-Dist: mkdocs; extra == "dev"
29
+ Requires-Dist: mkdocstrings[python]; extra == "dev"
30
+ Requires-Dist: mock; python_version < "3.8" and extra == "dev"
31
+ Requires-Dist: mypy; extra == "dev"
32
+ Requires-Dist: pillow; extra == "dev"
33
+ Requires-Dist: pre-commit; extra == "dev"
34
+ Requires-Dist: pytest-asyncio; extra == "dev"
35
+ Requires-Dist: pytest; extra == "dev"
36
+ Requires-Dist: pytest-xdist; extra == "dev"
37
+ Requires-Dist: respx; extra == "dev"
38
+
39
+ # prefect-databricks
40
+
41
+ Visit the full docs [here](https://PrefectHQ.github.io/prefect-databricks) to see additional examples and the API reference.
42
+
43
+ <p align="center">
44
+ <a href="https://pypi.python.org/pypi/prefect-databricks/" alt="PyPI version">
45
+ <img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-databricks?color=0052FF&labelColor=090422"></a>
46
+ <a href="https://pepy.tech/badge/prefect-databricks/" alt="Downloads">
47
+ <img src="https://img.shields.io/pypi/dm/prefect-databricks?color=0052FF&labelColor=090422" /></a>
48
+ <a href="https://github.com/PrefectHQ/prefect-databricks/pulse" alt="Activity">
49
+ </p>
50
+
51
+ ## Welcome!
52
+
53
+ Prefect integrations for interacting with Databricks
54
+
55
+ The tasks within this collection were created by a code generator using the service's OpenAPI spec.
56
+
57
+ The service's REST API documentation can be found [here](https://docs.databricks.com/dev-tools/api/latest/index.html).
58
+
59
+ ## Getting Started
60
+
61
+ ### Python setup
62
+
63
+ Requires an installation of Python 3.7+.
64
+
65
+ We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.
66
+
67
+ These tasks are designed to work with Prefect 2. For more information about how to use Prefect, please refer to the [Prefect documentation](https://orion-docs.prefect.io/).
68
+
69
+ ### Installation
70
+
71
+ Install `prefect-databricks` with `pip`:
72
+
73
+ ```bash
74
+ pip install prefect-databricks
75
+ ```
76
+
77
+ A list of available blocks in `prefect-databricks` and their setup instructions can be found [here](https://PrefectHQ.github.io/prefect-databricks/#blocks-catalog).
78
+
79
+ ### Lists jobs on the Databricks instance
80
+
81
+ ```python
82
+ from prefect import flow
83
+ from prefect_databricks import DatabricksCredentials
84
+ from prefect_databricks.jobs import jobs_list
85
+
86
+
87
+ @flow
88
+ def example_execute_endpoint_flow():
89
+ databricks_credentials = DatabricksCredentials.load("my-block")
90
+ jobs = jobs_list(
91
+ databricks_credentials,
92
+ limit=5
93
+ )
94
+ return jobs
95
+
96
+ example_execute_endpoint_flow()
97
+ ```
98
+
99
+ ### Use `with_options` to customize options on any existing task or flow
100
+
101
+ ```python
102
+ custom_example_execute_endpoint_flow = example_execute_endpoint_flow.with_options(
103
+ name="My custom flow name",
104
+ retries=2,
105
+ retry_delay_seconds=10,
106
+ )
107
+ ```
108
+
109
+ ### Launch a new cluster and run a Databricks notebook
110
+
111
+ Notebook named `example.ipynb` on Databricks which accepts a name parameter:
112
+
113
+ ```python
114
+ name = dbutils.widgets.get("name")
115
+ message = f"Don't worry {name}, I got your request! Welcome to prefect-databricks!"
116
+ print(message)
117
+ ```
118
+
119
+ Prefect flow that launches a new cluster to run `example.ipynb`:
120
+
121
+ ```python
122
+ from prefect import flow
123
+ from prefect_databricks import DatabricksCredentials
124
+ from prefect_databricks.jobs import jobs_runs_submit
125
+ from prefect_databricks.models.jobs import (
126
+ AutoScale,
127
+ AwsAttributes,
128
+ JobTaskSettings,
129
+ NotebookTask,
130
+ NewCluster,
131
+ )
132
+
133
+
134
+ @flow
135
+ def jobs_runs_submit_flow(notebook_path, **base_parameters):
136
+ databricks_credentials = DatabricksCredentials.load("my-block")
137
+
138
+ # specify new cluster settings
139
+ aws_attributes = AwsAttributes(
140
+ availability="SPOT",
141
+ zone_id="us-west-2a",
142
+ ebs_volume_type="GENERAL_PURPOSE_SSD",
143
+ ebs_volume_count=3,
144
+ ebs_volume_size=100,
145
+ )
146
+ auto_scale = AutoScale(min_workers=1, max_workers=2)
147
+ new_cluster = NewCluster(
148
+ aws_attributes=aws_attributes,
149
+ autoscale=auto_scale,
150
+ node_type_id="m4.large",
151
+ spark_version="10.4.x-scala2.12",
152
+ spark_conf={"spark.speculation": True},
153
+ )
154
+
155
+ # specify notebook to use and parameters to pass
156
+ notebook_task = NotebookTask(
157
+ notebook_path=notebook_path,
158
+ base_parameters=base_parameters,
159
+ )
160
+
161
+ # compile job task settings
162
+ job_task_settings = JobTaskSettings(
163
+ new_cluster=new_cluster,
164
+ notebook_task=notebook_task,
165
+ task_key="prefect-task"
166
+ )
167
+
168
+ run = jobs_runs_submit(
169
+ databricks_credentials=databricks_credentials,
170
+ run_name="prefect-job",
171
+ tasks=[job_task_settings]
172
+ )
173
+
174
+ return run
175
+
176
+
177
+ jobs_runs_submit_flow("/Users/username@gmail.com/example.ipynb", name="Marvin")
178
+ ```
179
+
180
+ Note, instead of using the built-in models, you may also input valid JSON. For example, `AutoScale(min_workers=1, max_workers=2)` is equivalent to `{"min_workers": 1, "max_workers": 2}`.
181
+
182
+ For more tips on how to use tasks and flows in a Collection, check out [Using Collections](https://orion-docs.prefect.io/collections/usage/)!
183
+
184
+ ## Resources
185
+
186
+ If you encounter any bugs while using `prefect-databricks`, feel free to open an issue in the [prefect-databricks](https://github.com/PrefectHQ/prefect-databricks) repository.
187
+
188
+ If you have any questions or issues while using `prefect-databricks`, you can find help in either the [Prefect Discourse forum](https://discourse.prefect.io/) or the [Prefect Slack community](https://prefect.io/slack).
189
+
190
+ Feel free to star or watch [`prefect-databricks`](https://github.com/PrefectHQ/prefect-databricks) for updates too!
191
+
192
+ ## Contributing
193
+
194
+ If you'd like to help contribute to fix an issue or add a feature to `prefect-databricks`, please [propose changes through a pull request from a fork of the repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).
195
+
196
+ Here are the steps:
197
+ 1. [Fork the repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository)
198
+ 2. [Clone the forked repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#cloning-your-forked-repository)
199
+ 3. Install the repository and its dependencies:
200
+ ```
201
+ pip install -e ".[dev]"
202
+ ```
203
+ 4. Make desired changes
204
+ 5. Add tests
205
+ 6. Insert an entry to [CHANGELOG.md](https://github.com/PrefectHQ/prefect-databricks/blob/main/CHANGELOG.md)
206
+ 7. Install `pre-commit` to perform quality checks prior to commit:
207
+ ```
208
+ pre-commit install
209
+ ```
210
+ 8. `git commit`, `git push`, and create a pull request
@@ -0,0 +1,172 @@
1
+ # prefect-databricks
2
+
3
+ Visit the full docs [here](https://PrefectHQ.github.io/prefect-databricks) to see additional examples and the API reference.
4
+
5
+ <p align="center">
6
+ <a href="https://pypi.python.org/pypi/prefect-databricks/" alt="PyPI version">
7
+ <img alt="PyPI" src="https://img.shields.io/pypi/v/prefect-databricks?color=0052FF&labelColor=090422"></a>
8
+ <a href="https://pepy.tech/badge/prefect-databricks/" alt="Downloads">
9
+ <img src="https://img.shields.io/pypi/dm/prefect-databricks?color=0052FF&labelColor=090422" /></a>
10
+ <a href="https://github.com/PrefectHQ/prefect-databricks/pulse" alt="Activity">
11
+ </p>
12
+
13
+ ## Welcome!
14
+
15
+ Prefect integrations for interacting with Databricks
16
+
17
+ The tasks within this collection were created by a code generator using the service's OpenAPI spec.
18
+
19
+ The service's REST API documentation can be found [here](https://docs.databricks.com/dev-tools/api/latest/index.html).
20
+
21
+ ## Getting Started
22
+
23
+ ### Python setup
24
+
25
+ Requires an installation of Python 3.7+.
26
+
27
+ We recommend using a Python virtual environment manager such as pipenv, conda or virtualenv.
28
+
29
+ These tasks are designed to work with Prefect 2. For more information about how to use Prefect, please refer to the [Prefect documentation](https://orion-docs.prefect.io/).
30
+
31
+ ### Installation
32
+
33
+ Install `prefect-databricks` with `pip`:
34
+
35
+ ```bash
36
+ pip install prefect-databricks
37
+ ```
38
+
39
+ A list of available blocks in `prefect-databricks` and their setup instructions can be found [here](https://PrefectHQ.github.io/prefect-databricks/#blocks-catalog).
40
+
41
+ ### Lists jobs on the Databricks instance
42
+
43
+ ```python
44
+ from prefect import flow
45
+ from prefect_databricks import DatabricksCredentials
46
+ from prefect_databricks.jobs import jobs_list
47
+
48
+
49
+ @flow
50
+ def example_execute_endpoint_flow():
51
+ databricks_credentials = DatabricksCredentials.load("my-block")
52
+ jobs = jobs_list(
53
+ databricks_credentials,
54
+ limit=5
55
+ )
56
+ return jobs
57
+
58
+ example_execute_endpoint_flow()
59
+ ```
60
+
61
+ ### Use `with_options` to customize options on any existing task or flow
62
+
63
+ ```python
64
+ custom_example_execute_endpoint_flow = example_execute_endpoint_flow.with_options(
65
+ name="My custom flow name",
66
+ retries=2,
67
+ retry_delay_seconds=10,
68
+ )
69
+ ```
70
+
71
+ ### Launch a new cluster and run a Databricks notebook
72
+
73
+ Notebook named `example.ipynb` on Databricks which accepts a name parameter:
74
+
75
+ ```python
76
+ name = dbutils.widgets.get("name")
77
+ message = f"Don't worry {name}, I got your request! Welcome to prefect-databricks!"
78
+ print(message)
79
+ ```
80
+
81
+ Prefect flow that launches a new cluster to run `example.ipynb`:
82
+
83
+ ```python
84
+ from prefect import flow
85
+ from prefect_databricks import DatabricksCredentials
86
+ from prefect_databricks.jobs import jobs_runs_submit
87
+ from prefect_databricks.models.jobs import (
88
+ AutoScale,
89
+ AwsAttributes,
90
+ JobTaskSettings,
91
+ NotebookTask,
92
+ NewCluster,
93
+ )
94
+
95
+
96
+ @flow
97
+ def jobs_runs_submit_flow(notebook_path, **base_parameters):
98
+ databricks_credentials = DatabricksCredentials.load("my-block")
99
+
100
+ # specify new cluster settings
101
+ aws_attributes = AwsAttributes(
102
+ availability="SPOT",
103
+ zone_id="us-west-2a",
104
+ ebs_volume_type="GENERAL_PURPOSE_SSD",
105
+ ebs_volume_count=3,
106
+ ebs_volume_size=100,
107
+ )
108
+ auto_scale = AutoScale(min_workers=1, max_workers=2)
109
+ new_cluster = NewCluster(
110
+ aws_attributes=aws_attributes,
111
+ autoscale=auto_scale,
112
+ node_type_id="m4.large",
113
+ spark_version="10.4.x-scala2.12",
114
+ spark_conf={"spark.speculation": True},
115
+ )
116
+
117
+ # specify notebook to use and parameters to pass
118
+ notebook_task = NotebookTask(
119
+ notebook_path=notebook_path,
120
+ base_parameters=base_parameters,
121
+ )
122
+
123
+ # compile job task settings
124
+ job_task_settings = JobTaskSettings(
125
+ new_cluster=new_cluster,
126
+ notebook_task=notebook_task,
127
+ task_key="prefect-task"
128
+ )
129
+
130
+ run = jobs_runs_submit(
131
+ databricks_credentials=databricks_credentials,
132
+ run_name="prefect-job",
133
+ tasks=[job_task_settings]
134
+ )
135
+
136
+ return run
137
+
138
+
139
+ jobs_runs_submit_flow("/Users/username@gmail.com/example.ipynb", name="Marvin")
140
+ ```
141
+
142
+ Note, instead of using the built-in models, you may also input valid JSON. For example, `AutoScale(min_workers=1, max_workers=2)` is equivalent to `{"min_workers": 1, "max_workers": 2}`.
143
+
144
+ For more tips on how to use tasks and flows in a Collection, check out [Using Collections](https://orion-docs.prefect.io/collections/usage/)!
145
+
146
+ ## Resources
147
+
148
+ If you encounter any bugs while using `prefect-databricks`, feel free to open an issue in the [prefect-databricks](https://github.com/PrefectHQ/prefect-databricks) repository.
149
+
150
+ If you have any questions or issues while using `prefect-databricks`, you can find help in either the [Prefect Discourse forum](https://discourse.prefect.io/) or the [Prefect Slack community](https://prefect.io/slack).
151
+
152
+ Feel free to star or watch [`prefect-databricks`](https://github.com/PrefectHQ/prefect-databricks) for updates too!
153
+
154
+ ## Contributing
155
+
156
+ If you'd like to help contribute to fix an issue or add a feature to `prefect-databricks`, please [propose changes through a pull request from a fork of the repository](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork).
157
+
158
+ Here are the steps:
159
+ 1. [Fork the repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository)
160
+ 2. [Clone the forked repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo#cloning-your-forked-repository)
161
+ 3. Install the repository and its dependencies:
162
+ ```
163
+ pip install -e ".[dev]"
164
+ ```
165
+ 4. Make desired changes
166
+ 5. Add tests
167
+ 6. Insert an entry to [CHANGELOG.md](https://github.com/PrefectHQ/prefect-databricks/blob/main/CHANGELOG.md)
168
+ 7. Install `pre-commit` to perform quality checks prior to commit:
169
+ ```
170
+ pre-commit install
171
+ ```
172
+ 8. `git commit`, `git push`, and create a pull request
@@ -0,0 +1 @@
1
+ from .credentials import DatabricksCredentials # noqa
@@ -0,0 +1,16 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple, Union
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '0.2.4'
16
+ __version_tuple__ = version_tuple = (0, 2, 4)
@@ -3,14 +3,16 @@
3
3
  from typing import Any, Dict, Optional
4
4
 
5
5
  from httpx import AsyncClient
6
- from prefect.blocks.core import Block
7
- from pydantic import VERSION as PYDANTIC_VERSION
8
6
 
9
- if PYDANTIC_VERSION.startswith("2."):
7
+ from prefect._internal.pydantic import HAS_PYDANTIC_V2
8
+
9
+ if HAS_PYDANTIC_V2:
10
10
  from pydantic.v1 import Field, SecretStr
11
11
  else:
12
12
  from pydantic import Field, SecretStr
13
13
 
14
+ from prefect.blocks.core import Block
15
+
14
16
 
15
17
  class DatabricksCredentials(Block):
16
18
  """
@@ -31,8 +33,7 @@ class DatabricksCredentials(Block):
31
33
  """
32
34
 
33
35
  _block_type_name = "Databricks Credentials"
34
- _logo_url = "https://cdn.sanity.io/images/3ugk85nk/production/ff9a2573c23954bedd27b0f420465a55b1a99dfd-250x250.png" # noqa
35
- _documentation_url = "https://prefecthq.github.io/prefect-databricks/credentials/#prefect_databricks.credentials.DatabricksCredentials" # noqa
36
+ _logo_url = "https://images.ctfassets.net/gm98wzqotmnx/5GTHI1PH2dTiantfps6Fnc/1c750fab7f4c14ea1b93a62b9fea6a94/databricks_logo_icon_170295.png?h=250" # noqa
36
37
 
37
38
  databricks_instance: str = Field(
38
39
  default=...,