Skip to content

Commit

Permalink
Remove Airflow version check for accessing {{dag_run.note}} (#74)
Browse files Browse the repository at this point in the history
Fixes #73.
  • Loading branch information
arielshaqed authored and FredrikBakken committed Aug 13, 2023
1 parent ecae432 commit 8b44de3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lakefs_provider/operators/with_metadata_operator.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from typing import Any, Dict

import packaging.version

from airflow import __version__ as airflow_version
from airflow.configuration import conf as airflow_conf
from airflow.models import BaseOperator
from airflow.models import BaseOperator, DagRun
from sqlalchemy.exc import SQLAlchemyError


Expand Down Expand Up @@ -51,8 +49,7 @@ def _get_current_dag_dict(self, context: Dict[str, Any]) -> Dict[str, Any]:

def enrich_metadata(self, context: Dict[str, Any]):
"""Enrich metadata with values for lakeFS."""
# add 'note' value to metadata if Airflow is version 2.5.0 or later
if packaging.version.parse(airflow_version) >= packaging.version.parse("2.5.0"):
if hasattr(DagRun, "note"): # Older Airflow versions don't have DagRun.note.
self.__metadata_templates["note"] = "{{dag_run.note}}"

cdd = self._get_current_dag_dict(context)
Expand Down

0 comments on commit 8b44de3

Please sign in to comment.