potiuk commented on code in PR #32495: URL: https://github.com/apache/airflow/pull/32495#discussion_r1260735672
########## dev/breeze/src/airflow_breeze/utils/publish_docs_builder.py: ########## @@ -0,0 +1,296 @@ +# 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 os +import re +import shlex +import shutil +from glob import glob +from pathlib import Path +from subprocess import run + +from rich.console import Console + +from airflow_breeze.utils.docs_errors import DocBuildError, parse_sphinx_warnings +from airflow_breeze.utils.helm_chart_utils import chart_version +from airflow_breeze.utils.publish_docs_helpers import ALL_PROVIDER_YAMLS, pretty_format_path +from airflow_breeze.utils.spelling_checks import SpellingError, parse_spelling_warnings + +PROCESS_TIMEOUT = 15 * 60 +CONSOLE_WIDTH = 180 + +ROOT_PROJECT_DIR = Path(__file__).parents[5].resolve() +DOCS_DIR = os.path.join(ROOT_PROJECT_DIR, "docs") + +console = Console(force_terminal=True, color_system="standard", width=CONSOLE_WIDTH) + + +class PublishDocsBuilder: + """Documentation builder for Airflow Docs Publishing.""" + + def __init__(self, package_name: str, for_production: bool): + self.package_name = package_name + self.for_production = for_production + + @property + def _doctree_dir(self) -> str: + return f"{DOCS_DIR}/_doctrees/docs/{self.package_name}" + + @property + def _inventory_cache_dir(self) -> str: + return f"{DOCS_DIR}/_inventory_cache" + + @property + def is_versioned(self): + """Is current documentation package versioned?""" + # Disable versioning. This documentation does not apply to any released product and we can update + # it as needed, i.e. with each new package of providers. + return self.package_name not in ("apache-airflow-providers", "docker-stack") + + @property + def _build_dir(self) -> str: + if self.is_versioned: + version = "stable" if self.for_production else "latest" + return f"{DOCS_DIR}/_build/docs/{self.package_name}/{version}" + else: + return f"{DOCS_DIR}/_build/docs/{self.package_name}" + + @property + def log_spelling_filename(self) -> str: + """Log from spelling job.""" + return os.path.join(self._build_dir, f"output-spelling-{self.package_name}.log") + + @property + def log_spelling_output_dir(self) -> str: + """Results from spelling job.""" + return os.path.join(self._build_dir, f"output-spelling-results-{self.package_name}") + + @property + def log_build_filename(self) -> str: + """Log from build job.""" + return os.path.join(self._build_dir, f"output-build-{self.package_name}.log") + + @property + def log_build_warning_filename(self) -> str: + """Warnings from build job.""" + return os.path.join(self._build_dir, f"warning-build-{self.package_name}.log") + + @property + def _current_version(self): + if not self.is_versioned: + raise Exception("This documentation package is not versioned") + if self.package_name == "apache-airflow": + from airflow.version import version as airflow_version Review Comment: This fails - because in Breeze "airflow" is not on PYTHONPATH and you should get airflow version differently. And we do not want to "import airflow" in Breeze : breeze does not rely on airflow being installed, it is essentially a tool that "manages" airflow environment, so requiring breeze to have airflow installed and on PYTHONPATH is quite a bit chicken-egg problem. There is a "get_airflow_version()` method in global constants that does it from sources without having to import airfliow. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
