Skip to content

Commit

Permalink
Update util.py
Browse files Browse the repository at this point in the history
fixes #1
  • Loading branch information
howardyoo authored Sep 8, 2024
1 parent 368cc9e commit 86c7761
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,17 @@ def gen_dag_span_id(dag_run: DagRun, as_int: bool = False) -> str | int:
)

def gen_span_id(ti: TaskInstance, as_int: bool = False) -> str | int:
from packaging.version import parse
"""Generate span id from the task instance."""
dag_run = ti.dag_run
if ti.state == TaskInstanceState.SUCCESS or ti.state == TaskInstanceState.FAILED:
try_number = get_try_number(ti)
else:
try_number = ti.try_number
# fix: issue #1
if parse(parse(airflow_version).base_version) == parse("2.10.0"):
try_number = ti.try_number - 1
else:
try_number = ti.try_number
return _gen_id(
[dag_run.dag_id, dag_run.run_id, ti.task_id, str(try_number)],
as_int,
Expand Down

0 comments on commit 86c7761

Please sign in to comment.