Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
343 lines (315 loc) · 11.5 KB
/
Copy pathpyproject.toml
File metadata and controls
343 lines (315 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "astronomer-cosmos"
dynamic = ["version"]
description = "Orchestrate your dbt projects in Airflow"
readme = "README.rst"
license = "Apache-2.0"
requires-python = ">=3.11"
authors = [{ name = "Astronomer", email = "humans@astronomer.io" }]
keywords = ["airflow", "apache-airflow", "astronomer", "dags", "dbt", "dbt-core", "dbt-fusion"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Apache Airflow",
"Framework :: Apache Airflow :: Provider",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = [
"aenum",
"attrs",
"apache-airflow>=2.11.0",
"deprecation", # Python 3.13 exposes a deprecated operator, we can remove this dependency in the future
"Jinja2>=3.0.0",
"msgpack",
"packaging>=22.0",
"virtualenv",
"openlineage-integration-common", # Without this dependency, Airflow datasets/assets don't work
]
[project.optional-dependencies]
dbt-all = [
"dbt-athena",
"dbt-bigquery",
"dbt-clickhouse",
# The dbt-databricks:1.9.0 version causes a dependency conflict with
# the Pydantic version required by Airflow (version > 2.7)
# See: https://github.com/astronomer/astronomer-cosmos/issues/1379
"dbt-databricks!=1.9.0",
"dbt-duckdb",
"dbt-exasol",
"dbt-mysql",
"dbt-oracle",
"dbt-postgres",
"dbt-redshift",
"dbt-snowflake",
"dbt-starrocks",
"dbt-spark",
"dbt-sqlserver",
"dbt-teradata",
"dbt-vertica",
]
dbt-athena = ["dbt-athena-community", "apache-airflow-providers-amazon>=8.0.0"]
dbt-bigquery = ["dbt-bigquery"]
dbt-clickhouse = ["dbt-clickhouse"]
dbt-databricks = ["dbt-databricks"]
dbt-duckdb = ["dbt-duckdb", "airflow-provider-duckdb>=0.2.0"]
dbt-exasol = ["dbt-exasol"]
dbt-loom = ["dbt-loom"]
# Not part of ``dbt-all``: dbt-oss and dbt-core 1.x both provide the ``dbt`` package and cannot be installed together.
dbt-oss = ["dbt-oss>=2,<3"]
dbt-mysql = ["dbt-mysql"]
dbt-oracle = ["dbt-oracle"]
dbt-postgres = ["dbt-postgres"]
dbt-redshift = ["dbt-redshift"]
dbt-snowflake = ["dbt-snowflake"]
dbt-starrocks = ["dbt-starrocks"]
dbt-spark = ["dbt-spark"]
dbt-sqlserver = ["dbt-sqlserver"]
dbt-teradata = ["dbt-teradata"]
dbt-vertica = ["dbt-vertica<=1.5.4"]
openlineage = ["openlineage-integration-common!=1.15.0", "apache-airflow-providers-openlineage"]
amazon = [
"apache-airflow-providers-amazon[s3fs]>=3.0.0",
]
# Due to issue https://github.com/fsspec/gcsfs/issues/664
google = ["apache-airflow-providers-google>=10.17.0", "gcsfs<2025.3.0"]
microsoft = ["apache-airflow-providers-microsoft-azure>=8.5.0"]
# Not part of ``all``: the provider needs newer versions than the Airflow constraint files pin.
ai = ["apache-airflow-providers-common-ai[sql]>=1.0.0"]
all = [
"astronomer-cosmos[dbt-all]",
"astronomer-cosmos[openlineage]",
"astronomer-cosmos[amazon]",
"astronomer-cosmos[google]",
"astronomer-cosmos[microsoft]",
"astronomer-cosmos[dbt-duckdb]"
]
docs = [
"sphinx",
"pydata-sphinx-theme>=0.16.0",
"sphinx-autobuild",
"sphinx-autoapi",
"apache-airflow-providers-cncf-kubernetes>=7.14.0",
]
docker = [
"apache-airflow-providers-docker>=3.5.0",
]
kubernetes = [
"apache-airflow-providers-cncf-kubernetes>=7.14.0",
]
aws_eks = [
"apache-airflow-providers-amazon>=8.0.0",
]
aws-ecs = [
"apache-airflow-providers-amazon>=8.0.0",
]
azure-container-instance = [
"apache-airflow-providers-microsoft-azure>=8.5.0",
]
gcp-cloud-run-job = [
"apache-airflow-providers-google>=10.11.0",
]
[project.entry-points.apache_airflow_provider]
provider_info = "cosmos.provider_info:get_provider_info"
[project.entry-points.'airflow.policy']
watcher_retry_policy = 'cosmos.plugin.cluster_policy'
[project.entry-points."airflow.plugins"]
cosmos = "cosmos.plugin:CosmosPlugin"
[project.urls]
Homepage = "https://github.com/astronomer/astronomer-cosmos"
Documentation = "https://astronomer.github.io/astronomer-cosmos"
"Source code" = "https://github.com/astronomer/astronomer-cosmos"
[tool.hatch.version]
path = "cosmos/__init__.py"
[tool.hatch.build.targets.sdist]
include = ["/cosmos"]
[tool.hatch.build.targets.wheel]
packages = ["/cosmos"]
######################################
# TESTING
######################################
[tool.hatch.envs.tests]
dependencies = [
# do not install Airflow dependencies here!
# we need to use constraints and we're doing this in the `pre-install-commands`
"packaging>=22.0",
"pytest>=6.0",
"pytest-split",
"pytest-dotenv",
"pytest-rerunfailures",
"pytest-timeout",
"requests-mock",
"pytest-cov",
"pytest-describe",
"sqlalchemy-stubs", # Change when sqlalchemy is upgraded https://docs.sqlalchemy.org/en/14/orm/extensions/mypy.html
"pre-commit",
"types-PyYAML",
"types-attrs",
"types-pytz",
"types-requests",
"types-python-dateutil",
"Werkzeug<3.0.0",
"pytest-asyncio",
"orjson",
# Needed by the regression test for issue #2620: the test exercises
# airflow.sentry's module-level ConfiguredSentry() path, which only
# runs when sentry_sdk is importable.
"sentry-sdk",
]
pre-install-commands = ["sh scripts/test/pre-install-airflow.sh {matrix:airflow} {matrix:python} {matrix:dbt}"]
[[tool.hatch.envs.tests.matrix]]
python = ["3.11", "3.12", "3.13", "3.14"]
airflow = ["2.11", "3.0", "3.1", "3.2", "3.3", "3.4"]
dbt = ["1.8", "1.9", "1.10", "1.11", "1.12", "2.0-dbt-fusion", "2.0-dbt-oss"]
[tool.hatch.envs.tests.overrides]
matrix.airflow.dependencies = [
# Known issue: https://github.com/zmievsa/cadwyn/issues/283
{ value = "typing-extensions!=4.14.0", if = ["3.0"] }
]
[tool.hatch.envs.tests.scripts]
freeze = "pip freeze"
test = 'sh scripts/test/unit.sh'
test-cov = 'sh scripts/test/unit-cov.sh'
test-integration-setup = 'sh scripts/test/integration-setup.sh {matrix:dbt}'
test-integration = 'sh scripts/test/integration.sh {args}'
test-kubernetes = "sh scripts/test/integration-kubernetes.sh"
test-kubernetes-setup = "sh scripts/test/kubernetes-setup.sh {matrix:dbt}"
test-kubernetes-dbt-oss = "sh scripts/test/integration-kubernetes-dbt-oss.sh"
test-dbt-oss-setup = 'sh scripts/test/install-dbt-oss.sh {matrix:dbt}'
test-integration-dbt-oss-setup = [
'sh scripts/test/integration-dbtf-setup.sh',
'sh scripts/test/install-dbt-oss.sh {matrix:dbt}',
# test_dbt_dag_with_watcher_and_subprocess runs dbt from venv-subprocess/, a dbt 1.x environment with only the Postgres
# adapter. Add the BigQuery one so it can run here. It checks Cosmos' subprocess mode on BigQuery, not dbt-oss itself.
'venv-subprocess/bin/pip install -U "dbt-core<2.0" dbt-bigquery',
]
test-integration-dbtf-setup = 'sh scripts/test/integration-dbtf-setup.sh'
test-integration-dbtf = 'sh scripts/test/integration-dbtf.sh'
test-integration-dbt-1-8 = 'sh scripts/test/integration-dbt-1-8.sh'
test-integration-dbt-async = 'sh scripts/test/integration-dbt-async.sh {matrix:dbt}'
test-integration-dbt-loom = 'sh scripts/test/integration-dbt-loom.sh {matrix:dbt}'
test-integration-expensive = 'sh scripts/test/integration-expensive.sh'
test-integration-warehouse = 'sh scripts/test/integration-warehouse.sh {args}'
test-integration-warehouse-setup = 'sh scripts/test/integration-warehouse-setup.sh {matrix:airflow} {matrix:dbt}'
test-telemetry = 'sh scripts/test/telemetry.sh'
test-performance = 'sh scripts/test/performance.sh'
test-performance-setup = 'sh scripts/test/performance-setup.sh {matrix:dbt}'
type-check = "pre-commit run mypy --files cosmos/**/*"
[tool.pytest.ini_options]
addopts = "--ignore-glob=**/dbt_packages/*"
filterwarnings = ["ignore::DeprecationWarning"]
minversion = "6.0"
markers = ["integration", "perf", "dbtfusion"]
######################################
# DOCS
######################################
[tool.hatch.envs.docs]
dependencies = [
"aenum",
"msgpack",
"apache-airflow",
"pydata-sphinx-theme>=0.16.0",
"sphinx",
"sphinx-autoapi",
"sphinx-autobuild",
"sphinx-reredirects",
"sphinxcontrib.mermaid",
]
[tool.hatch.envs.docs.scripts]
build = "sphinx-build -b html docs docs/_build --fail-on-warning"
serve = "sphinx-autobuild docs docs/_build"
# Serve without auto-reload: build once, then serve static files on port 8000
serve-no-reload = "sphinx-build -b html docs docs/_build && python -m http.server 8000 --bind 127.0.0.1 --directory docs/_build"
######################################
# THIRD PARTY TOOLS
######################################
[tool.black]
line-length = 120
target-version = ["py311", "py312", "py313"]
[tool.coverage.run]
omit = [
"cosmos/airflow/_override.py"
]
[tool.isort]
profile = "black"
known_third_party = ["airflow", "jinja2"]
[tool.mypy]
strict = true
ignore_missing_imports = true
no_warn_unused_ignores = false
[tool.ruff]
line-length = 120
[tool.ruff.lint]
select = ["C901", "D300", "I", "F", "TID253"]
ignore = ["F541"]
[tool.ruff.lint.mccabe]
max-complexity = 10
[tool.ruff.lint.flake8-tidy-imports]
# Block module-level imports of optional / heavy / provider-specific
# dependencies so they don't become hard runtime requirements for every
# Cosmos user. Preferred patterns, in order of preference:
# 1. import inside the function/method that uses the dependency;
# 2. `if TYPE_CHECKING:` block for type-only imports.
# Module-scope `try: ... except ImportError:` blocks (used today by the
# Airflow 2/3 BaseHook split in `cosmos/profiles/base.py` and by the
# BigQuery async operator) are not flagged by TID253 at the time of
# writing, but the rule's handling of conditional imports may tighten
# in future ruff versions — prefer function-level imports when possible.
# See PR #1109 / #1132 for the history of why this matters.
banned-module-level-imports = [
# Airflow provider packages — each is an optional pip install
"airflow.providers.amazon",
"airflow.providers.cncf.kubernetes",
"airflow.providers.databricks",
"airflow.providers.docker",
"airflow.providers.google",
"airflow.providers.microsoft.azure",
"airflow.providers.snowflake",
# Cloud / orchestration SDKs
"azure",
"boto3",
"botocore",
"databricks.sql",
"docker",
"google.auth",
"google.cloud",
"kubernetes",
"snowflake.connector",
# Cloud filesystems
"adlfs",
"gcsfs",
"s3fs",
# Other heavy optional deps
"mlflow",
"sentry_sdk",
]
[tool.ruff.lint.per-file-ignores]
# Opt-in leaf modules — only loaded via cosmos/__init__.py's _LAZY_IMPORTS
# when the user explicitly imports the matching operator class. Eager
# provider imports here are appropriate.
"cosmos/operators/kubernetes.py" = ["TID253"]
"cosmos/operators/_k8s_common.py" = ["TID253"]
"cosmos/operators/aws_eks.py" = ["TID253"]
"cosmos/operators/aws_ecs.py" = ["TID253"]
"cosmos/operators/azure_container_instance.py" = ["TID253"]
"cosmos/operators/gcp_cloud_run_job.py" = ["TID253"]
"cosmos/operators/docker.py" = ["TID253"]
"cosmos/operators/watcher_kubernetes.py" = ["TID253"]
"cosmos/operators/_asynchronous/bigquery.py" = ["TID253"]
"cosmos/airflow/_override.py" = ["TID253"]
# Tests, dev DAGs, and CI scripts aren't shipped to users.
"tests/**/*.py" = ["TID253"]
"dev/**/*.py" = ["TID253"]
"scripts/**/*.py" = ["TID253"]
[tool.distutils.bdist_wheel]
universal = true