Skip to content

Conversation

Liam-DeVoe
Copy link
Member

@Liam-DeVoe Liam-DeVoe commented Sep 7, 2025

(pending confirmation) closes #4442. Thanks to @pschanely and especially @jobh for getting to the bottom of this!

Comment on lines +310 to +318
@contextmanager
def with_register_backend(name, provider_cls):
try:
AVAILABLE_PROVIDERS[name] = provider_cls
yield
finally:
del AVAILABLE_PROVIDERS[name]


Copy link
Member Author

Choose a reason for hiding this comment

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

I'm naming this with the assumption that we'll migrate AVAILABLE_PROVIDERS to def register_backend(name, class_or_string) at some point

@jobh
Copy link
Contributor

jobh commented Sep 7, 2025

Nice! I don't have an informed opinion on the code changes, but I'll kick off a 50-repeat run of the reproducer on both windows and ubuntu. It usually failed at about 5 repeats, so if those pass I'll consider it solved.

(probably?) remove the cache rebuild added in #4518

Yes, most definitely! If it starts happening again we want to know.

@jobh
Copy link
Contributor

jobh commented Sep 7, 2025

The ubuntu runner got a probably unrelated error after ~20 repeats, https://github.com/HypothesisWorks/hypothesis/actions/runs/17525804945/job/49776013140

FAILED hypothesis-python/tests/crosshair/test_crosshair.py::test_crosshair_works_for_all_verbosities[3-21-50] - Failed: DID NOT RAISE <class 'AssertionError'>

I'll switch to windows runner and remove -x to complete.

Aside: Consider migrating the currently windows-specific CI job configuration to tox and switch f.x. one of the older python job to run the same config?

Copy link
Contributor

@jobh jobh left a comment

Choose a reason for hiding this comment

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

@Liam-DeVoe
Copy link
Member Author

The ubuntu runner got a probably unrelated error after ~20 repeats, https://github.com/HypothesisWorks/hypothesis/actions/runs/17525804945/job/49776013140

Agree this is unrelated - crosshair hitting timeouts on a particularly slow CI run, perhaps.

Aside: Consider migrating the currently windows-specific CI job configuration to tox and switch f.x. one of the older python job to run the same config?

I don't follow, what's the benefit of this? Is there some crosshair test or config which we're only running on windows, despite the check-crosshair-custom jobs on linux? (I don't know our windows CI particularly well)

@jobh
Copy link
Contributor

jobh commented Sep 8, 2025

Aside: Consider migrating the currently windows-specific CI job configuration to tox and switch f.x. one of the older python job to run the same config?

I don't follow, what's the benefit of this? Is there some crosshair test or config which we're only running on windows, despite the check-crosshair-custom jobs on linux? (I don't know our windows CI particularly well)

The benefit for this issue (in hindsight) would have been to quickly identify the trigger as being the combination of tests rather than the platform. That may never happen again of course, but the windows runner differs also in dependency versions. Duplicating the setup to another platform would make any error that happens only on windows more likely to be windows-specific.

But: from a quick glance I don't see that tests/crosshair is run anywhere else currently (as opposed to ~everything else under the crosshair profile)?

[edit: Sample toxified build matrix for windows+osx at the repurposed #4510)

@Liam-DeVoe
Copy link
Member Author

But: from a quick glance I don't see that tests/crosshair is run anywhere else currently (as opposed to ~everything else under the crosshair profile)?

Right, this seems to be the biggest problem. Probably we should add a new linux CI entry to test /tests/crosshair and any other missed test dirs that were previously windows-only? (or perhaps that's what you were proposing). Regardless it does seem good to move more things to tox.

@jobh
Copy link
Contributor

jobh commented Sep 9, 2025

But: from a quick glance I don't see that tests/crosshair is run anywhere else currently (as opposed to ~everything else under the crosshair profile)?

Right, this seems to be the biggest problem. Probably we should add a new linux CI entry to test /tests/crosshair and any other missed test dirs that were previously windows-only? (or perhaps that's what you were proposing). Regardless it does seem good to move more things to tox.

Yes. Technically, something like tests/numpy was also needed to create the prerequisite cache pressure, but that's going into the weeds. I created a new issue to follow up.

@Liam-DeVoe
Copy link
Member Author

Liam-DeVoe commented Sep 21, 2025

@Zac-HD just a quick check you're ok with the api of allowing provider class values in AVAILABLE_PROVIDERS a la AVAILABLE_PROVIDERS["hypothesis"] = HypothesisProvider, for classes that live in sub-namespaces and don't have an easy qualname. If that looks good I'll merge

@Zac-HD
Copy link
Member

Zac-HD commented Sep 21, 2025

@Zac-HD just a quick check you're ok with the api of allowing provider class values in AVAILABLE_PROVIDERS a la AVAILABLE_PROVIDERS["hypothesis"] = HypothesisProvider, for classes that live in sub-namespaces and don't have an easy qualname. If that looks good I'll merge

I'd prefer to keep it string-only, to encourage designs which only pay for importing the backend if that backend is actually used. (we do this for our Pytest plugin, for example)

But honestly writing a paragraph or two of docs about why and how to do that probably matters more, so if you want to go with docs + class support I won't object.

@Liam-DeVoe
Copy link
Member Author

I already wrote such a paragraph yep, encouraging string by default

Comment on lines 114 to 117
#: If you maintain a third-party backend, we strongly recommend providing an
#: absolute importable path, rather than a |PrimitiveProvider| class. Hypothesis
#: will defer importing class paths until required, which improves startup times
#: for tests which don't request the backend.
Copy link
Member

Choose a reason for hiding this comment

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

I already wrote such a paragraph yep, encouraging string by default

Nice! I think it's worth expanding on this though: "We strongly encourage plugin authors to ensure that import hypothesis does not automatically import your package, e.g. by registering a standalone _mypkg_hypothesis_plugin module rather than mypgk._hypothesis_plugin."

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the plugin example is confusing - it can be in a subdir as long as you're careful about imports - so I just said as much more explicitly

@Liam-DeVoe
Copy link
Member Author

Liam-DeVoe commented Oct 3, 2025

Finally dug into why the crosshair tests have been failing on this and other PRs, and it's because of our new CI detection. The crosshair profile previously inherited from the default profile, and now inherits from the ci profile, which causes failures under eg print_blob=True. I've changed it to inherit from default here to get things unstuck, though maybe we want to evaluate copying some of the ci settings to the crosshair profile under ci in the future.

@Liam-DeVoe Liam-DeVoe enabled auto-merge October 3, 2025 18:48
@Liam-DeVoe
Copy link
Member Author

Looks like this needs a codeowner approval @Zac-HD

@Liam-DeVoe Liam-DeVoe merged commit 70eda0f into HypothesisWorks:master Oct 4, 2025
92 of 94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Identical objects sometimes hashing differently during crosshair tests
3 participants