Skip to content

Commit

Permalink
Use LocalExecutor for 2.7 and above too instead of hardcoding 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
kaxil committed Aug 18, 2023
1 parent 1bcaf7f commit 4affef7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
16 changes: 14 additions & 2 deletions airflowctl/modes/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import typer
import yaml
from dotenv import load_dotenv
from packaging import version
from rich import print
from rich.console import Console

Expand Down Expand Up @@ -315,12 +316,23 @@ def _setup_env_vars_to_run_airflow(self):
settings = yaml.safe_load(f)
self.airflow_version = settings.get("airflow_version")

# TODO: Check for Airflow version >= 2.6 instead of hardcoding it
if self.airflow_version and self.airflow_version.startswith("2.6"):
if (
self.airflow_version
and is_valid_pep440_version(self.airflow_version)
and version.parse(self.airflow_version) >= version.parse("2.6.0")
):
os.environ["AIRFLOW__CORE__EXECUTOR"] = "LocalExecutor"
os.environ["_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK"] = "1"


def is_valid_pep440_version(version_str: str) -> bool:
try:
version.parse(version_str)
return True
except version.InvalidVersion:
return False


def create_virtualenv_with_specific_python_version(venv_path: Path, python_version: str):
if isinstance(venv_path, str):
venv_path = Path(venv_path)
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "airflowctl"
version = "0.2.4"
description = "A lightweight Python package to simplify the installation of Apache Airflow effortlessly."
version = "0.2.5"
description = "A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects."
authors = [
"Kaxil Naik <[email protected]>",
]
Expand Down Expand Up @@ -33,6 +33,7 @@ rich = "^13.5.2"
pyyaml = "^6.0.1"
python-dotenv = ">=0.21.0"
psutil = "^5.9.5"
packaging = "^23.1"

[tool.poetry.scripts]
airflowctl = "airflowctl.cli:app"
Expand Down

0 comments on commit 4affef7

Please sign in to comment.