-
Notifications
You must be signed in to change notification settings - Fork 586
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
settings rationalization #535
Comments
|
I’m adding |
That's not the case - they have to be explicitly added to the autoclass declaration in settings.rst. It might be possible to make it the case though - I don't remember why there's an explicit list. |
|
I'd really like |
@Daenyth, is there a reason max_examples doesn't work for this use case? It's a significantly more robust way of controlling this sort of thing - the problem with timeout for this use case is that it causes the amount of testing you do to silently degrade as your tests get slower. |
|
Yes - I can set As for degrading tests - if we could hook into pytest's |
|
The whole issue is related to #197.
|
|
Also related: #697 |
|
I've run into Because it's a hypothesis utility/helper strategy that is generating this giant structure, I'm at a loss as to how to make this remotely user-friendly. If nothing is done, I have to add @settings(max_buffer=2**18) to all tests that make use of this utility, and new users of this utility will run into the same mysterious issue. A settings decorator on this strategy does nothing. I feel sure that changing settings from within the strategy's body is futil, since the buffer is part of the input. Recommendations? Could hypothesis auto-expand its buffer in this case? Is that a huge or small patch? |
|
The below patch seems to make things better. I feel sure you can think of something better though; it's only meant to serve as a strawman. Click to show patch |
|
Hmm. @DRMacIver can probably comment on whether this patch is a good idea - I suspect not, on the basis that it could lead to hard-to-find performance problems when it kicks in. (we'd also have to deprecate the setting, obviously) With Hypothesis as it is now though, needing 256MB of entropy is a huge amount! It's going to be super-slow, and may not minimise well. If you can share the code I'd be happy to comment directly; otherwise the generic advice includes things like checking limits in If you also have no control of the utility/strategy/helper, then you'll just have to live with setting the setting on each test (or changing |
I do have plans to do a certain amount of auto-expanding of the buffer at some point, but most of this is so that the buffer size can start low. In particular doubling it each time you exceed it as in your patch is not a good idea - the whole point of having the setting at all is to stop data getting unreasonably big. My main recommendation is that if you need this much buffer size, your users are going to have a bad time regardless of what the settings are, because the performance is going to be awful - you're also going to have to turn off most of the health checks to make it run for starters. What are you actually generating? Can you make it smaller somehow? |
One thing to look into here is that you could be routinely exceeding the buffer size simply because your data shrinks badly - what's supposed to happen is that if you exceed half the max buffer size Hypothesis essentially starts shrinking your example, but if your example doesn't shrink well this can backfire. One thing to look at is e.g. do you have smaller examples towards the left in |
|
|
I think I can make a good patch from this, and I have some rebuttals for
your objections (that I hope you'll like), but I'm going to take this
discussion to a pull request first.
…On Thu, Nov 23, 2017, 12:27 AM David R. MacIver ***@***.***> wrote:
Recommendations? Could hypothesis auto-expand its buffer in this case? Is
that a huge or small patch?
I do have plans to do a certain amount of auto-expanding of the buffer at
some point, but most of this is so that the buffer size can start *low*.
In particular doubling it each time you exceed it as in your patch is not a
good idea - the whole point of having the setting at all is to stop data
getting unreasonably big.
My main recommendation is that if you need this much buffer size, your
users are going to have a bad time regardless of what the settings are,
because the performance is going to be awful - you're also going to have to
turn off most of the health checks to make it run for starters.
What are you actually generating? Can you make it smaller somehow?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#535 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAnFSHGtiQlJ5U2kcFuDDDOQQgRc3t_iks5s5SxjgaJpZM4NCxzf>
.
|
I think it's really very unlikely that you're going to be able to make this approach work in a way that doesn't break a lot of existing well supported use cases. This isn't an easy problem, and the fixed buffer size is currently carrying a lot of weight in terms of how various cases are handled (deeply nested and recursive structures in particular). You're welcome to give it a try if you really want to, but I would be very surprised if this proved to be a promising direction because fundamentally the outcome you are trying to achieve is something that looks like an error for normal operation. |
|
@DRMacIver - can you update the top of this thread? e.g. I'm thinking about doing some aggressive pruning, with a view to removing some old settings entirely in Hypothesis 4. How does this plan sound:
In the absence of any proposal, I'm inclined to leave |
I actually have a concrete proposal for deprecating
Note that I'm still very against us dropping things with anything less than a six month deprecation timeline, and that opinion hasn't somehow changed while I was in quiet mode, so the tightness of the timeline for a release is somewhat irrelevant to the question of deprecating these. |
|
And another thing: deprecated settings using their default values should be omitted from the __repr__ - at least when the default is "pretend this doesn't exist anymore" (ie not |
I think the thing to do might be to add a |
|
That's the elegant version - problem is that e.g. the |
That's' why there's a flag you can set, so we can make some deprecated settings opt in to being included in the repr! But also we're well outside the 6 month period for timeout's deprecation, so we could just get rid of it in 4.0 (or rather switch it over to "doesn't do anything and is still deprecated, but assigning unlimited to it isn't an error" mode which we promised to do) |
|
To summarise a really annoying afternoon: it's tedious but fairly easy to remove Removing that setting is therefore impractical without building an equivalent mechanism for use in our tests, and at that point I'm not actually convinced we should remove it at all. |
I think there are two senses in which we can remove it and we'd probably been implicitly assuming the opposite ones (unless I'm misunderstanding why) - I'd interpreted remove as "hard code the value" and it sounds like you'd interpreted as removing the limit? Note BTW that there's an alternative equivalent to |
|
(I hope I'm being helpful.) I would like to see a system that derives the "max shrinks" from the Closer to current default behavior would be to allow up to 5x the deadline to be spent on the shrink process. If this is a good idea, I would spend time to contribute this patch. |
I'd also interpreted it as "hard-code the current default"... but missed the
I've already got most of a patch for #1211, so leave this one to me 😁 |
|
Yep, not quite finished over there - our test suite turns out to be really subtle sometimes. At least I'm confident that it'll work for anyone once it passes! |
Turns out that Since this difference does in fact get caught by our tests, I'm going to drop |
|
It turns out that (assuming my pull will be merged) there are only three settings left on the to-deprecate list! Due to the selection effects they are also the trickiest ones to get right, so I've moved our notes over to individual issues for discussion and hopefully action ✨ |
The Hypothesis settings system is currently a confusing mess of confusingness. It asks users to make decisions they can't possibly have sufficient information to make, and ties those decisions very closely to Hypothesis internals.
I think we should give serious consideration to deprecating most of them. This ties in to #534
Here is a rough list of what I think about specific settings:
database_file - not intrinsically bad, but redundant with database. May be worth considering making the database API more public and just using the database setting.deprecated in Various improvements to the database setting #1196strict - good. Sensible operational decision as to how the user wants to respond to Hypothesis deprecationsbad - deprecated in favour of normal warning control.timeout - not intrinsically bad from a user point of view but should probably go anyway due to Towards true non-flakiness #534now deprecatedAll of this should be done with a very careful deprecation process which preserves the current default behaviour, warns when you execute a behaviour that will change in future, and gives people an option to opt in to the future behaviour.
Pending Deprecation Plans
The following are suggested routes for some deprecations:
perform_health_check=Falseand suggestsuppress_health_check=list(HealthCheck)max_iterations, and default tonot_set- meaning five times max_examples (the longstanding factor before the default for that was reduced to speed up under coverage).stateful_step_countand set it tonot_setby default. Add amax_stepsproperty onGenericStateMachinewhich also defaults tonot_set(or maybeNone?). Determine actualmax_stepsin order of "Look on object, look on settings, use a default". When the deprecation plan moves to dropping it,The text was updated successfully, but these errors were encountered: