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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
