kubeflow / kubeflow/pipelines-components

Import guard should exclude test files

Open
#131 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
12
Forks
56
Avg merge
1d 11h
Merged PRs (30d)
3

Description

## 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:

```yaml
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):

1. **CI filter**: change the regex to skip test paths, e.g., `'^(components|pipelines)/(?!.*tests/).*\.py$'`
2. **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`

Contributor guide

Open the contributing guide

Research direction

Start with .github/workflows/python-lint.yml lines 65-78 and inspect how it invokes .github/scripts/check_imports/check_imports.py. Compare the CI-filter and script-level options, then update the selected path handling so test files are excluded and remove obsolete test-related entries from .github/scripts/check_imports/import_exceptions.yaml. Done means the import guard still checks non-test Python files without requiring test-only exceptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, python
Domain
ci-cd, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.