Skip to content
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

fix either feature conditional compilation, again #3834

Merged
merged 7 commits into from Feb 22, 2024

Conversation

davidhewitt
Copy link
Member

#3722 (comment), thanks for reporting @utkarshgupta137

@davidhewitt
Copy link
Member Author

For what it's worth, I didn't fancy adding a test for this feature combination in CI, as testing the full set of all combinations of features seems impractical 😢

Copy link

codspeed-hq bot commented Feb 13, 2024

CodSpeed Performance Report

Merging #3834 will not alter performance

Comparing davidhewitt:either-type (51c53b0) with main (61bc02d)

Summary

✅ 67 untouched benchmarks

Copy link
Member

@adamreichold adamreichold left a comment

Choose a reason for hiding this comment

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

I wonder how this go through CI, don't we test a lot of feature combinations? I think this tells us that we need at least one more which does not include the experiment-inspect feature.

@adamreichold
Copy link
Member

For what it's worth, I didn't fancy adding a test for this feature combination in CI, as testing the full set of all combinations of features seems impractical 😢

Sorry for missing that. I also don't we should test the full power set. But I would rather drop a combination that includes the experiment feature than not testing stable features without the experimental bit enabled.

@utkarshgupta137
Copy link

Not sure what you guys are using right now, but we use https://github.com/taiki-e/cargo-hack in our workspace. We don't do powersets, because we often have conflicting feature, but we test each feature individually. I believe that would've been enough to catch this.

@adamreichold
Copy link
Member

I don't think testing all features individually is reasonable for PyO3 because we have many integration features like either which do not plausibly interact with each other. We mainly need to ensure that we test with/without the infrastructure features like experimental-inspect. So I think an adjustment of our current curated feature sets is still the most reasonable approach for us specifically.

@davidhewitt
Copy link
Member Author

👍 (I'll try to get to this tomorrow or over the weekend.)

@davidhewitt
Copy link
Member Author

I decided to go for a combination of both; I used the noxfile to build up groups of features to then pass on to cargo hack. It probably wouldn't have been much harder for us to use itertools.combinations to invoke cargo test directly but it's nice to use the higher-level tool and we already use lots of tools from taiki-e 🚀 .

test-feature-powerset:
needs: [fmt]
if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || (github.event_name != 'pull_request' && github.ref != 'refs/heads/main') }}
runs-on: ubuntu-latest
Copy link
Member Author

Choose a reason for hiding this comment

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

We could maybe extend to run this for each OS, but my expectation is that there's unlikely to be platform differences caught out by testing specific feature combinations. It seemed wasteful.

Similarly, if running a full test is too slow, we could downgrade to a check.

Copy link
Member

Choose a reason for hiding this comment

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

Similarly, if running a full test is too slow, we could downgrade to a check.

I think I'd prefer to start with a simple compile check instead of full test build. (The runtime is also where more platform-specific behaviour could lurk, and hence I'd say that single-platform-compile-check is a more natural working point.)

@utkarshgupta137
Copy link

That's what we do for our CI (though it is hard to compare library vs binary). We run all tests with no features enabled & all features enabled (Mac once a day, Linux every time, no Windows). Then we use cargo-hack to run check/clippy for all features one-by-one, but no powerset (that probably makes sense for a library though).

@davidhewitt
Copy link
Member Author

The "powerset" I added here has just got three "groups" if you like - abi3, all optional features, and all experimental features. That powerset creates just 8 test runs, which is hopefully a manageable number for a single CI job (especially as I opted to skip doctests for this job).

noxfile.py Outdated Show resolved Hide resolved
noxfile.py Outdated Show resolved Hide resolved
noxfile.py Outdated Show resolved Hide resolved
noxfile.py Outdated Show resolved Hide resolved
@davidhewitt
Copy link
Member Author

Ufff I missed installing rust-src, was why the tests failed I think. @LilyFoote just ran into the same thing locally, which is what jogged my memory. (#3575)

Copy link
Member

@adamreichold adamreichold left a comment

Choose a reason for hiding this comment

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

LGTM now. Only open question is whether to downgrade this to check builds (which I would prefer, but not strongly enough to further delay this).

@davidhewitt
Copy link
Member Author

Let's just go for check. The odds of a bug actually existing in a codepath which exists only in an edge case combination which isn't run in the rest of CI seems not worth the CI cycles for now.

@davidhewitt
Copy link
Member Author

Thanks for the rounds of review here! I will get on with preparing that patch release once this merges.

@davidhewitt davidhewitt added this pull request to the merge queue Feb 22, 2024
Merged via the queue into PyO3:main with commit c4f6665 Feb 22, 2024
69 checks passed
@davidhewitt davidhewitt deleted the either-type branch February 22, 2024 08:51
davidhewitt added a commit that referenced this pull request Feb 22, 2024
* fix `either` feature conditional compilation, again

* test feature powerset in CI

* install `rust-src` for feature powerset tests

* review: adamreichold feedback

* Fix one more case of redundant imports.

* just check feature powerset for now

---------

Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
davidhewitt added a commit that referenced this pull request Feb 23, 2024
* fix `either` feature conditional compilation, again

* test feature powerset in CI

* install `rust-src` for feature powerset tests

* review: adamreichold feedback

* Fix one more case of redundant imports.

* just check feature powerset for now

---------

Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants