-
Notifications
You must be signed in to change notification settings - Fork 14.5k
/
Copy pathglobal_constants.py
491 lines (424 loc) · 14.7 KB
/
global_constants.py
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# 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.
"""
Global constants that are used by all other Breeze components.
"""
from __future__ import annotations
import json
import platform
from enum import Enum
from functools import lru_cache
from pathlib import Path
from typing import Iterable
from airflow_breeze.utils.host_info_utils import Architecture
from airflow_breeze.utils.path_utils import AIRFLOW_SOURCES_ROOT
RUNS_ON_PUBLIC_RUNNER = '["ubuntu-22.04"]'
# we should get more sophisticated logic here in the future, but for now we just check if
# we use self airflow, vm-based, amd hosted runner as a default
# TODO: when we have it properly set-up with labels we should change it to
# RUNS_ON_SELF_HOSTED_RUNNER = '["self-hosted", "airflow-runner", "vm-runner", "X64"]'
RUNS_ON_SELF_HOSTED_RUNNER = '["self-hosted", "Linux", "X64"]'
SELF_HOSTED_RUNNERS_CPU_COUNT = 8
ANSWER = ""
APACHE_AIRFLOW_GITHUB_REPOSITORY = "apache/airflow"
# Checked before putting in build cache
ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS = ["3.8", "3.9", "3.10", "3.11"]
DEFAULT_PYTHON_MAJOR_MINOR_VERSION = ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS[0]
ALLOWED_ARCHITECTURES = [Architecture.X86_64, Architecture.ARM]
# Database Backends used when starting Breeze. The "none" value means that invalid configuration
# Is set and no database started - access to a database will fail.
ALLOWED_BACKENDS = ["sqlite", "mysql", "postgres", "none"]
ALLOWED_PROD_BACKENDS = ["mysql", "postgres"]
DEFAULT_BACKEND = ALLOWED_BACKENDS[0]
TESTABLE_INTEGRATIONS = ["cassandra", "celery", "kerberos", "mongo", "pinot", "trino", "kafka", "qdrant"]
OTHER_INTEGRATIONS = ["statsd", "otel", "openlineage"]
ALLOWED_DEBIAN_VERSIONS = ["bookworm", "bullseye"]
ALL_INTEGRATIONS = sorted(
[
*TESTABLE_INTEGRATIONS,
*OTHER_INTEGRATIONS,
]
)
AUTOCOMPLETE_INTEGRATIONS = sorted(
[
"all-testable",
"all",
*ALL_INTEGRATIONS,
]
)
ALLOWED_TTY = ["auto", "enabled", "disabled"]
ALLOWED_DOCKER_COMPOSE_PROJECTS = ["breeze", "pre-commit", "docker-compose"]
# Unlike everything else, k8s versions are supported as long as 2 major cloud providers support them.
# See:
# - https://endoflife.date/amazon-eks
# - https://endoflife.date/azure-kubernetes-service
# - https://endoflife.date/google-kubernetes-engine
ALLOWED_KUBERNETES_VERSIONS = ["v1.25.16", "v1.26.13", "v1.27.10", "v1.28.6", "v1.29.1"]
ALLOWED_EXECUTORS = [
"LocalExecutor",
"KubernetesExecutor",
"CeleryExecutor",
"CeleryKubernetesExecutor",
"SequentialExecutor",
]
DEFAULT_ALLOWED_EXECUTOR = ALLOWED_EXECUTORS[0]
START_AIRFLOW_ALLOWED_EXECUTORS = ["LocalExecutor", "CeleryExecutor", "SequentialExecutor"]
START_AIRFLOW_DEFAULT_ALLOWED_EXECUTOR = START_AIRFLOW_ALLOWED_EXECUTORS[0]
SEQUENTIAL_EXECUTOR = "SequentialExecutor"
ALLOWED_KIND_OPERATIONS = ["start", "stop", "restart", "status", "deploy", "test", "shell", "k9s"]
ALLOWED_CONSTRAINTS_MODES_CI = ["constraints-source-providers", "constraints", "constraints-no-providers"]
ALLOWED_CONSTRAINTS_MODES_PROD = ["constraints", "constraints-no-providers", "constraints-source-providers"]
ALLOWED_CELERY_BROKERS = ["rabbitmq", "redis"]
DEFAULT_CELERY_BROKER = ALLOWED_CELERY_BROKERS[1]
MOUNT_SELECTED = "selected"
MOUNT_ALL = "all"
MOUNT_SKIP = "skip"
MOUNT_REMOVE = "remove"
ALLOWED_MOUNT_OPTIONS = [MOUNT_SELECTED, MOUNT_ALL, MOUNT_SKIP, MOUNT_REMOVE]
ALLOWED_POSTGRES_VERSIONS = ["12", "13", "14", "15", "16"]
# Oracle introduced new release model for MySQL
# - LTS: Long Time Support releases, new release approx every 2 year,
# with 5 year premier and 3 year extended support, no new features/removals during current LTS release.
# the first LTS release should be in summer/fall 2024.
# - Innovations: Shot living releases with short support cycle - only until next Innovation/LTS release.
# See: https://dev.mysql.com/blog-archive/introducing-mysql-innovation-and-long-term-support-lts-versions/
MYSQL_LTS_RELEASES: list[str] = []
MYSQL_OLD_RELEASES = ["8.0"]
MYSQL_INNOVATION_RELEASE = "8.3"
ALLOWED_MYSQL_VERSIONS = [*MYSQL_OLD_RELEASES, *MYSQL_LTS_RELEASES]
if MYSQL_INNOVATION_RELEASE:
ALLOWED_MYSQL_VERSIONS.append(MYSQL_INNOVATION_RELEASE)
ALLOWED_INSTALL_MYSQL_CLIENT_TYPES = ["mariadb", "mysql"]
PIP_VERSION = "24.0"
# packages that providers docs
REGULAR_DOC_PACKAGES = [
"apache-airflow",
"docker-stack",
"helm-chart",
"apache-airflow-providers",
]
@lru_cache(maxsize=None)
def all_selective_test_types() -> tuple[str, ...]:
return tuple(sorted(e.value for e in SelectiveUnitTestTypes))
class SelectiveUnitTestTypes(Enum):
ALWAYS = "Always"
API = "API"
BRANCH_PYTHON_VENV = "BranchPythonVenv"
EXTERNAL_PYTHON = "ExternalPython"
EXTERNAL_BRANCH_PYTHON = "BranchExternalPython"
CLI = "CLI"
CORE = "Core"
SERIALIZATION = "Serialization"
OTHER = "Other"
OPERATORS = "Operators"
PLAIN_ASSERTS = "PlainAsserts"
PROVIDERS = "Providers"
PYTHON_VENV = "PythonVenv"
WWW = "WWW"
ALLOWED_TEST_TYPE_CHOICES = [
"All",
"Default",
*all_selective_test_types(),
"All-Postgres",
"All-MySQL",
"All-Quarantined",
]
ALLOWED_PARALLEL_TEST_TYPE_CHOICES = [
*all_selective_test_types(),
]
@lru_cache(maxsize=None)
def all_helm_test_packages() -> list[str]:
return sorted(
[
candidate.name
for candidate in (AIRFLOW_SOURCES_ROOT / "helm_tests").iterdir()
if candidate.is_dir() and candidate.name != "__pycache__"
]
)
ALLOWED_HELM_TEST_PACKAGES = [
"all",
*all_helm_test_packages(),
]
ALLOWED_PACKAGE_FORMATS = ["wheel", "sdist", "both"]
ALLOWED_INSTALLATION_PACKAGE_FORMATS = ["wheel", "sdist"]
ALLOWED_INSTALLATION_METHODS = [".", "apache-airflow"]
ALLOWED_BUILD_CACHE = ["registry", "local", "disabled"]
ALLOWED_BUILD_PROGRESS = ["auto", "plain", "tty"]
MULTI_PLATFORM = "linux/amd64,linux/arm64"
SINGLE_PLATFORMS = ["linux/amd64", "linux/arm64"]
ALLOWED_PLATFORMS = [*SINGLE_PLATFORMS, MULTI_PLATFORM]
ALLOWED_USE_AIRFLOW_VERSIONS = ["none", "wheel", "sdist"]
ALLOWED_PYDANTIC_VERSIONS = ["v2", "v1", "none"]
ALL_HISTORICAL_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
def get_default_platform_machine() -> str:
machine = platform.uname().machine
# Some additional conversion for various platforms...
machine = {"x86_64": "amd64"}.get(machine, machine)
return machine
# Initialise base variables
DOCKER_DEFAULT_PLATFORM = f"linux/{get_default_platform_machine()}"
DOCKER_BUILDKIT = 1
SSH_PORT = "12322"
WEBSERVER_HOST_PORT = "28080"
POSTGRES_HOST_PORT = "25433"
MYSQL_HOST_PORT = "23306"
FLOWER_HOST_PORT = "25555"
REDIS_HOST_PORT = "26379"
CELERY_BROKER_URLS_MAP = {"rabbitmq": "amqp://guest:guest@rabbitmq:5672", "redis": "redis://redis:6379/0"}
SQLITE_URL = "sqlite:////root/airflow/sqlite/airflow.db"
PYTHONDONTWRITEBYTECODE = True
PRODUCTION_IMAGE = False
ALL_PYTHON_MAJOR_MINOR_VERSIONS = ["3.8", "3.9", "3.10", "3.11"]
CURRENT_PYTHON_MAJOR_MINOR_VERSIONS = ALL_PYTHON_MAJOR_MINOR_VERSIONS
CURRENT_POSTGRES_VERSIONS = ["12", "13", "14", "15", "16"]
DEFAULT_POSTGRES_VERSION = CURRENT_POSTGRES_VERSIONS[0]
USE_MYSQL_INNOVATION_RELEASE = True
if USE_MYSQL_INNOVATION_RELEASE:
CURRENT_MYSQL_VERSIONS = ALLOWED_MYSQL_VERSIONS.copy()
else:
CURRENT_MYSQL_VERSIONS = [*MYSQL_OLD_RELEASES, *MYSQL_LTS_RELEASES]
DEFAULT_MYSQL_VERSION = CURRENT_MYSQL_VERSIONS[0]
AIRFLOW_PYTHON_COMPATIBILITY_MATRIX = {
"2.0.0": ["3.6", "3.7", "3.8"],
"2.0.1": ["3.6", "3.7", "3.8"],
"2.0.2": ["3.6", "3.7", "3.8"],
"2.1.0": ["3.6", "3.7", "3.8"],
"2.1.1": ["3.6", "3.7", "3.8"],
"2.1.2": ["3.6", "3.7", "3.8", "3.9"],
"2.1.3": ["3.6", "3.7", "3.8", "3.9"],
"2.1.4": ["3.6", "3.7", "3.8", "3.9"],
"2.2.0": ["3.6", "3.7", "3.8", "3.9"],
"2.2.1": ["3.6", "3.7", "3.8", "3.9"],
"2.2.2": ["3.6", "3.7", "3.8", "3.9"],
"2.2.3": ["3.6", "3.7", "3.8", "3.9"],
"2.2.4": ["3.6", "3.7", "3.8", "3.9"],
"2.2.5": ["3.6", "3.7", "3.8", "3.9"],
"2.3.0": ["3.7", "3.8", "3.9", "3.10"],
"2.3.1": ["3.7", "3.8", "3.9", "3.10"],
"2.3.2": ["3.7", "3.8", "3.9", "3.10"],
"2.3.3": ["3.7", "3.8", "3.9", "3.10"],
"2.3.4": ["3.7", "3.8", "3.9", "3.10"],
"2.4.0": ["3.7", "3.8", "3.9", "3.10"],
"2.4.1": ["3.7", "3.8", "3.9", "3.10"],
"2.4.2": ["3.7", "3.8", "3.9", "3.10"],
"2.4.3": ["3.7", "3.8", "3.9", "3.10"],
"2.5.0": ["3.7", "3.8", "3.9", "3.10"],
"2.5.1": ["3.7", "3.8", "3.9", "3.10"],
"2.5.2": ["3.7", "3.8", "3.9", "3.10"],
"2.5.3": ["3.7", "3.8", "3.9", "3.10"],
"2.6.0": ["3.7", "3.8", "3.9", "3.10"],
"2.6.1": ["3.7", "3.8", "3.9", "3.10"],
"2.6.2": ["3.7", "3.8", "3.9", "3.10", "3.11"],
"2.6.3": ["3.7", "3.8", "3.9", "3.10", "3.11"],
"2.7.0": ["3.8", "3.9", "3.10", "3.11"],
"2.7.1": ["3.8", "3.9", "3.10", "3.11"],
"2.7.2": ["3.8", "3.9", "3.10", "3.11"],
"2.7.3": ["3.8", "3.9", "3.10", "3.11"],
}
DB_RESET = False
START_AIRFLOW = "false"
LOAD_EXAMPLES = False
LOAD_DEFAULT_CONNECTIONS = False
PRESERVE_VOLUMES = False
CLEANUP_CONTEXT = False
INIT_SCRIPT_FILE = ""
BREEZE_INIT_COMMAND = ""
DRY_RUN_DOCKER = False
INSTALL_AIRFLOW_VERSION = ""
COMMITTERS = [
"BasPH",
"Fokko",
"KevinYang21",
"Taragolis",
"XD-DENG",
"aijamalnk",
"alexvanboxel",
"amoghrajesh",
"aoen",
"artwr",
"ashb",
"bbovenzi",
"bolkedebruin",
"criccomini",
"dimberman",
"dstandish",
"eladkal",
"ephraimbuddy",
"feluelle",
"feng-tao",
"ferruzzi",
"houqp",
"hussein-awala",
"jedcunningham",
"jgao54",
"jghoman",
"jhtimmins",
"jmcarp",
"josh-fell",
"jscheffl",
"kaxil",
"leahecole",
"malthe",
"mik-laj",
"milton0825",
"mistercrunch",
"mobuchowski",
"msumit",
"o-nikolas",
"pankajastro",
"pankajkoti",
"phanikumv",
"pierrejeambrun",
"pingzh",
"potiuk",
"r39132",
"ryanahamilton",
"ryw",
"saguziel",
"sekikn",
"turbaszek",
"uranusjr",
"utkarsharma2",
"vikramkoka",
"vincbeck",
"xinbinhuang",
"yuqian90",
"zhongjiajie",
]
def get_airflow_version():
airflow_init_py_file = AIRFLOW_SOURCES_ROOT / "airflow" / "__init__.py"
airflow_version = "unknown"
with open(airflow_init_py_file) as init_file:
while line := init_file.readline():
if "__version__ = " in line:
airflow_version = line.split()[2][1:-1]
break
if airflow_version == "unknown":
raise Exception("Unable to determine Airflow version")
return airflow_version
def get_airflow_extras():
airflow_dockerfile = AIRFLOW_SOURCES_ROOT / "Dockerfile"
with open(airflow_dockerfile) as dockerfile:
for line in dockerfile.readlines():
if "ARG AIRFLOW_EXTRAS=" in line:
line = line.split("=")[1].strip()
return line.replace('"', "")
# Initialize integrations
AVAILABLE_INTEGRATIONS = ["cassandra", "kerberos", "mongo", "pinot", "celery", "statsd", "trino", "qdrant"]
ALL_PROVIDER_YAML_FILES = Path(AIRFLOW_SOURCES_ROOT, "airflow", "providers").rglob("provider.yaml")
PROVIDER_RUNTIME_DATA_SCHEMA_PATH = AIRFLOW_SOURCES_ROOT / "airflow" / "provider_info.schema.json"
with Path(AIRFLOW_SOURCES_ROOT, "generated", "provider_dependencies.json").open() as f:
PROVIDER_DEPENDENCIES = json.load(f)
# Initialize files for rebuild check
FILES_FOR_REBUILD_CHECK = [
"pyproject.toml",
"Dockerfile.ci",
".dockerignore",
"generated/provider_dependencies.json",
"scripts/docker/common.sh",
"scripts/docker/install_additional_dependencies.sh",
"scripts/docker/install_airflow.sh",
"scripts/docker/install_airflow_dependencies_from_branch_tip.sh",
"scripts/docker/install_from_docker_context_files.sh",
"scripts/docker/install_mysql.sh",
]
ENABLED_SYSTEMS = ""
CURRENT_KUBERNETES_VERSIONS = ALLOWED_KUBERNETES_VERSIONS
CURRENT_EXECUTORS = ["KubernetesExecutor"]
DEFAULT_KUBERNETES_VERSION = CURRENT_KUBERNETES_VERSIONS[0]
DEFAULT_EXECUTOR = CURRENT_EXECUTORS[0]
KIND_VERSION = "v0.21.0"
HELM_VERSION = "v3.14.0"
# Initialize image build variables - Have to check if this has to go to ci dataclass
USE_AIRFLOW_VERSION = None
GITHUB_ACTIONS = ""
ISSUE_ID = ""
NUM_RUNS = ""
MIN_DOCKER_VERSION = "24.0.0"
MIN_DOCKER_COMPOSE_VERSION = "2.20.2"
AIRFLOW_SOURCES_FROM = "."
AIRFLOW_SOURCES_TO = "/opt/airflow"
DEFAULT_EXTRAS = [
# BEGINNING OF EXTRAS LIST UPDATED BY PRE COMMIT
"aiobotocore",
"amazon",
"async",
"celery",
"cncf-kubernetes",
"common-io",
"docker",
"elasticsearch",
"ftp",
"google",
"google-auth",
"graphviz",
"grpc",
"hashicorp",
"http",
"ldap",
"microsoft-azure",
"mysql",
"odbc",
"openlineage",
"pandas",
"postgres",
"redis",
"sendgrid",
"sftp",
"slack",
"snowflake",
"ssh",
"statsd",
"virtualenv",
# END OF EXTRAS LIST UPDATED BY PRE COMMIT
]
CHICKEN_EGG_PROVIDERS = " ".join(
[
"fab",
]
)
def _exclusion(providers: Iterable[str]) -> str:
return " ".join([f"apache_airflow_providers_{provider.replace('.', '_')}*" for provider in providers])
BASE_PROVIDERS_COMPATIBILITY_CHECKS: list[dict[str, str]] = [
{
"python-version": "3.8",
"airflow-version": "2.6.0",
"remove-providers": _exclusion(["openlineage", "common.io", "cohere", "fab", "qdrant"]),
},
{
"python-version": "3.9",
"airflow-version": "2.6.0",
"remove-providers": _exclusion(["openlineage", "common.io", "fab", "qdrant"]),
},
{
"python-version": "3.8",
"airflow-version": "2.7.1",
"remove-providers": _exclusion(["common.io", "fab"]),
},
]
class GithubEvents(Enum):
PULL_REQUEST = "pull_request"
PULL_REQUEST_REVIEW = "pull_request_review"
PULL_REQUEST_TARGET = "pull_request_target"
PULL_REQUEST_WORKFLOW = "pull_request_workflow"
PUSH = "push"
SCHEDULE = "schedule"
WORKFLOW_DISPATCH = "workflow_dispatch"
WORKFLOW_RUN = "workflow_run"
@lru_cache(maxsize=None)
def github_events() -> list[str]:
return [e.value for e in GithubEvents]