Skip to content

Commit

Permalink
Versionless bundles return None vs raising (apache#44574)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedcunningham authored Dec 2, 2024
1 parent 3747c91 commit 5bddd13
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion airflow/dag_processing/bundles/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def path(self) -> Path:
"""

@abstractmethod
def get_current_version(self) -> str:
def get_current_version(self) -> str | None:
"""
Retrieve a string that represents the version of the DAG bundle.
Expand Down
5 changes: 2 additions & 3 deletions airflow/dag_processing/bundles/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from pathlib import Path

from airflow.dag_processing.bundles.base import BaseDagBundle
from airflow.exceptions import AirflowException


class LocalDagBundle(BaseDagBundle):
Expand All @@ -36,8 +35,8 @@ def __init__(self, *, local_folder: str, **kwargs) -> None:
super().__init__(**kwargs)
self._path = Path(local_folder)

def get_current_version(self) -> str:
raise AirflowException("Not versioned!")
def get_current_version(self) -> None:
return None

def refresh(self) -> None:
"""Nothing to refresh - it's just a local directory."""
Expand Down
5 changes: 2 additions & 3 deletions tests/dag_processing/test_dag_bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ def test_path(self):
bundle = LocalDagBundle(name="test", local_folder="/hello")
assert bundle.path == Path("/hello")

def test_does_not_support_versioning(self):
def test_none_for_version(self):
assert LocalDagBundle.supports_versioning is False

bundle = LocalDagBundle(name="test", local_folder="/hello")

with pytest.raises(AirflowException):
bundle.get_current_version()
assert bundle.get_current_version() is None


@pytest.fixture
Expand Down

0 comments on commit 5bddd13

Please sign in to comment.