streamwright-spark 0.1.0__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.
- streamwright_spark-0.1.0/LICENSE +201 -0
- streamwright_spark-0.1.0/PKG-INFO +107 -0
- streamwright_spark-0.1.0/README.md +59 -0
- streamwright_spark-0.1.0/pyproject.toml +74 -0
- streamwright_spark-0.1.0/setup.cfg +4 -0
- streamwright_spark-0.1.0/src/streamwright/spark/__init__.py +1 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/__init__.py +14 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/__main__.py +7 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/aws_secrets.py +58 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/common.py +73 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/inputs.py +40 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/lock.py +65 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/main.py +94 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/run.py +339 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/state.py +133 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/submit_format.py +43 -0
- streamwright_spark-0.1.0/src/streamwright/spark/cli/validate.py +60 -0
- streamwright_spark-0.1.0/src/streamwright/spark/contracts/__init__.py +36 -0
- streamwright_spark-0.1.0/src/streamwright/spark/contracts/adapter.py +7 -0
- streamwright_spark-0.1.0/src/streamwright/spark/contracts/events.py +5 -0
- streamwright_spark-0.1.0/src/streamwright/spark/contracts/launcher.py +71 -0
- streamwright_spark-0.1.0/src/streamwright/spark/contracts/state.py +5 -0
- streamwright_spark-0.1.0/src/streamwright/spark/contracts/types.py +29 -0
- streamwright_spark-0.1.0/src/streamwright/spark/docs.py +19 -0
- streamwright_spark-0.1.0/src/streamwright/spark/engine/__init__.py +1 -0
- streamwright_spark-0.1.0/src/streamwright/spark/engine/executor.py +276 -0
- streamwright_spark-0.1.0/src/streamwright/spark/engine/runtime.py +154 -0
- streamwright_spark-0.1.0/src/streamwright/spark/engine/session.py +95 -0
- streamwright_spark-0.1.0/src/streamwright/spark/entrypoint.py +33 -0
- streamwright_spark-0.1.0/src/streamwright/spark/guide.md +105 -0
- streamwright_spark-0.1.0/src/streamwright/spark/io/__init__.py +1 -0
- streamwright_spark-0.1.0/src/streamwright/spark/io/capabilities.py +13 -0
- streamwright_spark-0.1.0/src/streamwright/spark/io/database_rules.py +79 -0
- streamwright_spark-0.1.0/src/streamwright/spark/io/delta.py +314 -0
- streamwright_spark-0.1.0/src/streamwright/spark/io/file_rules.py +201 -0
- streamwright_spark-0.1.0/src/streamwright/spark/io/files.py +222 -0
- streamwright_spark-0.1.0/src/streamwright/spark/io/jdbc.py +320 -0
- streamwright_spark-0.1.0/src/streamwright/spark/io/messaging.py +40 -0
- streamwright_spark-0.1.0/src/streamwright/spark/io/sql.py +56 -0
- streamwright_spark-0.1.0/src/streamwright/spark/job/__init__.py +20 -0
- streamwright_spark-0.1.0/src/streamwright/spark/job/check.py +20 -0
- streamwright_spark-0.1.0/src/streamwright/spark/job/reader.py +10 -0
- streamwright_spark-0.1.0/src/streamwright/spark/job/rules.py +325 -0
- streamwright_spark-0.1.0/src/streamwright/spark/job/runtime_rules.py +99 -0
- streamwright_spark-0.1.0/src/streamwright/spark/job/validate.py +80 -0
- streamwright_spark-0.1.0/src/streamwright/spark/launchers/__init__.py +1 -0
- streamwright_spark-0.1.0/src/streamwright/spark/launchers/common.py +83 -0
- streamwright_spark-0.1.0/src/streamwright/spark/launchers/emr_ec2.py +200 -0
- streamwright_spark-0.1.0/src/streamwright/spark/launchers/local.py +22 -0
- streamwright_spark-0.1.0/src/streamwright/spark/launchers/s3_jobs.py +25 -0
- streamwright_spark-0.1.0/src/streamwright/spark/launchers/standalone.py +58 -0
- streamwright_spark-0.1.0/src/streamwright/spark/plan/__init__.py +5 -0
- streamwright_spark-0.1.0/src/streamwright/spark/plan/analysis.py +166 -0
- streamwright_spark-0.1.0/src/streamwright/spark/plugin.py +37 -0
- streamwright_spark-0.1.0/src/streamwright/spark/runtime/__init__.py +1 -0
- streamwright_spark-0.1.0/src/streamwright/spark/runtime/definition.py +104 -0
- streamwright_spark-0.1.0/src/streamwright/spark/runtime/errors.py +11 -0
- streamwright_spark-0.1.0/src/streamwright/spark/runtime/lock.py +126 -0
- streamwright_spark-0.1.0/src/streamwright/spark/runtime/registry.py +101 -0
- streamwright_spark-0.1.0/src/streamwright/spark/schema.py +20 -0
- streamwright_spark-0.1.0/src/streamwright/spark/sdk/__init__.py +55 -0
- streamwright_spark-0.1.0/src/streamwright/spark/sdk/py.typed +0 -0
- streamwright_spark-0.1.0/src/streamwright/spark/storage/__init__.py +1 -0
- streamwright_spark-0.1.0/src/streamwright/spark/storage/exports.py +155 -0
- streamwright_spark-0.1.0/src/streamwright/spark/storage/ingest.py +175 -0
- streamwright_spark-0.1.0/src/streamwright/spark/storage/paths.py +60 -0
- streamwright_spark-0.1.0/src/streamwright_spark.egg-info/PKG-INFO +107 -0
- streamwright_spark-0.1.0/src/streamwright_spark.egg-info/SOURCES.txt +91 -0
- streamwright_spark-0.1.0/src/streamwright_spark.egg-info/dependency_links.txt +1 -0
- streamwright_spark-0.1.0/src/streamwright_spark.egg-info/entry_points.txt +14 -0
- streamwright_spark-0.1.0/src/streamwright_spark.egg-info/requires.txt +33 -0
- streamwright_spark-0.1.0/src/streamwright_spark.egg-info/top_level.txt +1 -0
- streamwright_spark-0.1.0/tests/test_adapters_contract.py +198 -0
- streamwright_spark-0.1.0/tests/test_brokers.py +92 -0
- streamwright_spark-0.1.0/tests/test_call_steps.py +221 -0
- streamwright_spark-0.1.0/tests/test_cli.py +134 -0
- streamwright_spark-0.1.0/tests/test_cli_state_core.py +72 -0
- streamwright_spark-0.1.0/tests/test_connector_contract.py +182 -0
- streamwright_spark-0.1.0/tests/test_engine_runtime.py +13 -0
- streamwright_spark-0.1.0/tests/test_entrypoint.py +31 -0
- streamwright_spark-0.1.0/tests/test_examples_core_validation.py +49 -0
- streamwright_spark-0.1.0/tests/test_exports.py +103 -0
- streamwright_spark-0.1.0/tests/test_ingest.py +1098 -0
- streamwright_spark-0.1.0/tests/test_job.py +96 -0
- streamwright_spark-0.1.0/tests/test_launchers.py +301 -0
- streamwright_spark-0.1.0/tests/test_lock_inputs.py +34 -0
- streamwright_spark-0.1.0/tests/test_naming.py +141 -0
- streamwright_spark-0.1.0/tests/test_plan.py +77 -0
- streamwright_spark-0.1.0/tests/test_refs.py +56 -0
- streamwright_spark-0.1.0/tests/test_runner.py +70 -0
- streamwright_spark-0.1.0/tests/test_schema.py +76 -0
- streamwright_spark-0.1.0/tests/test_storage.py +60 -0
- streamwright_spark-0.1.0/tests/test_writers.py +269 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: streamwright-spark
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Spark jobs for StreamWright (kind: SparkJob), attached as `sw spark ...`.
|
|
5
|
+
Author-email: Karthick Jaganathan <kjaganathan.sde@gmail.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://streamwright.web.app
|
|
8
|
+
Project-URL: Documentation, https://streamwright.web.app/docs/
|
|
9
|
+
Project-URL: Repository, https://github.com/karthick-jaganathan/streamwright-spark
|
|
10
|
+
Project-URL: Issue Tracker, https://github.com/karthick-jaganathan/streamwright-spark/issues
|
|
11
|
+
Keywords: data,pipeline,etl,spark,pyspark,deltalake,kafka,sqs,yaml,streamwright
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Database
|
|
18
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: pyyaml==6.0.2
|
|
23
|
+
Requires-Dist: streamwright~=0.1.9
|
|
24
|
+
Provides-Extra: spark
|
|
25
|
+
Requires-Dist: pyspark<3.6,>=3.5; extra == "spark"
|
|
26
|
+
Provides-Extra: delta
|
|
27
|
+
Requires-Dist: delta-spark<3.3,>=3.2; extra == "delta"
|
|
28
|
+
Provides-Extra: postgres
|
|
29
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == "postgres"
|
|
30
|
+
Provides-Extra: kafka
|
|
31
|
+
Requires-Dist: confluent-kafka>=2.4; extra == "kafka"
|
|
32
|
+
Requires-Dist: aws-msk-iam-sasl-signer-python>=1.0; extra == "kafka"
|
|
33
|
+
Provides-Extra: sqs
|
|
34
|
+
Requires-Dist: boto3>=1.34; extra == "sqs"
|
|
35
|
+
Provides-Extra: emr
|
|
36
|
+
Requires-Dist: boto3>=1.34; extra == "emr"
|
|
37
|
+
Provides-Extra: test
|
|
38
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
39
|
+
Requires-Dist: jsonschema>=4; extra == "test"
|
|
40
|
+
Provides-Extra: all
|
|
41
|
+
Requires-Dist: pyspark<3.6,>=3.5; extra == "all"
|
|
42
|
+
Requires-Dist: delta-spark<3.3,>=3.2; extra == "all"
|
|
43
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == "all"
|
|
44
|
+
Requires-Dist: confluent-kafka>=2.4; extra == "all"
|
|
45
|
+
Requires-Dist: aws-msk-iam-sasl-signer-python>=1.0; extra == "all"
|
|
46
|
+
Requires-Dist: boto3>=1.34; extra == "all"
|
|
47
|
+
Dynamic: license-file
|
|
48
|
+
|
|
49
|
+
# StreamWright Spark
|
|
50
|
+
|
|
51
|
+
[](https://pypi.org/project/streamwright-spark/)
|
|
52
|
+
[](https://pypi.org/project/streamwright-spark/)
|
|
53
|
+
[](https://pypi.org/project/streamwright-spark/)
|
|
54
|
+
[](https://streamwright.web.app/docs/spark/overview/)
|
|
55
|
+
|
|
56
|
+
`kind: SparkJob` for [StreamWright](https://pypi.org/project/streamwright/): declarative batch pipelines on Apache Spark.
|
|
57
|
+
|
|
58
|
+
- **Read and write** object storage, Delta Lake, databases, Kafka and SQS with StreamWright connectors.
|
|
59
|
+
- **Exactly-once batches**: batch state, leases and output receipts; replay-safe writes.
|
|
60
|
+
- **Any source connector** (REST APIs, ads platforms) through driver-side call steps.
|
|
61
|
+
- **Runs** locally, on Spark standalone and on AWS EMR on EC2.
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install "streamwright-spark[spark]" # needs Java 11+
|
|
67
|
+
sw connectors -i files
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Example
|
|
71
|
+
|
|
72
|
+
```yaml
|
|
73
|
+
# orders.yaml
|
|
74
|
+
kind: SparkJob
|
|
75
|
+
version: 1
|
|
76
|
+
name: daily_orders
|
|
77
|
+
connections:
|
|
78
|
+
lake: {provider: files, roots: ["/data/lake/"]}
|
|
79
|
+
steps:
|
|
80
|
+
- name: orders
|
|
81
|
+
connection: lake
|
|
82
|
+
service: object
|
|
83
|
+
method: read
|
|
84
|
+
arguments: {path: "raw/orders/*.csv", format: csv, options: {header: true}}
|
|
85
|
+
- name: daily_totals
|
|
86
|
+
sql: SELECT CAST(ordered_at AS DATE) AS day, COUNT(*) AS orders FROM orders GROUP BY 1
|
|
87
|
+
outputs:
|
|
88
|
+
- name: save_totals
|
|
89
|
+
connection: lake
|
|
90
|
+
service: object
|
|
91
|
+
method: write
|
|
92
|
+
arguments: {path: "/data/lake/curated/daily_totals/", format: parquet, mode: overwrite}
|
|
93
|
+
sql: SELECT * FROM daily_totals
|
|
94
|
+
runtime:
|
|
95
|
+
state: {sqlite: /data/state/daily_orders.db}
|
|
96
|
+
platform: {type: local}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
sw spark validate orders.yaml
|
|
101
|
+
sw spark run orders.yaml --once
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Links
|
|
105
|
+
|
|
106
|
+
[Documentation](https://streamwright.web.app/docs/spark/overview/) ·
|
|
107
|
+
[StreamWright](https://github.com/karthick-jaganathan/streamwright)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# StreamWright Spark
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/streamwright-spark/)
|
|
4
|
+
[](https://pypi.org/project/streamwright-spark/)
|
|
5
|
+
[](https://pypi.org/project/streamwright-spark/)
|
|
6
|
+
[](https://streamwright.web.app/docs/spark/overview/)
|
|
7
|
+
|
|
8
|
+
`kind: SparkJob` for [StreamWright](https://pypi.org/project/streamwright/): declarative batch pipelines on Apache Spark.
|
|
9
|
+
|
|
10
|
+
- **Read and write** object storage, Delta Lake, databases, Kafka and SQS with StreamWright connectors.
|
|
11
|
+
- **Exactly-once batches**: batch state, leases and output receipts; replay-safe writes.
|
|
12
|
+
- **Any source connector** (REST APIs, ads platforms) through driver-side call steps.
|
|
13
|
+
- **Runs** locally, on Spark standalone and on AWS EMR on EC2.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install "streamwright-spark[spark]" # needs Java 11+
|
|
19
|
+
sw connectors -i files
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Example
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
# orders.yaml
|
|
26
|
+
kind: SparkJob
|
|
27
|
+
version: 1
|
|
28
|
+
name: daily_orders
|
|
29
|
+
connections:
|
|
30
|
+
lake: {provider: files, roots: ["/data/lake/"]}
|
|
31
|
+
steps:
|
|
32
|
+
- name: orders
|
|
33
|
+
connection: lake
|
|
34
|
+
service: object
|
|
35
|
+
method: read
|
|
36
|
+
arguments: {path: "raw/orders/*.csv", format: csv, options: {header: true}}
|
|
37
|
+
- name: daily_totals
|
|
38
|
+
sql: SELECT CAST(ordered_at AS DATE) AS day, COUNT(*) AS orders FROM orders GROUP BY 1
|
|
39
|
+
outputs:
|
|
40
|
+
- name: save_totals
|
|
41
|
+
connection: lake
|
|
42
|
+
service: object
|
|
43
|
+
method: write
|
|
44
|
+
arguments: {path: "/data/lake/curated/daily_totals/", format: parquet, mode: overwrite}
|
|
45
|
+
sql: SELECT * FROM daily_totals
|
|
46
|
+
runtime:
|
|
47
|
+
state: {sqlite: /data/state/daily_orders.db}
|
|
48
|
+
platform: {type: local}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
sw spark validate orders.yaml
|
|
53
|
+
sw spark run orders.yaml --once
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Links
|
|
57
|
+
|
|
58
|
+
[Documentation](https://streamwright.web.app/docs/spark/overview/) ·
|
|
59
|
+
[StreamWright](https://github.com/karthick-jaganathan/streamwright)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "streamwright-spark"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Spark jobs for StreamWright (kind: SparkJob), attached as `sw spark ...`."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Karthick Jaganathan", email = "kjaganathan.sde@gmail.com"},
|
|
13
|
+
]
|
|
14
|
+
keywords = ["data", "pipeline", "etl", "spark", "pyspark", "deltalake", "kafka", "sqs", "yaml", "streamwright"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 4 - Beta",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Topic :: Database",
|
|
22
|
+
"Topic :: Software Development :: Libraries :: Application Frameworks",
|
|
23
|
+
]
|
|
24
|
+
requires-python = ">=3.11"
|
|
25
|
+
# Validation, planning, naming, the state store and the batch loop need only the standard library, PyYAML and
|
|
26
|
+
# streamwright (core), so `sw spark validate` runs without Spark. The connectors themselves come from the hub:
|
|
27
|
+
# `streamwright connectors install s3 postgres deltalake kafka sqs ...`. Everything else is an extra.
|
|
28
|
+
dependencies = ["pyyaml==6.0.2", "streamwright~=0.1.9"]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://streamwright.web.app"
|
|
32
|
+
Documentation = "https://streamwright.web.app/docs/"
|
|
33
|
+
Repository = "https://github.com/karthick-jaganathan/streamwright-spark"
|
|
34
|
+
"Issue Tracker" = "https://github.com/karthick-jaganathan/streamwright-spark/issues"
|
|
35
|
+
|
|
36
|
+
[project.optional-dependencies]
|
|
37
|
+
spark = ["pyspark>=3.5,<3.6"]
|
|
38
|
+
delta = ["delta-spark>=3.2,<3.3"]
|
|
39
|
+
postgres = ["psycopg[binary]>=3.1"]
|
|
40
|
+
kafka = ["confluent-kafka>=2.4", "aws-msk-iam-sasl-signer-python>=1.0"]
|
|
41
|
+
sqs = ["boto3>=1.34"]
|
|
42
|
+
emr = ["boto3>=1.34"]
|
|
43
|
+
test = ["pytest>=8", "jsonschema>=4"]
|
|
44
|
+
all = ["pyspark>=3.5,<3.6", "delta-spark>=3.2,<3.3", "psycopg[binary]>=3.1", "confluent-kafka>=2.4",
|
|
45
|
+
"aws-msk-iam-sasl-signer-python>=1.0", "boto3>=1.34"]
|
|
46
|
+
|
|
47
|
+
[project.scripts]
|
|
48
|
+
streamwright-spark = "streamwright.spark.cli:main"
|
|
49
|
+
sw-spark = "streamwright.spark.cli:main"
|
|
50
|
+
|
|
51
|
+
[project.entry-points."streamwright.job_kinds"]
|
|
52
|
+
SparkJob = "streamwright.spark.plugin:JOB_ENGINE"
|
|
53
|
+
|
|
54
|
+
[project.entry-points."streamwright.commands"]
|
|
55
|
+
spark = "streamwright.spark.cli:register"
|
|
56
|
+
|
|
57
|
+
[project.entry-points."streamwright.spark.launchers"]
|
|
58
|
+
local = "streamwright.spark.launchers.local:LocalLauncher"
|
|
59
|
+
standalone = "streamwright.spark.launchers.standalone:StandaloneLauncher"
|
|
60
|
+
emr_ec2 = "streamwright.spark.launchers.emr_ec2:EmrEc2Launcher"
|
|
61
|
+
|
|
62
|
+
[tool.setuptools]
|
|
63
|
+
# `streamwright` is a namespace package shared with streamwright (core) and its connector distributions
|
|
64
|
+
package-dir = {"" = "src"}
|
|
65
|
+
packages = [
|
|
66
|
+
"streamwright.spark", "streamwright.spark.cli", "streamwright.spark.contracts",
|
|
67
|
+
"streamwright.spark.engine", "streamwright.spark.job",
|
|
68
|
+
"streamwright.spark.launchers", "streamwright.spark.plan", "streamwright.spark.runtime",
|
|
69
|
+
"streamwright.spark.storage", "streamwright.spark.sdk", "streamwright.spark.io"
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
[tool.setuptools.package-data]
|
|
73
|
+
"streamwright.spark.sdk" = ["py.typed"]
|
|
74
|
+
"streamwright.spark" = ["guide.md"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""SparkJob engine for StreamWright."""
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""The `sw spark` command line."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
|
|
5
|
+
from streamwright.spark.cli.main import main
|
|
6
|
+
|
|
7
|
+
__all__ = ["main", "register"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def register(subparsers):
|
|
11
|
+
parser = subparsers.add_parser("spark", help="validate, run and inspect SparkJob pipelines", add_help=False)
|
|
12
|
+
parser.add_argument("-h", "--help", action="store_true")
|
|
13
|
+
parser.add_argument("arguments", nargs=argparse.REMAINDER)
|
|
14
|
+
parser.set_defaults(command_handler=lambda args: main(["--help"] if args.help else args.arguments))
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""AWS Secrets Manager access, imported only by the driver when configured."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import re
|
|
5
|
+
|
|
6
|
+
import boto3
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def read_secrets(source, job):
|
|
10
|
+
region = ((job.get("runtime") or {}).get("platform") or {}).get("region")
|
|
11
|
+
client = boto3.client("secretsmanager", region_name=region)
|
|
12
|
+
data = {}
|
|
13
|
+
|
|
14
|
+
def fetch_value(secret_id):
|
|
15
|
+
reply = client.get_secret_value(SecretId=secret_id)
|
|
16
|
+
raw = reply.get("SecretString")
|
|
17
|
+
if raw is None and "SecretBinary" in reply:
|
|
18
|
+
raw = reply["SecretBinary"].decode("utf-8")
|
|
19
|
+
return raw or ""
|
|
20
|
+
|
|
21
|
+
mapping = source.get("mapping")
|
|
22
|
+
if isinstance(mapping, dict):
|
|
23
|
+
for variable, secret_id in mapping.items():
|
|
24
|
+
raw = fetch_value(secret_id)
|
|
25
|
+
try:
|
|
26
|
+
parsed = json.loads(raw)
|
|
27
|
+
if isinstance(parsed, dict):
|
|
28
|
+
if variable in parsed:
|
|
29
|
+
data[variable] = parsed[variable]
|
|
30
|
+
elif len(parsed) == 1:
|
|
31
|
+
data[variable] = next(iter(parsed.values()))
|
|
32
|
+
else:
|
|
33
|
+
data.update(parsed)
|
|
34
|
+
else:
|
|
35
|
+
data[variable] = raw
|
|
36
|
+
except (ValueError, TypeError):
|
|
37
|
+
data[variable] = raw
|
|
38
|
+
|
|
39
|
+
secret_ids = source.get("ids") or source.get("id")
|
|
40
|
+
if isinstance(secret_ids, str):
|
|
41
|
+
secret_ids = [secret_ids]
|
|
42
|
+
elif not isinstance(secret_ids, (list, tuple)):
|
|
43
|
+
secret_ids = []
|
|
44
|
+
for secret_id in secret_ids:
|
|
45
|
+
raw = fetch_value(secret_id)
|
|
46
|
+
try:
|
|
47
|
+
parsed = json.loads(raw)
|
|
48
|
+
if isinstance(parsed, dict):
|
|
49
|
+
data.update(parsed)
|
|
50
|
+
else:
|
|
51
|
+
leaf = secret_id.split("/")[-1].split(":")[-1]
|
|
52
|
+
leaf = re.sub(r"-[A-Za-z0-9]{6}$", "", leaf)
|
|
53
|
+
data[leaf] = raw
|
|
54
|
+
except (ValueError, TypeError):
|
|
55
|
+
leaf = secret_id.split("/")[-1].split(":")[-1]
|
|
56
|
+
leaf = re.sub(r"-[A-Za-z0-9]{6}$", "", leaf)
|
|
57
|
+
data[leaf] = raw
|
|
58
|
+
return data
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""Pieces shared by the sw spark commands."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from streamwright.core.jobs.inputs import InputError as InputsError
|
|
6
|
+
from streamwright.core.jobs.inputs import parse_set
|
|
7
|
+
from streamwright.core.sdk.contract import resolve_connection
|
|
8
|
+
from streamwright.spark.contracts import Connection
|
|
9
|
+
from streamwright.spark.runtime import registry
|
|
10
|
+
|
|
11
|
+
__all__ = ["InputsError", "add_job_arguments", "connections_of", "err", "load_plugins", "parse_set"]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def err(text):
|
|
15
|
+
sys.stderr.write(text + "\n")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def add_job_arguments(parser, many=False):
|
|
19
|
+
if many:
|
|
20
|
+
parser.add_argument("job", nargs="*", metavar="PATH", help="path to the job definition YAML file(s)")
|
|
21
|
+
parser.add_argument(
|
|
22
|
+
"--job",
|
|
23
|
+
"-j",
|
|
24
|
+
action="append",
|
|
25
|
+
default=[],
|
|
26
|
+
dest="flag_jobs",
|
|
27
|
+
help="path to the job definition YAML file (can be specified multiple times)",
|
|
28
|
+
)
|
|
29
|
+
parser.add_argument("--file", "-f", action="append", default=[], dest="flag_files", help="alias for --job")
|
|
30
|
+
parser.add_argument("--pipeline", action="append", default=[], dest="flag_pipelines", help="alias for --job")
|
|
31
|
+
else:
|
|
32
|
+
parser.add_argument("job", nargs="?", metavar="JOB", help="path to the job definition YAML file or directory")
|
|
33
|
+
parser.add_argument("--job", "-j", dest="flag_job", help="path to the job definition YAML file or directory")
|
|
34
|
+
parser.add_argument("--file", "-f", dest="flag_file", help="alias for --job")
|
|
35
|
+
parser.add_argument("--pipeline", dest="flag_pipeline", help="alias for --job")
|
|
36
|
+
parser.add_argument("--config", help="a YAML file with a `config:` mapping (values for spec.config)")
|
|
37
|
+
parser.add_argument(
|
|
38
|
+
"--set",
|
|
39
|
+
action="append",
|
|
40
|
+
default=[],
|
|
41
|
+
metavar="NAME=VALUE",
|
|
42
|
+
help="override a spec.config value (e.g. --set key=value)",
|
|
43
|
+
)
|
|
44
|
+
parser.add_argument("--overlay", action="append", default=[], help="YAML merged over the job; a null deletes a key")
|
|
45
|
+
parser.add_argument(
|
|
46
|
+
"--allow-connector", action="append", default=None, metavar="PROVIDER", help="only load these providers"
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def load_plugins(allow=None):
|
|
51
|
+
"""({provider: adapter}, {platform: launcher}, problems)."""
|
|
52
|
+
adapters, problems = registry.load_all("adapter", allow)
|
|
53
|
+
launchers, more = registry.load_all("launcher")
|
|
54
|
+
return adapters, launchers, problems + more
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def connections_of(job, *, adapters=None, declared=None, config=None, secrets=None):
|
|
58
|
+
"""
|
|
59
|
+
{name: Connection} of the connections the Spark engine runs natively (a Spark adapter): `provider` apart, the rest
|
|
60
|
+
is the auth block. A provider without a Spark adapter is reached only through call steps, which resolve its
|
|
61
|
+
connection in the source engine.
|
|
62
|
+
"""
|
|
63
|
+
connections = {}
|
|
64
|
+
for name, connection in (job.get("connections") or {}).items():
|
|
65
|
+
provider = connection["provider"]
|
|
66
|
+
adapter = (adapters or {}).get(provider)
|
|
67
|
+
if adapter is None:
|
|
68
|
+
continue
|
|
69
|
+
original = (declared or job)["connections"][name]
|
|
70
|
+
auth = {key: value for key, value in original.items() if key != "provider"}
|
|
71
|
+
values = resolve_connection(adapter.definition, auth, config=config or {}, secrets=secrets or {})
|
|
72
|
+
connections[name] = Connection(name, provider, values)
|
|
73
|
+
return connections
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Config and secret values for a run, through core input handling."""
|
|
2
|
+
|
|
3
|
+
from importlib import import_module
|
|
4
|
+
|
|
5
|
+
from streamwright.core.config import inputs as core_inputs
|
|
6
|
+
from streamwright.core.jobs import inputs as job_inputs
|
|
7
|
+
from streamwright.spark.cli.common import err, parse_set
|
|
8
|
+
|
|
9
|
+
__all__ = ["InputError", "config_values", "secret_values"]
|
|
10
|
+
|
|
11
|
+
InputError = core_inputs.InputError
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def config_values(job, args):
|
|
15
|
+
provided = {}
|
|
16
|
+
if args.config:
|
|
17
|
+
provided.update(job_inputs.read_config_values(args.config))
|
|
18
|
+
provided.update(parse_set(args.set))
|
|
19
|
+
return job_inputs.effective_config(job, provided)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def secret_values(job, args):
|
|
23
|
+
"""STREAMWRIGHT_SECRET_<NAME> variables, --secrets FILE, or runtime.secrets (AWS Secrets Manager); never printed."""
|
|
24
|
+
declared = ((job.get("spec") or {}).get("secrets")) or {}
|
|
25
|
+
provided = {}
|
|
26
|
+
if getattr(args, "secrets", None):
|
|
27
|
+
provided.update(core_inputs.read_values_file(args.secrets, err))
|
|
28
|
+
for name, value in core_inputs.secrets_from_env(list(declared)).items():
|
|
29
|
+
provided.setdefault(name, value)
|
|
30
|
+
source = (job.get("runtime") or {}).get("secrets") or {}
|
|
31
|
+
if source.get("source") == "aws_secretsmanager" and len(set(provided) & set(declared)) < len(declared):
|
|
32
|
+
try:
|
|
33
|
+
aws_secrets = import_module("streamwright.spark.cli.aws_secrets")
|
|
34
|
+
except ImportError as exc:
|
|
35
|
+
if exc.name != "boto3":
|
|
36
|
+
raise
|
|
37
|
+
raise InputError('boto3 is not installed; pip install "streamwright-spark[emr]"') from exc
|
|
38
|
+
for name, value in aws_secrets.read_secrets(source, job).items():
|
|
39
|
+
provided.setdefault(name, value)
|
|
40
|
+
return job_inputs.secret_values(job, provided)
|