-
Notifications
You must be signed in to change notification settings - Fork 0
Add pytest configuration and CI infrastructure to prevent module import errors #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
4
commits into
main
Choose a base branch
from
copilot/fix-import-errors-and-submodule
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| name: CI Audit - Tests and Code Quality | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, develop ] | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
|
|
||
| # Set minimal permissions for GITHUB_TOKEN | ||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Run Tests | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.10", "3.11"] | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: recursive # Initialize any git submodules if present | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: 'pip' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
|
|
||
| # Install test dependencies | ||
| pip install pytest pytest-cov pytest-xdist | ||
|
|
||
| # Install GA_denoise_selector dependencies | ||
| if [ -f GA_denoise_selector/requirements.txt ]; then | ||
| pip install -r GA_denoise_selector/requirements.txt | ||
| fi | ||
|
|
||
| # Install Mamba-SSM-Denoise dependencies | ||
| if [ -f Mamba-SSM-Denoise/Track_H_cross_validation/requirements.txt ]; then | ||
| pip install -r Mamba-SSM-Denoise/Track_H_cross_validation/requirements.txt | ||
| fi | ||
|
|
||
| # Install GA_smoother_classic dependencies | ||
| if [ -f GA_smoother_classic/requirements.txt ]; then | ||
| pip install -r GA_smoother_classic/requirements.txt | ||
| fi | ||
|
|
||
| - name: Set PYTHONPATH | ||
| run: | | ||
| echo "PYTHONPATH=$PYTHONPATH:$(pwd):$(pwd)/GA_denoise_selector:$(pwd)/Mamba-SSM-Denoise/Track_H_cross_validation:$(pwd)/GA_smoother_classic" >> $GITHUB_ENV | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| # Export PYTHONPATH for pytest (belt and suspenders approach) | ||
| export PYTHONPATH=$PYTHONPATH:$(pwd):$(pwd)/GA_denoise_selector:$(pwd)/Mamba-SSM-Denoise/Track_H_cross_validation:$(pwd)/GA_smoother_classic | ||
|
|
||
| # Run tests with quick marker if available, otherwise run all tests | ||
| if grep -r "pytest.mark.quick" tests/ 2>/dev/null; then | ||
| pytest tests -m "quick" --maxfail=1 --cov=GA_denoise_selector/smoothers --cov=Mamba-SSM-Denoise/Track_H_cross_validation/src --cov-report=term --cov-report=html | ||
| else | ||
| pytest tests --maxfail=1 --cov=GA_denoise_selector/smoothers --cov=Mamba-SSM-Denoise/Track_H_cross_validation/src --cov-report=term --cov-report=html | ||
| fi | ||
|
|
||
| - name: Upload coverage reports | ||
| uses: actions/upload-artifact@v4 | ||
| if: always() | ||
| with: | ||
| name: coverage-report-${{ matrix.python-version }} | ||
| path: htmlcov/ | ||
| retention-days: 30 | ||
|
|
||
| lint: | ||
| name: Code Quality Checks | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install linting tools | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install flake8 black isort mypy | ||
|
|
||
| - name: Run flake8 | ||
| continue-on-error: true | ||
| run: | | ||
| # Stop the build if there are Python syntax errors or undefined names | ||
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
| # Exit-zero treats all errors as warnings | ||
| flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
|
|
||
| - name: Check code formatting with black | ||
| continue-on-error: true | ||
| run: | | ||
| black --check --diff . | ||
|
|
||
| - name: Check import ordering with isort | ||
| continue-on-error: true | ||
| run: | | ||
| isort --check-only --diff . | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Python | ||
| __pycache__/ | ||
| *.py[cod] | ||
| *$py.class | ||
| *.so | ||
| .Python | ||
| build/ | ||
| develop-eggs/ | ||
| dist/ | ||
| downloads/ | ||
| eggs/ | ||
| .eggs/ | ||
| lib/ | ||
| lib64/ | ||
| parts/ | ||
| sdist/ | ||
| var/ | ||
| wheels/ | ||
| pip-wheel-metadata/ | ||
| share/python-wheels/ | ||
| *.egg-info/ | ||
| .installed.cfg | ||
| *.egg | ||
| MANIFEST | ||
|
|
||
| # PyTorch | ||
| *.pth | ||
| *.pt | ||
| checkpoints/ | ||
| runs/ | ||
| lightning_logs/ | ||
|
|
||
| # Testing | ||
| .pytest_cache/ | ||
| .coverage | ||
| .coverage.* | ||
| htmlcov/ | ||
| .tox/ | ||
| .nox/ | ||
| coverage.xml | ||
| *.cover | ||
| .hypothesis/ | ||
| pytest_cache/ | ||
|
|
||
| # Jupyter Notebook | ||
| .ipynb_checkpoints | ||
| *.ipynb | ||
|
|
||
| # Environment | ||
| .env | ||
| .venv | ||
| env/ | ||
| venv/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
|
|
||
| # IDEs | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
| .DS_Store | ||
|
|
||
| # Data | ||
| *.csv | ||
| *.h5 | ||
| *.hdf5 | ||
| *.pkl | ||
| *.pickle | ||
| data/ | ||
| datasets/ | ||
| output/ | ||
| outputs/ | ||
| results/ | ||
|
|
||
| # Logs | ||
| *.log | ||
| logs/ | ||
| tensorboard/ | ||
|
|
||
| # Git submodules (if any future submodules are added) | ||
| external/ | ||
|
|
||
| # Temporary files | ||
| tmp/ | ||
| temp/ | ||
| *.tmp | ||
|
|
||
| # OS-specific | ||
| .DS_Store | ||
| Thumbs.db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| [tool:pytest] | ||
| # Configure pytest to find source modules for all projects | ||
| pythonpath = | ||
| . | ||
| GA_denoise_selector | ||
| Mamba-SSM-Denoise/Track_H_cross_validation | ||
| GA_smoother_classic | ||
|
|
||
| # Test discovery patterns | ||
| testpaths = tests | ||
| python_files = test_*.py | ||
| python_classes = Test* | ||
| python_functions = test_* | ||
|
|
||
| # Custom markers | ||
| markers = | ||
| quick: marks tests as quick (deselect with '-m "not quick"') | ||
|
|
||
| # Coverage configuration | ||
| [coverage:run] | ||
| source = | ||
| GA_denoise_selector/smoothers | ||
| Mamba-SSM-Denoise/Track_H_cross_validation/src | ||
|
|
||
| omit = | ||
| */tests/* | ||
| */test_*.py | ||
| */__pycache__/* | ||
|
|
||
| [coverage:report] | ||
| exclude_lines = | ||
| pragma: no cover | ||
| def __repr__ | ||
| raise AssertionError | ||
| raise NotImplementedError | ||
| if __name__ == '__main__': | ||
| if TYPE_CHECKING: | ||
| @abstractmethod |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mypyis installed here but not used in any subsequent step, which adds CI time and dependency surface without benefit. Either add amypycheck step or removemypyfrom the install list to keep the workflow lean.