- Implemented main application structure with App and View components. - Integrated React Markdown for rendering Markdown content. - Added API function to fetch Markdown content from the backend. - Created a custom Chakra UI theme to align with Airflow's design. - Configured Vite for building the application with appropriate asset paths. - Included a sample Markdown file for initial content display. - Set up TypeScript configuration for better development experience.
2.9 KiB
2.9 KiB
Building the Plugin
You can build the plugin into a wheel file using any PEP-517 compatible build frontend. The build process will automatically:
- Install UI dependencies using pnpm
- Build the React frontend
- Package everything into a wheel file
This is handled by a custom Hatch build hook (hatch_build.py).
Example build commands
# Using uv (recommended)
uv build
# Or using pip
pip wheel .
# Or using hatch directly
hatch build
The build process will fail if pnpm is not installed or if the UI build fails.
Quick Test Checklist
After building, you can quickly verify that the UI static files are included in the wheel:
# one-liner smoke test
rm -rf ui/dist && uv build
unzip -l dist/airflow_markdown_view_plugin-*.whl | grep 'ui/dist/index.*.js'
If the grep shows your JS bundles, you’re golden. If not, the hook didn’t run—fix it before shipping.
Markdown View Airflow Plugin
This plugin allows users to render Markdown content from a view.md file directly within the Airflow UI.
Features
- Displays content from a
markdown_view_plugin/view.mdfile. - Uses FastAPI for the backend and React/Vite for the frontend.
- Integrates with Airflow's UI theme, including light/dark mode support.
- Provides a theme toggle button within the plugin's view.
Setup
- Place the Plugin: Put the entire
markdown_view_plugindirectory into your Airflowpluginsfolder. - Install UI Dependencies: Navigate to the
markdown_view_plugin/uidirectory and run:pnpm install - Build the UI: After installing dependencies, build the React frontend:
This will create a
pnpm run builddistfolder insidemarkdown_view_plugin/ui. - Restart Airflow Webserver: After adding the plugin and building the UI, restart your Airflow webserver and scheduler.
- Access the Plugin: In the Airflow UI, navigate to the "Plugins" menu. You should find a link to the "Markdown View" (the exact name and category might depend on future menu link configuration in
markdown_view_plugin.py). Clicking this link will take you to the plugin's page.
Customization
- To change the displayed content, edit the
markdown_view_plugin/view.mdfile. - The UI can be further customized by modifying the React components in
markdown_view_plugin/ui/src/. - The backend logic is in
markdown_view_plugin/markdown_view_plugin.py.
Development
- Backend: The FastAPI application is defined in
markdown_view_plugin.py. - Frontend: The React/Vite application is in the
markdown_view_plugin/ui/directory.- To run the frontend in development mode (with hot reloading), navigate to
markdown_view_plugin/uiand runpnpm run dev. - Ensure your
vite.config.tshas the correctbasepath and any necessary proxy configurations if you are developing against a running Airflow instance.
- To run the frontend in development mode (with hot reloading), navigate to