airflow icon indicating copy to clipboard operation
airflow copied to clipboard

Conflicting results between Ruff linting and Pydantic tests

Open CYarros10 opened this issue 1 year ago • 1 comments

          Conflicting tests when evaluating `airflow/tests/providers/google/cloud/operators/vertex_ai/test_supervised_fine_tuning.py` and `airflow/tests/providers/google/cloud/hooks/vertex_ai/test_supervised_fine_tuning.py` ...

Static checks, mypy, docs / Static checks :

Run 'ruff' for extremely fast Python linting.......................................Failed
- hook id: ruff
- exit code: 1

All checks passed!
tests/providers/google/cloud/hooks/vertex_ai/test_supervised_fine_tuning.py:27:1: E402 Module level import not at top of file
   |
25 |   pytest.importorskip("google.cloud.aiplatform_v1")
26 |   
27 | / from airflow.providers.google.cloud.hooks.vertex_ai.supervised_fine_tuning import (
28 | |     SupervisedFineTuningHook,
29 | | )
   | |_^ E402
30 |   from tests.providers.google.cloud.utils.base_gcp_mock import (
31 |       mock_base_gcp_hook_default_project_id,

Special tests / Pydantic removed test / All:Pydantic-Removed-Postgres:12:3.8: API Always BranchExternalPython BranchPythonVenv CLI Core ExternalPython Operators Other PlainAsserts :

_ ERROR collecting tests/providers/google/cloud/hooks/vertex_ai/test_supervised_fine_tuning.py _
ImportError while importing test module '/opt/airflow/tests/providers/google/cloud/hooks/vertex_ai/test_supervised_fine_tuning.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/providers/google/cloud/hooks/vertex_ai/test_supervised_fine_tuning.py:24: in <module>
    from airflow.providers.google.cloud.hooks.vertex_ai.supervised_fine_tuning import (
airflow/providers/google/cloud/hooks/vertex_ai/supervised_fine_tuning.py:25: in <module>
    import vertexai
E   ModuleNotFoundError: No module named 'vertexai'

Originally posted by @CYarros10 in https://github.com/apache/airflow/pull/41807#discussion_r1735221087

CYarros10 avatar Aug 28 '24 20:08 CYarros10

I'd imagine this is a general issue regarding how Ruff formatting/linting checks are required and how pytest.importorskip is sometimes necessary before other imports to pass Pydantic environment build tests - example:

# For no Pydantic environment, we need to skip the tests
pytest.importorskip("google.cloud.aiplatform_v1")

from airflow.providers.google.cloud.operators.vertex_ai.supervised_fine_tuning import (
    SupervisedFineTuningTrainOperator,
)

CYarros10 avatar Aug 28 '24 20:08 CYarros10

This issue has been automatically marked as stale because it has been open for 365 days without any activity. There has been several Airflow releases since last activity on this issue. Kindly asking to recheck the report against latest Airflow version and let us know if the issue is reproducible. The issue will be closed in next 30 days if no further activity occurs from the issue author.

github-actions[bot] avatar Aug 29 '25 07:08 github-actions[bot]

This issue has been closed because it has not received response from the issue author.

github-actions[bot] avatar Oct 09 '25 07:10 github-actions[bot]