Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/prod-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ jobs:
shell: bash
run: rm -fv ./dist/* ./docker-context-files/*
if: inputs.upload-package-artifact == 'true'
- name: "Install prek"
uses: ./.github/actions/install-prek
id: prek
with:
python-version: ${{ matrix.python-version }}
platform: ${{ inputs.platform }}
save-cache: false
- name: "Install Breeze"
uses: ./.github/actions/breeze
if: inputs.upload-package-artifact == 'true'
Expand Down
11 changes: 9 additions & 2 deletions dev/breeze/src/airflow_breeze/commands/developer_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
DEFAULT_ALLOWED_EXECUTOR,
DEFAULT_CELERY_BROKER,
DEFAULT_PYTHON_MAJOR_MINOR_VERSION,
EDGE_EXECUTOR,
FAB_AUTH_MANAGER,
GITHUB_REPO_BRANCH_PATTERN,
MOUNT_ALL,
START_AIRFLOW_ALLOWED_EXECUTORS,
Expand All @@ -121,6 +123,7 @@
from airflow_breeze.utils.path_utils import (
AIRFLOW_ROOT_PATH,
EDGE_PLUGIN_PREK_HOOK,
FAB_AUTH_MANAGER_WWW_PREK_HOOK,
cleanup_python_generated_files,
)
from airflow_breeze.utils.platforms import get_normalized_platform
Expand Down Expand Up @@ -655,8 +658,12 @@ def start_airflow(
perform_environment_checks(quiet=False)
if use_airflow_version is None and not skip_assets_compilation:
assert_prek_installed()
# Compile edge assets as well if needed
additional_assets = [EDGE_PLUGIN_PREK_HOOK] if executor and "EdgeExecutor" in executor else []
# Compile provider assets if needed
additional_assets = []
if executor and EDGE_EXECUTOR in executor:
additional_assets.append(EDGE_PLUGIN_PREK_HOOK)
if auth_manager == FAB_AUTH_MANAGER:
additional_assets.append(FAB_AUTH_MANAGER_WWW_PREK_HOOK)
# Now with the /ui project, lets only do a static build of /www and focus on the /ui
run_compile_ui_assets(
dev=dev_mode, run_in_background=True, force_clean=False, additional_ui_hooks=additional_assets
Expand Down
6 changes: 6 additions & 0 deletions dev/breeze/src/airflow_breeze/utils/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ def find_airflow_root_path_to_operate_on() -> Path:
EDGE_PLUGIN_UI_NODE_MODULES_PATH = EDGE_PLUGIN_PATH / "node_modules"
EDGE_PLUGIN_UI_DIST_PATH = EDGE_PLUGIN_PATH / "dist"
EDGE_PLUGIN_PREK_HOOK = "compile-edge-assets"
FAB_AUTH_MANAGER_WWW_PATH = (
AIRFLOW_PROVIDERS_ROOT_PATH / "fab" / "src" / "airflow" / "providers" / "fab" / "www"
)
FAB_AUTH_MANAGER_WWW_NODE_MODULES_PATH = FAB_AUTH_MANAGER_WWW_PATH / "node_modules"
FAB_AUTH_MANAGER_WWW_DIST_PATH = FAB_AUTH_MANAGER_WWW_PATH / "static" / "dist"
FAB_AUTH_MANAGER_WWW_PREK_HOOK = "compile-fab-assets"

DAGS_PATH = AIRFLOW_ROOT_PATH / "dags"
FILES_PATH = AIRFLOW_ROOT_PATH / "files"
Expand Down
6 changes: 6 additions & 0 deletions dev/breeze/src/airflow_breeze/utils/run_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
EDGE_PLUGIN_PREK_HOOK,
EDGE_PLUGIN_UI_DIST_PATH,
EDGE_PLUGIN_UI_NODE_MODULES_PATH,
FAB_AUTH_MANAGER_WWW_DIST_PATH,
FAB_AUTH_MANAGER_WWW_NODE_MODULES_PATH,
FAB_AUTH_MANAGER_WWW_PREK_HOOK,
FAST_API_SIMPLE_AUTH_MANAGER_DIST_PATH,
FAST_API_SIMPLE_AUTH_MANAGER_NODE_MODULES_PATH,
UI_ASSET_COMPILE_LOCK,
Expand Down Expand Up @@ -511,6 +514,9 @@ def _clean_ui_assets(additional_ui_hooks: list[str]):
if EDGE_PLUGIN_PREK_HOOK in additional_ui_hooks:
shutil.rmtree(EDGE_PLUGIN_UI_NODE_MODULES_PATH, ignore_errors=True)
shutil.rmtree(EDGE_PLUGIN_UI_DIST_PATH, ignore_errors=True)
if FAB_AUTH_MANAGER_WWW_PREK_HOOK in additional_ui_hooks:
shutil.rmtree(FAB_AUTH_MANAGER_WWW_NODE_MODULES_PATH, ignore_errors=True)
shutil.rmtree(FAB_AUTH_MANAGER_WWW_DIST_PATH, ignore_errors=True)
get_console().print("[success]Cleaned ui assets[/]")


Expand Down
2 changes: 2 additions & 0 deletions providers/fab/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Do not commit hash files, this is just to speed-up local builds
www-hash.txt
1 change: 1 addition & 0 deletions providers/fab/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ repos:
- id: compile-fab-assets
name: Compile FAB provider assets
language: node
stages: ['pre-commit', 'manual']
files: ^src/airflow/providers/fab/www/
exclude: |
(?x)
Expand Down
70 changes: 70 additions & 0 deletions providers/fab/hatch_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 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.
from __future__ import annotations

import logging
import os
import shutil
from collections.abc import Callable, Iterable
from pathlib import Path
from subprocess import run
from typing import Any

from hatchling.builders.config import BuilderConfig
from hatchling.builders.plugin.interface import BuilderInterface
from hatchling.plugin.manager import PluginManager

log = logging.getLogger(__name__)
log_level = logging.getLevelName(os.getenv("CUSTOM_AIRFLOW_BUILD_LOG_LEVEL", "INFO"))
log.setLevel(log_level)


class CustomBuild(BuilderInterface[BuilderConfig, PluginManager]):
"""Custom build class for Airflow assets and git version."""

# Note that this name of the plugin MUST be `custom` - as long as we use it from custom
# hatch_build.py file and not from external plugin. See note in the:
# https://hatch.pypa.io/latest/plugins/build-hook/custom/#example
PLUGIN_NAME = "custom"

@staticmethod
def clean_dir(path: Path) -> None:
log.warning("Cleaning directory: %s", path)
shutil.rmtree(path, ignore_errors=True)

def clean(self, directory: str, versions: Iterable[str]) -> None:
work_dir = Path(self.root)
log.warning("Cleaning generated files in directory: %s", work_dir)
fab_package_src = work_dir / "src" / "airflow" / "providers" / "fab"
fab_ui_path = fab_package_src / "www"
self.clean_dir(fab_ui_path / ".pnpm-store")
self.clean_dir(fab_ui_path / "static" / "dist")
self.clean_dir(fab_ui_path / "node_modules")
(work_dir / "www-hash.txt").unlink(missing_ok=True)

def get_version_api(self) -> dict[str, Callable[..., str]]:
"""Get custom build target for standard package preparation."""
return {"standard": self.build_standard}

def build_standard(self, directory: str, artifacts: Any, **build_data: Any) -> str:
# run this in the airflow repo root
work_dir = Path(self.root).parents[1].resolve()
cmd = ["prek", "run", "compile-fab-assets", "--all-files"]
log.warning("Running command: %s", " ".join(cmd))
run(cmd, cwd=work_dir.as_posix(), check=True)
dist_path = Path(self.root) / "src" / "airflow" / "providers" / "fab" / "www" / "static" / "dist"
return dist_path.resolve().as_posix()
1 change: 1 addition & 0 deletions providers/fab/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ description: |
state: ready

source-date-epoch: 1770751867
build-system: hatchling

# Note that those versions are maintained by release manager - do not update them manually
# with the exception of case where other provider in sources has >= new provider version.
Expand Down
51 changes: 47 additions & 4 deletions providers/fab/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,18 @@
# IF YOU WANT TO MODIFY THIS FILE EXCEPT DEPENDENCIES, YOU SHOULD MODIFY THE TEMPLATE
# `pyproject_TEMPLATE.toml.jinja2` IN the `dev/breeze/src/airflow_breeze/templates` DIRECTORY
[build-system]
requires = ["flit_core==3.12.0"]
build-backend = "flit_core.buildapi"
requires = [
"GitPython==3.1.45",
"gitdb==4.0.12",
"hatchling==1.27.0",
"packaging==25.0",
"pathspec==0.12.1",
"pluggy==1.6.0",
"smmap==5.0.2",
"tomli==2.2.1; python_version < '3.11'",
"trove-classifiers==2025.9.11.17",
]
build-backend = "hatchling.build"

[project]
name = "apache-airflow-providers-fab"
Expand Down Expand Up @@ -143,5 +153,38 @@ apache-airflow-providers-standard = {workspace = true}
[project.entry-points."apache_airflow_provider"]
provider_info = "airflow.providers.fab.get_provider_info:get_provider_info"

[tool.flit.module]
name = "airflow.providers.fab"
[tool.hatch.version]
path = "src/airflow/providers/fab/__init__.py"

[tool.hatch.build.targets.sdist]
include = [
"docs",
"src/airflow/providers/fab",
"tests",
"NOTICE"
]
exclude = [
"src/airflow/__init__.py",
"src/airflow/providers/__init__.py",
"src/airflow/providers/fab/www/.pnpm-store",
"src/airflow/providers/fab/www/node_modules",
]

[tool.hatch.build.targets.custom]
path = "./hatch_build.py"

artifacts = [
"src/airflow/providers/fab/www/static",
]

[tool.hatch.build.targets.wheel]
packages = ['src/airflow']
artifacts = [
"src/airflow/providers/fab/www/static",
]
exclude = [
"src/airflow/__init__.py",
"src/airflow/providers/__init__.py",
"src/airflow/providers/fab/www/.pnpm-store",
"src/airflow/providers/fab/www/node_modules",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading