Skip to content

Run test suite under Python -O / -OO in CI#608

Open
arunkumargururaj07-star wants to merge 3 commits intobayesflow-org:mainfrom
arunkumargururaj07-star:ci-run-tests-with-O
Open

Run test suite under Python -O / -OO in CI#608
arunkumargururaj07-star wants to merge 3 commits intobayesflow-org:mainfrom
arunkumargururaj07-star:ci-run-tests-with-O

Conversation

@arunkumargururaj07-star
Copy link

This PR updates the CI workflow to run the test suite under Python optimization
flags (-O and -OO).

The goal is to ensure that tests behave correctly when assertions in the main
codebase are stripped, while relying on pytest’s assertion rewriting for test
files.

No test logic or helper functions were modified — only the GitHub Actions
workflow was updated to add optimized test runs.

@LarsKue LarsKue self-requested a review January 13, 2026 16:15
Copy link
Contributor

@LarsKue LarsKue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR. Please target the dev branch instead of the main branch. Further, I think we need to avoid making the test suite too expensive, see individual comments for changes.

os: [ubuntu-latest, windows-latest]
python-version: ["3.10"] # we usually only need to test the oldest python version
backend: ["jax", "tensorflow", "torch"]
optimization: ["", "-O", "-OO"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running the optimizations in the matrix is too expensive. Can we add a separate manual-trigger only workflow to handle this instead?

- name: Run Tests
run: |
pytest -x -m "not slow"
python ${{ matrix.optimization }} -m pytest tests/ --tb=short -v
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you go into some detail why you chose to make this verbose but shorten the traceback? I'm not entirely sure of the implications for the output yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep this file unchanged with respect to the dev branch.

@LarsKue LarsKue added the unit tests A new set of tests needs to be added. label Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unit tests A new set of tests needs to be added.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants