From 2b99777972f06dcdf618a8f3e22b13627db54040 Mon Sep 17 00:00:00 2001 From: GiovanniCorsetti <66136602+CorsettiS@users.noreply.github.com> Date: Fri, 24 Jan 2025 16:22:49 +0100 Subject: [PATCH] Fix OpenLineage deprecation warning (#1449) Openlineage suggests using event_v2 as the new import call. This can be seen in the source code of openlineage itself for the [run](https://github.com/OpenLineage/OpenLineage/blob/main/client/python/openlineage/client/run.py) method. ``` UserWarning: {message : DeprecationWarning('This module is deprecated. Please use `openlineage.client.event_v2`.'), category : 'DeprecationWarning', filename : '/home/airflow/.local/lib/python3.10/site-packages/openlineage/client/filter.py', lineno : 9, line : None} `` Co-authored-by: Giovanni Corsetti <155465603+corsettigyg@users.noreply.github.com> --- cosmos/operators/local.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cosmos/operators/local.py b/cosmos/operators/local.py index c672c27cb..7db2faaea 100644 --- a/cosmos/operators/local.py +++ b/cosmos/operators/local.py @@ -46,7 +46,11 @@ if TYPE_CHECKING: from airflow.datasets import Dataset # noqa: F811 from dbt.cli.main import dbtRunner, dbtRunnerResult - from openlineage.client.run import RunEvent + + try: # pragma: no cover + from openlineage.client.event_v2 import RunEvent # pragma: no cover + except ImportError: # pragma: no cover + from openlineage.client.run import RunEvent # pragma: no cover from sqlalchemy.orm import Session