Skip to content

Commit

Permalink
Introduce short package names for publish docs (apache#34253)
Browse files Browse the repository at this point in the history
* Introduce short package names for publish docs

* inlcuding docs

* Refactoring to a general utils file
  • Loading branch information
amoghrajesh authored Sep 10, 2023
1 parent 58cce7d commit 18eed91
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 192 deletions.
14 changes: 14 additions & 0 deletions BREEZE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,9 @@ while publishing the documentation.
breeze release-management publish-docs --airflow-site-directory
You can also use shorthand names as arguments instead of using the full names
for airflow providers. To find the short hand names, follow the instructions in :ref:`generating_short_form_names`.
The flag ``--airflow-site-directory`` takes the path of the cloned ``airflow-site``. The command will
not proceed if this is an invalid path.
Expand All @@ -2093,6 +2096,17 @@ These are all available flags of ``release-management publish-docs`` command:
:width: 100%
:alt: Breeze Publish documentation
.. _generating_short_form_names:
Generating short form names for Providers
-----------------------------------------
Skip the ``apache-airflow-providers-`` from the usual provider full names.
Now with the remaining part, replace every ``dash("-")`` with a ``dot(".")``.
Example:
If the provider name is ``apache-airflow-providers-cncf-kubernetes``, it will be ``cncf.kubernetes``.
Adding back referencing HTML for the documentation
""""""""""""""""""""""""""""""""""""""""""""""""""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from airflow_breeze.utils.common_options import (
argument_packages,
argument_packages_plus_all_providers,
argument_packages_plus_all_providers_for_shorthand,
option_airflow_constraints_mode_ci,
option_airflow_constraints_mode_update,
option_airflow_constraints_reference,
Expand Down Expand Up @@ -82,7 +83,7 @@
)
from airflow_breeze.utils.confirm import Answer, user_confirm
from airflow_breeze.utils.console import Output, get_console
from airflow_breeze.utils.custom_param_types import BetterChoice, NotVerifiedBetterChoice
from airflow_breeze.utils.custom_param_types import BetterChoice
from airflow_breeze.utils.docker_command_utils import (
check_remote_ghcr_io_commands,
get_env_variables_for_docker_commands,
Expand Down Expand Up @@ -837,10 +838,13 @@ def run_publish_docs_in_parallel(
)
@click.option("-s", "--override-versioned", help="Overrides versioned directories.", is_flag=True)
@option_airflow_site_directory
@argument_packages_plus_all_providers_for_shorthand
@click.option(
"--package-filter",
help="List of packages to consider.",
type=NotVerifiedBetterChoice(get_available_documentation_packages()),
help="List of packages to consider. You can use the full names like apache-airflow-providers-<provider>, "
"the short hand names or the glob pattern matching the full package name. "
"The list of short hand names can be found in --help output",
type=str,
multiple=True,
)
@option_run_in_parallel
Expand All @@ -853,6 +857,7 @@ def run_publish_docs_in_parallel(
def publish_docs(
override_versioned: bool,
airflow_site_directory: str,
packages_plus_all_providers: tuple[str],
package_filter: tuple[str],
run_in_parallel: bool,
parallelism: int,
Expand All @@ -869,8 +874,10 @@ def publish_docs(

available_packages = get_available_packages()
package_filters = package_filter
current_packages = process_package_filters(
available_packages, package_filters, packages_plus_all_providers
)

current_packages = process_package_filters(available_packages, package_filters)
print(f"Publishing docs for {len(current_packages)} package(s)")
for pkg in current_packages:
print(f" - {pkg}")
Expand Down
16 changes: 1 addition & 15 deletions dev/breeze/src/airflow_breeze/params/doc_build_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,7 @@
from dataclasses import dataclass

from airflow_breeze.branch_defaults import AIRFLOW_BRANCH

providers_prefix = "apache-airflow-providers-"


def get_provider_name_from_short_hand(short_form_providers: tuple[str]):
providers = []
for short_form_provider in short_form_providers:
if short_form_provider == "providers-index":
providers.append("apache-airflow-providers")
continue

short_form_provider.split(".")
parts = "-".join(short_form_provider.split("."))
providers.append(providers_prefix + parts)
return tuple(providers)
from airflow_breeze.utils.general_utils import get_provider_name_from_short_hand


@dataclass
Expand Down
32 changes: 32 additions & 0 deletions dev/breeze/src/airflow_breeze/utils/general_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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

providers_prefix = "apache-airflow-providers-"


def get_provider_name_from_short_hand(short_form_providers: tuple[str]):
providers = []
for short_form_provider in short_form_providers:
if short_form_provider == "providers-index":
providers.append("apache-airflow-providers")
continue

short_form_provider.split(".")
parts = "-".join(short_form_provider.split("."))
providers.append(providers_prefix + parts)
return tuple(providers)
11 changes: 9 additions & 2 deletions dev/breeze/src/airflow_breeze/utils/publish_docs_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import yaml

from airflow_breeze.utils.general_utils import get_provider_name_from_short_hand

CONSOLE_WIDTH = 180

ROOT_DIR = Path(__file__).parents[5].resolve()
Expand Down Expand Up @@ -99,14 +101,19 @@ def get_available_packages():
]


def process_package_filters(available_packages: list[str], package_filters: list[str] | None):
def process_package_filters(
available_packages: list[str], package_filters: list[str] | None, packages_short_form: tuple[str]
):
"""Filters the package list against a set of filters.
A packet is returned if it matches at least one filter. The function keeps the order of the packages.
"""
if not package_filters:
if not package_filters and not packages_short_form:
return available_packages

expanded_short_form_packages = get_provider_name_from_short_hand(packages_short_form)
package_filters = list(package_filters + expanded_short_form_packages)

invalid_filters = [
f for f in package_filters if not any(fnmatch.fnmatch(p, f) for p in available_packages)
]
Expand Down
4 changes: 2 additions & 2 deletions images/breeze/output-commands-hash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ release-management:install-provider-packages:34c38aca17d23dbb454fe7a6bfd8e630
release-management:prepare-airflow-package:85d01c57e5b5ee0fb9e5f9d9706ed3b5
release-management:prepare-provider-documentation:a53cd338bd719c77108b53bc8d45b634
release-management:prepare-provider-packages:fc69d2ab8abdcbafcaaa63da380f4b76
release-management:publish-docs:1c7e6b9af76d663d3af5bec29a21a2ee
release-management:publish-docs:45a6ea090bfcf564ea0dd8fc61655d8a
release-management:release-prod-images:cfbfe8b19fee91fd90718f98ef2fd078
release-management:start-rc-process:b27bd524dd3c89f50a747b60a7e892c1
release-management:start-release:419f48f6a4ff4457cb9de7ff496aebbe
release-management:update-constraints:02ec4b119150e3fdbac52026e94820ef
release-management:verify-provider-packages:96dce5644aad6b37080acf77b3d8de3a
release-management:1098994e77919b0de653e5029bccbd14
release-management:885a5fe8a39a3773011cf1f9bd2983ad
sbom:generate-provider-requirements:2ea27f55be4e6ab2b0b5a410330f2747
sbom:update-sbom-information:653be48be70b4b7ff5172d491aadc694
sbom:ff73e9f941b6d6053e680ca53e9d1b33
Expand Down
Loading

0 comments on commit 18eed91

Please sign in to comment.