Skip to content
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

Further make sure graphviz is truly optional feature on MacOS #43867

Merged
merged 1 commit into from
Nov 11, 2024
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: 5 additions & 2 deletions hatch_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,11 @@
],
"doc-gen": [
"apache-airflow[doc]",
"diagrams>=0.23.4",
"eralchemy2>=1.3.8",
# The graphviz package creates friction when installing on MacOS as it needs graphviz system package to
# be installed, and it's really only used for very obscure features of Airflow, so we can skip it on MacOS
# Instead, if someone attempts to use it on MacOS, they will get explanatory error on how to install it
"diagrams>=0.23.4; sys_platform != 'darwin'",
"eralchemy2>=1.3.8; sys_platform != 'darwin'",
],
# END OF doc extras
}
Expand Down
14 changes: 12 additions & 2 deletions scripts/ci/pre_commit/generate_airflow_diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,19 @@ def main():
hash_file = source_file.with_suffix(".md5sum")
if not hash_file.exists() or not hash_file.read_text().strip() == str(checksum).strip():
console.print(f"[bright_blue]Changes in {source_file}. Regenerating the image.")
subprocess.run(
[sys.executable, source_file.resolve().as_posix()], check=True, cwd=source_file.parent
process = subprocess.run(
[sys.executable, source_file.resolve().as_posix()], check=False, cwd=source_file.parent
)
if process.returncode != 0:
if sys.platform == "darwin":
console.print(
"[red]Likely you have no graphviz installed[/]"
"Please install eralchemy2 package to run this script. "
"This will require to install graphviz, "
"and installing graphviz might be difficult for MacOS. Please follow: "
"https://pygraphviz.github.io/documentation/stable/install.html#macos ."
)
potiuk marked this conversation as resolved.
Show resolved Hide resolved
sys.exit(process.returncode)
hash_file.write_text(str(checksum) + "\n")
else:
console.print(f"[bright_blue]No changes in {source_file}. Not regenerating the image.")
Expand Down
15 changes: 13 additions & 2 deletions scripts/in_container/run_prepare_er_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from __future__ import annotations

import os
import sys
from pathlib import Path

from checksumdir import dirhash
Expand All @@ -34,9 +35,19 @@

MIGRATIONS_DIR = AIRFLOW_SOURCES_ROOT / "airflow" / "migrations"
if __name__ == "__main__":
from eralchemy2 import render_er

console = Console(width=400, color_system="standard")
try:
from eralchemy2 import render_er
except ImportError:
if sys.platform == "darwin":
console.print(
"[red]Likely you have no graphviz installed[/]"
"Please install eralchemy2 package to run this script. "
"This will require to install graphviz, "
"and installing graphviz might be difficult for MacOS. Please follow: "
"https://pygraphviz.github.io/documentation/stable/install.html#macos ."
)
raise

console.print("[bright_blue]Preparing diagram for Airflow ERD")
sha256hash = dirhash(
Expand Down
Loading