pierrejeambrun commented on code in PR #43015: URL: https://github.com/apache/airflow/pull/43015#discussion_r1800666224
########## airflow/api_fastapi/app.py: ########## @@ -44,20 +44,46 @@ def init_dag_bag(app: FastAPI) -> None: app.state.dag_bag = get_dag_bag() -def create_app() -> FastAPI: +def create_task_api_app(app: FastAPI) -> None: + """Create FastAPI app for task API.""" + from airflow.api_fastapi.views.task_sdk import task_sdk_router + + task_api_app = FastAPI( + title="Airflow Task API", + description="The private Airflow Task API.", + include_in_schema=False, + ) + + task_api_app.include_router(task_sdk_router) + app.mount("/task", task_api_app) + + +def create_app(apps: list[str] | None = None) -> FastAPI: from airflow.configuration import conf + # TODO: Need to figure out how to get the 'apps' from the command line + # and pass it to the create_app function + # Passing it to the gunicorn command does not seem straightforward + # One possible option is to pass via environment variable (--env to gunicorn) + # https://docs.gunicorn.org/en/stable/settings.html#raw-env Review Comment: Yes, or we can create a wrapper function that does the argparsing maybe ? ########## airflow/cli/commands/fastapi_api_command.py: ########## @@ -101,6 +102,8 @@ def fastapi_api(args): ) pid_file, _, _, _ = setup_locations("fastapi-api", pid=args.pid) + + # TODO: Need to pass "apps" to create_app somehow Review Comment: I saw something like this to pass args to the function called, that might help, I haven't tested it: ``` gunicorn 'mypackage:build_app(foo="bar")' ``` Here https://stackoverflow.com/questions/8495367/using-additional-command-line-arguments-with-gunicorn ########## airflow/api_fastapi/app.py: ########## @@ -44,20 +44,46 @@ def init_dag_bag(app: FastAPI) -> None: app.state.dag_bag = get_dag_bag() -def create_app() -> FastAPI: +def create_task_api_app(app: FastAPI) -> None: + """Create FastAPI app for task API.""" + from airflow.api_fastapi.views.task_sdk import task_sdk_router + + task_api_app = FastAPI( + title="Airflow Task API", + description="The private Airflow Task API.", + include_in_schema=False, + ) + + task_api_app.include_router(task_sdk_router) + app.mount("/task", task_api_app) + + +def create_app(apps: list[str] | None = None) -> FastAPI: from airflow.configuration import conf + # TODO: Need to figure out how to get the 'apps' from the command line + # and pass it to the create_app function + # Passing it to the gunicorn command does not seem straightforward + # One possible option is to pass via environment variable (--env to gunicorn) + # https://docs.gunicorn.org/en/stable/settings.html#raw-env Review Comment: Yes, or we can create a wrapper function that does the argparsing maybe ? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org