File tree Expand file tree Collapse file tree 10 files changed +18
-46
lines changed
src/airflow/providers/celery/cli Expand file tree Collapse file tree 10 files changed +18
-46
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,10 @@ dependencies = [
8484 # 0.115.10 fastapi was a bad release that broke our API's and static checks.
8585 # Related fastapi issue here: https://github.com/fastapi/fastapi/discussions/13431
8686 " fastapi[standard]>=0.115.0,!=0.115.10" ,
87+ # We could get rid of flask and gunicorn if we replace serve_logs with a starlette + unicorn
88+ " flask>=2.1.1" ,
8789 " gitpython>=3.1.40" ,
90+ # We could get rid of flask and gunicorn if we replace serve_logs with a starlette + unicorn
8891 " gunicorn>=20.1.0" ,
8992 " httpx>=0.25.0" ,
9093 ' importlib_metadata>=6.5;python_version<"3.12"' ,
Original file line number Diff line number Diff line change 2929from airflow .executors .executor_loader import ExecutorLoader
3030from airflow .jobs .job import Job , run_job
3131from airflow .jobs .scheduler_job_runner import SchedulerJobRunner
32- from airflow .providers .celery .version_compat import AIRFLOW_V_3_0_PLUS
3332from airflow .utils import cli as cli_utils
3433from airflow .utils .providers_configuration_loader import providers_configuration_loaded
3534from airflow .utils .scheduler_health import serve_health_check
@@ -60,18 +59,7 @@ def scheduler(args: Namespace):
6059
6160@contextmanager
6261def _serve_logs (skip_serve_logs : bool = False ):
63- """Start serve_logs sub-process."""
64- if AIRFLOW_V_3_0_PLUS :
65- try :
66- from airflow .providers .fab .www .serve_logs import serve_logs
67- except ImportError :
68- raise ImportError (
69- "Celery requires FAB provider to be installed in order to run this command. "
70- "Please install the FAB provider by running: "
71- "pip install apache-airflow-providers-celery[fab]"
72- )
73- else :
74- from airflow .utils .serve_logs import serve_logs # type: ignore[no-redef]
62+ from airflow .utils .serve_logs import serve_logs
7563
7664 sub_proc = None
7765 executor_class , _ = ExecutorLoader .import_default_executor_cls ()
Original file line number Diff line number Diff line change 2828from airflow .configuration import conf
2929from airflow .jobs .job import Job , run_job
3030from airflow .jobs .triggerer_job_runner import TriggererJobRunner
31- from airflow .providers .celery .version_compat import AIRFLOW_V_3_0_PLUS
3231from airflow .utils import cli as cli_utils
3332from airflow .utils .providers_configuration_loader import providers_configuration_loaded
3433
3534
3635@contextmanager
3736def _serve_logs (skip_serve_logs : bool = False ) -> Generator [None , None , None ]:
3837 """Start serve_logs sub-process."""
39- if AIRFLOW_V_3_0_PLUS :
40- try :
41- from airflow .providers .fab .www .serve_logs import serve_logs
42- except ImportError :
43- raise ImportError (
44- "Celery requires FAB provider to be installed in order to run this command. "
45- "Please install the FAB provider by running: "
46- "pip install apache-airflow-providers-celery[fab]"
47- )
48- else :
49- from airflow .utils .serve_logs import serve_logs # type: ignore[no-redef]
38+ from airflow .utils .serve_logs import serve_logs
5039
5140 sub_proc = None
5241 if skip_serve_logs is False :
Original file line number Diff line number Diff line change 2121import logging
2222import os
2323import socket
24+ import sys
2425from collections import namedtuple
2526
2627import gunicorn .app .base
3233 InvalidIssuedAtError ,
3334 InvalidSignatureError ,
3435)
35- from setproctitle import setproctitle
3636from werkzeug .exceptions import HTTPException
3737
3838from airflow .api_fastapi .auth .tokens import JWTValidator , get_signing_key
@@ -169,6 +169,13 @@ def load(self):
169169
170170def serve_logs (port = None ):
171171 """Serve logs generated by Worker."""
172+ # setproctitle causes issue on Mac OS: https://github.com/benoitc/gunicorn/issues/3021
173+ os_type = sys .platform
174+ if os_type == "darwin" :
175+ logger .debug ("Mac OS detected, skipping setproctitle" )
176+ else :
177+ from setproctitle import setproctitle
178+
172179 setproctitle ("airflow serve-logs" )
173180 wsgi_app = create_app ()
174181
Original file line number Diff line number Diff line change 2525from airflow .cli import cli_parser
2626from airflow .cli .commands import scheduler_command
2727from airflow .executors import executor_loader
28- from airflow .providers .fab .www .serve_logs import serve_logs
2928from airflow .utils .scheduler_health import serve_health_check
29+ from airflow .utils .serve_logs import serve_logs
3030
3131from tests_common .test_utils .config import conf_vars
3232
Original file line number Diff line number Diff line change 2626
2727from airflow .api_fastapi .auth .tokens import JWTGenerator
2828from airflow .config_templates .airflow_local_settings import DEFAULT_LOGGING_CONFIG
29- from airflow .providers .fab .www .serve_logs import create_app
3029from airflow .utils import timezone
30+ from airflow .utils .serve_logs import create_app
3131
3232from tests_common .test_utils .config import conf_vars
3333
@@ -81,7 +81,7 @@ def sample_log(request, tmp_path):
8181 base_log_dir = Path (DEFAULT_LOGGING_CONFIG ["handlers" ]["task" ]["base_log_folder" ])
8282 else :
8383 raise ValueError (f"Unknown client fixture: { client } " )
84-
84+ base_log_dir . mkdir ( exist_ok = True , parents = True )
8585 f = base_log_dir .joinpath ("sample.log" )
8686 f .write_text (LOG_DATA )
8787 return f
Original file line number Diff line number Diff line change @@ -2157,7 +2157,7 @@ def test_upgrade_to_newer_dependencies(
21572157 ),
21582158 pytest .param (
21592159 ("providers/celery/src/airflow/providers/celery/file.py" ,),
2160- {"docs-list-as-string" : "celery cncf.kubernetes fab " },
2160+ {"docs-list-as-string" : "celery cncf.kubernetes" },
21612161 id = "Celery python files changed" ,
21622162 ),
21632163 pytest .param (
Original file line number Diff line number Diff line change @@ -75,7 +75,6 @@ You can install such cross-provider dependencies when installing from PyPI. For
7575Dependent package Extra
7676====================================================================================================================== ===================
7777`apache-airflow-providers-cncf-kubernetes <https://airflow.apache.org/docs/apache-airflow-providers-cncf-kubernetes >`_ ``cncf.kubernetes ``
78- `apache-airflow-providers-fab <https://airflow.apache.org/docs/apache-airflow-providers-fab >`_ ``fab ``
7978====================================================================================================================== ===================
8079
8180The changelog for the provider package can be found in the
Original file line number Diff line number Diff line change @@ -72,17 +72,13 @@ dependencies = [
7272"cncf.kubernetes" = [
7373 " apache-airflow-providers-cncf-kubernetes>=7.4.0" ,
7474]
75- "fab" = [
76- " apache-airflow-providers-fab>=2.0.0" ,
77- ]
7875
7976[dependency-groups ]
8077dev = [
8178 " apache-airflow" ,
8279 " apache-airflow-task-sdk" ,
8380 " apache-airflow-devel-common" ,
8481 " apache-airflow-providers-cncf-kubernetes" ,
85- " apache-airflow-providers-fab" ,
8682 # Additional devel dependencies (do not remove this line and add extra development dependencies)
8783]
8884
Original file line number Diff line number Diff line change @@ -107,17 +107,7 @@ def flower(args):
107107@contextmanager
108108def _serve_logs (skip_serve_logs : bool = False ):
109109 """Start serve_logs sub-process."""
110- if AIRFLOW_V_3_0_PLUS :
111- try :
112- from airflow .providers .fab .www .serve_logs import serve_logs
113- except ImportError :
114- raise ImportError (
115- "Celery requires FAB provider to be installed in order to run this command. "
116- "Please install the FAB provider by running: "
117- "pip install apache-airflow-providers-celery[fab]"
118- )
119- else :
120- from airflow .utils .serve_logs import serve_logs # type: ignore[no-redef]
110+ from airflow .utils .serve_logs import serve_logs
121111
122112 sub_proc = None
123113 if skip_serve_logs is False :
You can’t perform that action at this time.
0 commit comments