Re: [PR] Remove core imports in shared observability tests [airflow]

2026-02-11 Thread via GitHub


amoghrajesh merged PR #61784:
URL: https://github.com/apache/airflow/pull/61784


-- 
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]



Re: [PR] Remove core imports in shared observability tests [airflow]

2026-02-11 Thread via GitHub


amoghrajesh commented on PR #61784:
URL: https://github.com/apache/airflow/pull/61784#issuecomment-3889018855

   > Changes LGTM! If the failure persists, it might be worth launching a CI 
that runs the failing test on repeat.
   
   Nope, there are no actual failures on main, its when I tried to work on a 
related PR that I did notice this pattern which can be eliminated


-- 
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]



Re: [PR] Remove core imports in shared observability tests [airflow]

2026-02-11 Thread via GitHub


amoghrajesh commented on code in PR #61784:
URL: https://github.com/apache/airflow/pull/61784#discussion_r2797079525


##
shared/observability/tests/observability/metrics/test_stats.py:
##
@@ -149,7 +148,8 @@ def test_load_invalid_custom_stats_client(self):
 "Your custom StatsD client must extend the statsd."
 "StatsClient in order to ensure backwards compatibility."
 )
-with pytest.raises(AirflowConfigException, match=error_message):
+# we assert for Exception here instead of AirflowConfigException 
to not import from shared configuration
+with pytest.raises(Exception, match=error_message):

Review Comment:
   We would have to add `configuration` from `shared` as a dev dependency, 
which can be avoided by doing this. This kind of simulates that because 
`AirflowConfigException` inherits from `Exception` and we match by error 
message which is thrown by AirflowConfigException, so I think its good enough



-- 
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]



Re: [PR] Remove core imports in shared observability tests [airflow]

2026-02-11 Thread via GitHub


amoghrajesh commented on PR #61784:
URL: https://github.com/apache/airflow/pull/61784#issuecomment-3889012905

   Good catch @andreahlert! I did that earlier and since I am using `Exception` 
class directly, I removed that


-- 
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]



Re: [PR] Remove core imports in shared observability tests [airflow]

2026-02-11 Thread via GitHub


andreahlert commented on code in PR #61784:
URL: https://github.com/apache/airflow/pull/61784#discussion_r2795196475


##
shared/observability/tests/observability/metrics/test_stats.py:
##
@@ -149,7 +148,8 @@ def test_load_invalid_custom_stats_client(self):
 "Your custom StatsD client must extend the statsd."
 "StatsClient in order to ensure backwards compatibility."
 )
-with pytest.raises(AirflowConfigException, match=error_message):
+# we assert for Exception here instead of AirflowConfigException 
to not import from shared configuration
+with pytest.raises(Exception, match=error_message):

Review Comment:
   would it work to import AirflowConfigException from 
airflow_shared.configuration here instead of catching bare Exception?



-- 
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]



Re: [PR] Remove core imports in shared observability tests [airflow]

2026-02-11 Thread via GitHub


andreahlert commented on PR #61784:
URL: https://github.com/apache/airflow/pull/61784#issuecomment-3886716111

   hey, the description mentions adding apache-airflow-shared-configuration as 
a dep but didn't see the pyproject.toml change. Was that dropped?


-- 
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]



[PR] Remove core imports in shared observability tests [airflow]

2026-02-11 Thread via GitHub


amoghrajesh opened a new pull request, #61784:
URL: https://github.com/apache/airflow/pull/61784

   
   
   ---
   
   # Was generative AI tooling used to co-author this PR?
   
   
   
   - [x] No
   
   
   
   The shared observability tests were importing from `airflow._shared` which 
pulled in the entire `airflow-core` package with some dependencies with 
failures such as these:
   
   ```python
   ERROR tests/observability/metrics/test_stats.py - ImportError while 
importing test module 
'/home/runner/work/airflow/airflow/shared/observability/tests/observability/metrics/test_stats.py'.
   Hint: make sure your test modules/packages have valid Python names.
   Traceback:
   ../../.venv/lib/python3.10/site-packages/_pytest/python.py:507: in 
importtestmodule
   mod = import_path(
   ../../.venv/lib/python3.10/site-packages/_pytest/pathlib.py:587: in 
import_path
   importlib.import_module(module_name)
   /usr/lib/python3.10/importlib/__init__.py:126: in import_module
   return _bootstrap._gcd_import(name[level:], package, level)
   :1050: in _gcd_import
   ???
   :1027: in _find_and_load
   ???
   :1006: in _find_and_load_unlocked
   ???
   :688: in _load_unlocked
   ???
   ../../.venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:197: 
in exec_module
   exec(co, module.__dict__)
   tests/observability/metrics/test_stats.py:33: in 
   from airflow._shared.configuration import AirflowConfigException
   ../../airflow-core/src/airflow/__init__.py:64: in 
   from airflow import configuration, settings
   ../../airflow-core/src/airflow/configuration.py:935: in 
   secrets_backend_list = initialize_secrets_backends()
   ../../airflow-core/src/airflow/configuration.py:881: in 
initialize_secrets_backends
   from airflow.models import Connection
   ../../airflow-core/src/airflow/models/__init__.py:88: in __getattr__
   val = import_string(f"{path}.{name}")
   ../../airflow-core/src/airflow/_shared/module_loading/__init__.py:58: in 
import_string
   module = import_module(module_path)
   /usr/lib/python3.10/importlib/__init__.py:126: in import_module
   return _bootstrap._gcd_import(name[level:], package, level)
   ../../airflow-core/src/airflow/models/connection.py:39: in 
   from airflow.utils.helpers import prune_dict
   ../../airflow-core/src/airflow/utils/helpers.py:29: in 
   from lazy_object_proxy import Proxy
   E   ModuleNotFoundError: No module named 'lazy_object_proxy'
   ```
   
   Example: 
https://github.com/apache/airflow/actions/runs/21914519496/job/63277989205?pr=61523
   
   This caused test failures when running the shared observability package in 
isolation.
   
   Changed test imports to use same namespace directly and added 
`apache-airflow-shared-configuration` as an explicit dependency. For this, some 
changes I made included making change to validator type checks to use` 
isinstance()` instead of identity checks to handle cases where classes may be 
loaded from different module paths, which does a good enough job.
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]