Problem
The import guard CI check (check_imports.py) currently runs against all .py files under components/ and pipelines/, including test files. The CI filter is:
filter: '^(components|pipelines)/.*\.py$'
Test files run locally via pytest, not inside KFP containers. The import guard's rationale (keeping top-level imports stdlib-only so KFP serialization and compilation work correctly) does not apply to them.
As a result, every third-party module used in tests (e.g., pandas, tests) must be manually whitelisted in import_exceptions.yaml under globs like components/**/tests/*. This adds friction for contributors and grows the exceptions file unnecessarily.
Proposed fix
Exclude test files from the import guard. Options (not mutually exclusive):
- CI filter: change the regex to skip test paths, e.g.,
'^(components|pipelines)/(?!.*tests/).*\.py$'
- Script-level: have
check_imports.py skip files whose path contains /tests/
Either approach would allow removing the test-related entries from import_exceptions.yaml.
References
- Workflow:
.github/workflows/python-lint.yml (lines 65-78)
- Script:
.github/scripts/check_imports/check_imports.py
- Config:
.github/scripts/check_imports/import_exceptions.yaml
Problem
The import guard CI check (
check_imports.py) currently runs against all.pyfiles undercomponents/andpipelines/, including test files. The CI filter is:Test files run locally via pytest, not inside KFP containers. The import guard's rationale (keeping top-level imports stdlib-only so KFP serialization and compilation work correctly) does not apply to them.
As a result, every third-party module used in tests (e.g.,
pandas,tests) must be manually whitelisted inimport_exceptions.yamlunder globs likecomponents/**/tests/*. This adds friction for contributors and grows the exceptions file unnecessarily.Proposed fix
Exclude test files from the import guard. Options (not mutually exclusive):
'^(components|pipelines)/(?!.*tests/).*\.py$'check_imports.pyskip files whose path contains/tests/Either approach would allow removing the test-related entries from
import_exceptions.yaml.References
.github/workflows/python-lint.yml(lines 65-78).github/scripts/check_imports/check_imports.py.github/scripts/check_imports/import_exceptions.yaml