Skip to content

Conversation

@Liam-DeVoe
Copy link
Member

I'm finding this useful as a "post test-case callback" in hypofuzz. I'm hoping to put things like observation.metadata.data_status: Status and observation.metadata.choice_nodes in here, and replace any manual inspection of ConjectureData from HypofuzzProvider.

@Liam-DeVoe Liam-DeVoe force-pushed the provider-on-observability branch from 33094e2 to b2be76d Compare May 27, 2025 22:50
Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

per comment below, maybe we can use Provider.observe_test_case() instead of this new mechanism?

@Zac-HD
Copy link
Member

Zac-HD commented May 29, 2025

unrelated note: this line suggests that monkeypatching OBSERVABILITY_COLLECT_COVERAGE in the defining module won't work; we should probably import it differently since we've documented that it's patchable (and maybe a test???)

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

lgtm, let's ship it!

Comment on lines 845 to 856
return (
with_observation_callback(on_observation)
if (
self.settings.backend != "hypothesis"
# only for lifetime = "test_function" providers (guaranteed
# by this isinstance check)
and isinstance(self.provider, PrimitiveProvider)
# and the provider opted-in to observations
and self.provider.add_observability_callback
)
else nullcontext()
)
Copy link
Member

Choose a reason for hiding this comment

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

Seems cleaner as an if-statement and two returns than a ternary expression and one.

Copy link
Member Author

Choose a reason for hiding this comment

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

interesting! I disagree, but only very weakly

@Liam-DeVoe Liam-DeVoe enabled auto-merge May 31, 2025 19:19
@Liam-DeVoe Liam-DeVoe merged commit ab90309 into HypothesisWorks:master May 31, 2025
59 checks passed
@Liam-DeVoe Liam-DeVoe deleted the provider-on-observability branch June 1, 2025 02:27
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.

2 participants