-
Notifications
You must be signed in to change notification settings - Fork 16.6k
Add documentation to AIP-68 dev tools #53643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking "Sign up for GitHub", you agree to our terms of service and privacy statement. We'll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pierrejeambrun
merged 2 commits into
apache:main
from
astronomer:add-documentation-to-aip-68-dev-tools
Jul 28, 2025
Merged
Add documentation to AIP-68 dev tools #53643
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,152 @@ optional parameters like the icon and url_route are passed on. | |
| Information and code samples to register ``fastapi_apps``, ``fastapi_root_middlewares``, ``external_views`` and ``react_apps`` are | ||
| available in :doc:`plugin `. | ||
|
|
||
| Developing React Applications with the Bootstrap Tool | ||
| ===================================================== | ||
|
|
||
| Airflow provides a React plugin bootstrap tool to help developers quickly create, develop, and integrate external React applications into the core UI. This is the most flexible | ||
| and recommended way to customize the Airflow UI. | ||
| This tool generates a complete React project structure that builds as a library compatible with dynamic imports and shares React instances with the host Airflow application. | ||
|
|
||
| Creating a New React Plugin Project | ||
| ----------------------------------- | ||
|
|
||
| The bootstrap tool is located in ``dev/react-plugin-tools/`` and provides a simple CLI to generate new React plugin projects: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| # Navigate to the bootstrap tool directory | ||
| cd dev/react-plugin-tools | ||
|
|
||
| # Create a new plugin project | ||
| python bootstrap.py my-awesome-plugin | ||
|
|
||
| # Or specify a custom directory | ||
| python bootstrap.py my-awesome-plugin --dir /path/to/my-projects/my-awesome-plugin | ||
|
|
||
| This generates a complete React project with Vite, TypeScript, Chakra UI integration, and proper configuration for building as a library that integrates with Airflow's UI. | ||
|
|
||
| React Development Workflow | ||
| --------------------------- | ||
|
|
||
| Once your project is generated, refer to the ``README.md`` file in your project directory for complete development instructions, including: | ||
|
|
||
| - Available development scripts (``pnpm dev``, ``pnpm build``, etc.) | ||
| - Project structure explanation | ||
| - Development workflow with hot reload | ||
| - Building for production | ||
| - Troubleshooting common React development issues | ||
|
|
||
| The generated project is pre-configured with all necessary tools and follows Airflow's UI development patterns. | ||
|
|
||
| Integrating with Airflow | ||
| ------------------------- | ||
|
|
||
| To integrate your React application with Airflow, you need to: | ||
|
|
||
| 1. **Serve the built assets** you can do that on your own infrastructure or directly within Airflow using ``fastapi_apps`` | ||
| 2. **Register the React app** using ``react_apps`` plugin configuration | ||
|
|
||
| Example Plugin Implementation | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| Create an Airflow plugin that serves your React application: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| from pathlib import Path | ||
| from fastapi import FastAPI | ||
| from starlette.staticfiles import StaticFiles | ||
| import mimetypes | ||
|
|
||
| from airflow.plugins_manager import AirflowPlugin | ||
|
|
||
| # Ensure proper MIME types for cjs files | ||
| mimetypes.add_type("application/javascript", ".cjs") | ||
|
|
||
| # Create FastAPI app to serve static files | ||
| app = FastAPI() | ||
|
|
||
| # Mount your React app's dist folder | ||
| react_app_directory = Path(__file__).parent.joinpath("my-awesome-plugin", "dist") | ||
| app.mount( | ||
| "/my-react-app", | ||
| StaticFiles(directory=react_app_directory, html=True), | ||
| name="my_react_app_static", | ||
| ) | ||
|
|
||
|
|
||
| class MyReactPlugin(AirflowPlugin): | ||
| name = "My React Plugin" | ||
|
|
||
| # Serve static files | ||
| fastapi_apps = [ | ||
| { | ||
| "app": app, | ||
| "url_prefix": "/my-plugin", | ||
| "name": "My Plugin Static Server", | ||
| } | ||
| ] | ||
|
|
||
| # Register React application | ||
| react_apps = [ | ||
| { | ||
| "name": "My Awesome React App", | ||
| "url_route": "my-awesome-app", | ||
| "bundle_url": "http://localhost:28080/my-plugin/my-react-app/main.umd.cjs", | ||
| "destination": "nav", | ||
| } | ||
| ] | ||
|
|
||
| Plugin Configuration Options | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| React apps support several configuration options, you can take a look at :doc:`plugin ` for more details. | ||
|
|
||
|
|
||
| Integration Best Practices | ||
| --------------------------- | ||
|
|
||
| The generated template follows these best practices for Airflow integration: | ||
|
|
||
| 1. **External Dependencies**: React and common libraries are marked as external to avoid conflicts with the host application | ||
| 2. **Global Naming**: Uses standardized global name (``AirflowPlugin``) for consistency | ||
| 3. **Library Build**: Configured as UMD library with proper externalization for dynamic imports | ||
| 4. **MIME Types**: Proper JavaScript MIME type handling for ``.cjs`` files because FastAPI serves them as plain text by default | ||
|
|
||
| Deployment Strategies | ||
| --------------------- | ||
|
|
||
| External Hosting | ||
| ~~~~~~~~~~~~~~~~ | ||
|
|
||
| You can also host assets on external infrastructure: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| react_apps = [ | ||
| { | ||
| "name": "My External App", | ||
| "url_route": "my-external-app", | ||
| "bundle_url": "https://my-cdn.com/main.umd.cjs", | ||
| "destination": "nav", | ||
| } | ||
| ] | ||
|
|
||
| Troubleshooting Integration Issues | ||
| ----------------------------------- | ||
|
|
||
| Common integration issues and solutions: | ||
|
|
||
| **MIME type issues** | ||
| Ensure ``.js`` and ``.cjs`` files are served with correct MIME type using ``mimetypes.add_type("application/javascript", ".cjs")``. | ||
|
|
||
| **Component not loading** | ||
| Check that the bundle URL is accessible and matches the expected format. | ||
|
|
||
| **React development issues** | ||
| Refer to the ``README.md`` file generated with your project for detailed troubleshooting of React-specific development issues. | ||
|
|
||
| Support for Airflow 2 plugins | ||
| ============================= | ||
|
|
||
|
|
@@ -61,7 +207,9 @@ Adding Rest endpoints through the blueprints is still supported, those endpoints | |
| be integrated in the FastAPI application via the WSGI Middleware and accessible | ||
| under ``/pluginsv2``. | ||
|
|
||
| It is not possible to extend the core UI, for instance by extending the base template, nonetheless extra menu items | ||
| Adding Flask-AppBuilder views ( ``appbuilder_views`` ) via the Airflow 2 is still supported in its own iframe. | ||
|
|
||
| It is not possible to extend the AF3 core UI, for instance by extending the base template, nonetheless extra menu items | ||
| of the auth managers are added to the core UI security tab and their ``href`` are rendered in iframes. | ||
| This is how the fab provider integrates users, roles, actions, resources and permissions custom views in the Airflow 3 UI. | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1982,6 +1982,7 @@ views | |
| virtualenv | ||
| virtualenvs | ||
| virtualized | ||
| Vite | ||
| vm | ||
| VolumeKmsKeyId | ||
| VolumeMount | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.