You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "kacpermuda (via GitHub)" <gi...@apache.org> on 2025/03/18 08:55:29 UTC
[PR] feat: Add helper for OpenLineage version check [airflow]
kacpermuda opened a new pull request, #47897:
URL: https://github.com/apache/airflow/pull/47897
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
Some providers, such as Snowflake and DBT Cloud, do not require an OpenLineage provider but may offer optional features that depend on it. These features are generally available starting from a specific version of the OpenLineage provider or client. This decorator helps ensure compatibility, preventing import errors and providing clear logs about version requirements.
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add helper for OpenLineage version check [airflow]
Posted by "kacpermuda (via GitHub)" <gi...@apache.org>.
kacpermuda commented on code in PR #47897:
URL: https://github.com/apache/airflow/pull/47897#discussion_r2000772324
##########
providers/common/compat/src/airflow/providers/common/compat/openlineage/check.py:
##########
@@ -0,0 +1,106 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import functools
+import logging
+from importlib import metadata
+
+from packaging.version import Version
+
+log = logging.getLogger(__name__)
+
+
+def require_openlineage_version(
+ provider_min_version: str | None = None, client_min_version: str | None = None
+):
+ """
+ Enforce minimum version requirements for OpenLineage provider or client.
+
+ Some providers, such as Snowflake and DBT Cloud, do not require an OpenLineage provider but may
+ offer optional features that depend on it. These features are generally available starting
+ from a specific version of the OpenLineage provider or client. This decorator helps ensure compatibility,
+ preventing import errors and providing clear logs about version requirements.
+
+ Args:
+ provider_min_version: Optional minimum version requirement for apache-airflow-providers-openlineage
+ client_min_version: Optional minimum version requirement for openlineage-python
+
+ Raises:
+ ValueError: If neither `provider_min_version` nor `client_min_version` is provided.
+ TypeError: If the decorator is used without parentheses (e.g., `@require_openlineage_version`).
Review Comment:
So these two errors ValueError and TypeError are related to how this decorator is used. If the OL version if incompatible, we simply log and return None. Do you think we should raise this `AirflowOptionalProviderFeatureException` in such cases?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add helper for OpenLineage version check [airflow]
Posted by "kacpermuda (via GitHub)" <gi...@apache.org>.
kacpermuda commented on code in PR #47897:
URL: https://github.com/apache/airflow/pull/47897#discussion_r2000973695
##########
providers/common/compat/src/airflow/providers/common/compat/openlineage/check.py:
##########
@@ -0,0 +1,106 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import functools
+import logging
+from importlib import metadata
+
+from packaging.version import Version
+
+log = logging.getLogger(__name__)
+
+
+def require_openlineage_version(
+ provider_min_version: str | None = None, client_min_version: str | None = None
+):
+ """
+ Enforce minimum version requirements for OpenLineage provider or client.
+
+ Some providers, such as Snowflake and DBT Cloud, do not require an OpenLineage provider but may
+ offer optional features that depend on it. These features are generally available starting
+ from a specific version of the OpenLineage provider or client. This decorator helps ensure compatibility,
+ preventing import errors and providing clear logs about version requirements.
+
+ Args:
+ provider_min_version: Optional minimum version requirement for apache-airflow-providers-openlineage
+ client_min_version: Optional minimum version requirement for openlineage-python
+
+ Raises:
+ ValueError: If neither `provider_min_version` nor `client_min_version` is provided.
+ TypeError: If the decorator is used without parentheses (e.g., `@require_openlineage_version`).
Review Comment:
Changed it and added generic checker in this PR: #47909. Could you check if that's satisfying solution?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add helper for OpenLineage version check [airflow]
Posted by "kacpermuda (via GitHub)" <gi...@apache.org>.
kacpermuda commented on code in PR #47897:
URL: https://github.com/apache/airflow/pull/47897#discussion_r2000781063
##########
providers/common/compat/src/airflow/providers/common/compat/openlineage/check.py:
##########
@@ -0,0 +1,106 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import functools
+import logging
+from importlib import metadata
+
+from packaging.version import Version
+
+log = logging.getLogger(__name__)
+
+
+def require_openlineage_version(
+ provider_min_version: str | None = None, client_min_version: str | None = None
+):
+ """
+ Enforce minimum version requirements for OpenLineage provider or client.
+
+ Some providers, such as Snowflake and DBT Cloud, do not require an OpenLineage provider but may
+ offer optional features that depend on it. These features are generally available starting
+ from a specific version of the OpenLineage provider or client. This decorator helps ensure compatibility,
+ preventing import errors and providing clear logs about version requirements.
+
+ Args:
+ provider_min_version: Optional minimum version requirement for apache-airflow-providers-openlineage
+ client_min_version: Optional minimum version requirement for openlineage-python
+
+ Raises:
+ ValueError: If neither `provider_min_version` nor `client_min_version` is provided.
+ TypeError: If the decorator is used without parentheses (e.g., `@require_openlineage_version`).
Review Comment:
Any Exceptions raised during OL's extraction are caught by OL anyway, so the result would be similar.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add helper for OpenLineage version check [airflow]
Posted by "mobuchowski (via GitHub)" <gi...@apache.org>.
mobuchowski merged PR #47897:
URL: https://github.com/apache/airflow/pull/47897
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add helper for OpenLineage version check [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #47897:
URL: https://github.com/apache/airflow/pull/47897#discussion_r2000835820
##########
providers/common/compat/src/airflow/providers/common/compat/openlineage/check.py:
##########
@@ -0,0 +1,106 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import functools
+import logging
+from importlib import metadata
+
+from packaging.version import Version
+
+log = logging.getLogger(__name__)
+
+
+def require_openlineage_version(
+ provider_min_version: str | None = None, client_min_version: str | None = None
+):
+ """
+ Enforce minimum version requirements for OpenLineage provider or client.
+
+ Some providers, such as Snowflake and DBT Cloud, do not require an OpenLineage provider but may
+ offer optional features that depend on it. These features are generally available starting
+ from a specific version of the OpenLineage provider or client. This decorator helps ensure compatibility,
+ preventing import errors and providing clear logs about version requirements.
+
+ Args:
+ provider_min_version: Optional minimum version requirement for apache-airflow-providers-openlineage
+ client_min_version: Optional minimum version requirement for openlineage-python
+
+ Raises:
+ ValueError: If neither `provider_min_version` nor `client_min_version` is provided.
+ TypeError: If the decorator is used without parentheses (e.g., `@require_openlineage_version`).
Review Comment:
If there is a provider version incompatibility we should raise AirflowOptionalProviderFeatureException
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add helper for OpenLineage version check [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #47897:
URL: https://github.com/apache/airflow/pull/47897#discussion_r2000765818
##########
providers/common/compat/src/airflow/providers/common/compat/openlineage/check.py:
##########
@@ -0,0 +1,106 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import functools
+import logging
+from importlib import metadata
+
+from packaging.version import Version
+
+log = logging.getLogger(__name__)
+
+
+def require_openlineage_version(
+ provider_min_version: str | None = None, client_min_version: str | None = None
+):
+ """
+ Enforce minimum version requirements for OpenLineage provider or client.
+
+ Some providers, such as Snowflake and DBT Cloud, do not require an OpenLineage provider but may
+ offer optional features that depend on it. These features are generally available starting
+ from a specific version of the OpenLineage provider or client. This decorator helps ensure compatibility,
+ preventing import errors and providing clear logs about version requirements.
+
+ Args:
+ provider_min_version: Optional minimum version requirement for apache-airflow-providers-openlineage
+ client_min_version: Optional minimum version requirement for openlineage-python
+
+ Raises:
+ ValueError: If neither `provider_min_version` nor `client_min_version` is provided.
+ TypeError: If the decorator is used without parentheses (e.g., `@require_openlineage_version`).
Review Comment:
This makes openlineage behave differently from other providers.
We always raise `AirflowOptionalProviderFeatureException` when there is problem with version.
Even in openlineage itself
https://github.com/apache/airflow/blob/b2c646af408d2ea70c82aa47fb3f2f68c777fd7e/providers/dbt/cloud/src/airflow/providers/dbt/cloud/utils/openlineage.py#L76-L82
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] feat: Add helper for OpenLineage version check [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #47897:
URL: https://github.com/apache/airflow/pull/47897#discussion_r2000771633
##########
providers/common/compat/src/airflow/providers/common/compat/openlineage/check.py:
##########
@@ -0,0 +1,106 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from __future__ import annotations
+
+import functools
+import logging
+from importlib import metadata
+
+from packaging.version import Version
+
+log = logging.getLogger(__name__)
+
+
+def require_openlineage_version(
+ provider_min_version: str | None = None, client_min_version: str | None = None
+):
+ """
+ Enforce minimum version requirements for OpenLineage provider or client.
+
+ Some providers, such as Snowflake and DBT Cloud, do not require an OpenLineage provider but may
+ offer optional features that depend on it. These features are generally available starting
+ from a specific version of the OpenLineage provider or client. This decorator helps ensure compatibility,
+ preventing import errors and providing clear logs about version requirements.
+
+ Args:
+ provider_min_version: Optional minimum version requirement for apache-airflow-providers-openlineage
+ client_min_version: Optional minimum version requirement for openlineage-python
+
+ Raises:
+ ValueError: If neither `provider_min_version` nor `client_min_version` is provided.
+ TypeError: If the decorator is used without parentheses (e.g., `@require_openlineage_version`).
Review Comment:
i wonder if we can change `require_openlineage_version` to `require_provider_version(provider=...)`
and create a more generic interface for all providers that implement the function
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org