Adding CI for PR's -- uv lockfile verification, ruff lint, unit test suite#35
Merged
Merged
Conversation
Introduce a pr.yaml workflow that runs black, isort, and flake8 on every pull request to main, plus a package install verification step. Add lint as a prerequisite to the existing main.yml notebook runner. Wire up .pre-commit-config.yaml for local developer feedback. Made-with: Cursor
Run black and isort across src/ and notebooks/ to bring existing code into compliance with the new CI lint checks. Switch to black[jupyter] so .ipynb files are covered. Made-with: Cursor
- Takes main's updated src/, notebooks, pyproject.toml deps and cuml/cuopt 26.4 pins - Takes Python 3.11 minimum from the fix branch - Preserves ruff dev tooling and ruff config (required by pr.yaml lint steps) - Updates test_core.py import: compute_abs_returns -> compute_linear_returns - Regenerates uv.lock against merged pyproject.toml
- pyproject.toml: fix ruff target-version (string, not list) and per-file-ignores glob (**/__init__.py) - ruff format + --fix applied to 6 src/ files (whitespace, trailing newlines, f-strings) - tests: compute_abs_returns -> compute_absolute_returns (correct rename; linear != absolute) - tests: use ReturnsComputeSettings / ScenarioGenerationSettings pydantic models instead of dicts - tests: invalid fit_type now raises pydantic ValidationError at model construction - tests: skip test_no_fit due to pre-existing DataFrame-vs-ndarray bug in no_fit path - uv.lock regenerated
Adding CI/CD pipeline for PRs, Ruff linting, and Unit tests
Contributor
|
@jgoldberg-nvidia we need to resolve the |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds PR-level CI checks to catch lockfile, linting/formatting, and unit-test regressions before merge, and migrates dev tooling to Ruff with an initial unit test suite.
Changes:
- Introduces a new PR CI workflow to verify
uv.lock, run Ruff format/lint, and execute pytest across a Python version matrix. - Switches dev tooling from black/isort/flake8 to Ruff and updates code formatting accordingly.
- Adds a broad unit test suite for core returns/CVaR/portfolio/backtest functionality.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/pr.yaml |
New PR workflow for lockfile verification, linting/formatting, and tests. |
.github/workflows/main.yml |
Adds a lint+tests gate before running notebooks post-merge. |
pyproject.toml |
Replaces black/isort/flake8 with ruff + pytest in dev extra; adds Ruff config. |
.pre-commit-config.yaml |
Adds pre-commit hooks for Ruff lint/format plus whitespace fixers. |
uv.lock |
Updates lock to reflect new dev tooling (ruff/pytest) and removed black/isort/flake8. |
tests/test_core.py |
New unit test module covering returns, CVaR data/params, optimization, frontier, backtesting. |
src/utils.py |
Reformats code (notably long constants/printing and a few wrapped expressions) for Ruff. |
src/backtest.py |
Minor docstring edit (introduces a punctuation typo). |
src/base_optimizer.py |
Minor formatting change. |
src/cvar_optimizer.py |
Minor formatting/import consolidation. |
src/cvar_utils.py |
Minor formatting fixes. |
src/mean_variance_optimizer.py |
Minor formatting fixes. |
src/rebalance.py |
Minor formatting fixes (including assertions). |
src/portfolio.py |
Minor formatting fixes (including an assertion). |
src/settings.py |
Removes trailing whitespace. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a PR-level CI workflow (
.github/workflows/pr.yaml) that runs on every pull request againstmain, motivated by the recentuv sync --extra cuda13break in e65a857 that only surfaced after merge.lockfile-checkjob runsuv lock --locked, which re-resolves the full manifest across every Python version inrequires-pythonandevery extra (
dev,cuda12,cuda13). Catches dependency-resolution regressions (e.g., pinningcuml-cu13==26.4.*whilerequires-pythonstill permits Python 3.10) before merge, instead of waiting for the post-merge GPU job.
install-and-testmatrix runs unit tests on Python 3.11 and 3.12, catching code that works on the current dev target but regresses on thedeclared floor.
lintjob runsruff format --checkandruff checkonsrc/.pr-buildergate marks the PR as failing if any of the above fail.Also switches dev tooling from
black/isort/flake8toruff(single tool, faster) and appliesruff formattosrc/. Adds atests/test_core.pysuite (38 tests) covering returns, CVaR data + parameters, portfolio math, efficient frontier, and the backtester, using thepydantic
ReturnsComputeSettings/ScenarioGenerationSettingsmodels.One test (
test_no_fit) is skipped pending a fix togenerate_cvar_data— theno_fitpath passes aDataFrametoCvarData.R, whichpydantic validates as
ndarray. Latent bug in main; skip preserves the test for when it's fixed.Test plan
lockfile-checkpasses on this PR (provesuv lock --lockedresolves cleanly for all extras and Python versions)install-and-testpasses on Python 3.11 and 3.12 matrix legslintpasses (ruff format --check src/andruff check src/both clean)main.ymlpost-merge notebook run still succeeds against the merged codecuml-cu13==99.0.*) in a throwaway commit and confirmlockfile-checkfails