Repository navigation
TST: Cache .hypothesis - #11161
TST: Cache .hypothesis#11161pllim wants to merge 2 commits into
Conversation
| python-version: ${{ matrix.python }} | ||
| - uses: actions/cache@v2 | ||
| with: | ||
| path: .hypothesis |
There was a problem hiding this comment.
Is this path specification enough? I have no idea where that directory is supposed to be. Is it in some special tox dir, home, root, or ...? How do I find out?
There was a problem hiding this comment.
I need someone very familiar with tox + hypothesis to chime in here.
There was a problem hiding this comment.
Tox runs tests in .tmp/{envname}, so the .hypothesis directory should be created there, but I don't know how to run hypothesis tests locally to check. I guess in actions {envname} should always be ${{ matrix.toxenv }}, so it should work with something like path: .tmp/${{ matrix.toxenv }}/.hypothesis, but I think that would mean that each env would have its own cache...
If we want to share the cache across envs, we could modify tox's config to run in .tmp/ instead of .tmp/{envname}. Nothing is generated in this directory except .hypothesis, so I don't think we need a per-env tmp directory.
There was a problem hiding this comment.
Does it matter if the path is different as long as key is the same? 🤔
There was a problem hiding this comment.
I asked myself the same question ;). I think yes, because actions will store and restore this specific path.
There was a problem hiding this comment.
@saimn AFAICT you're correct here. Caching per-env would be fine, or you can configure Hypothesis to use a particular path (e.g. the repo root) - see https://github.com/numpy/numpy/blob/91d9bbebc159ada6cccd0e1fcec1926e26b19c6f/numpy/conftest.py#L17-L21.
I kinda like this approach because it means that updating the tox env won't discard the cache, which is going to be nice for local development too.
|
I have no idea what's in this directory and if it's really useful to cache it. Maybe cc @Zac-HD if you can provide some insights ? |
|
Here's the Hypothesis docs about the database. In short:
I can't answer questions about how GitHub Actions caching works, but that's the Hypothesis side. Always happy to help with follow-up questions etc. too 🙂 |
|
Thanks @Zac-HD , really useful ! |
11aaed0 to
b46b884
Compare
|
I modified the code to make the |
|
CI failure is unrelated. This is what the log looks like on first run: I guess we'll see what it looks like on subsequent pushes after a successful CI run. I expect something like "cache hit, restoring cache" or something. 🤞 |
b46b884 to
7be76dd
Compare
|
At the end of a successful run, you will see this: But if I understand https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows#example-of-search-priority correctly, when a new PR is opened and |
|
At the next run, you will see something like this: So, I guess it is not going to be a problem as far as cache size limit is concerned... |
Yes! That's what we want ;) |
🚨🚨🚨 That's not desirable though - if the cached database is loaded and then updated, we'd want GitHub Actions to update the cache. That could probably be forced by adding e.g. build number as a final key suffix? So there would always be a cache miss, and then load the most recent alternative... not exactly the intended use, but it would work.
TLDR: it's designed not to be too large, I'd be surprised if the cache ever got to 1GB. Details: the maximum possible size of each value is 8 KiB, but typical sizes are more like tens of bytes with a right-tail up to ~hundreds or ~1K at the largest realistic end. Each key (=test) can have in principle unlimited keys; but in practice it shouldn't go above tens unless you have failing examples - and latter passing runs discard now-passing entries. Running fuzzing mode can grow it further, but it's still reasonably bounded and you're not doing that in CI anyway. |
|
(Unrelated: I think both CircleCI and astropy-bot hate me now. One runs when I said to skip, the other one just never runs when I open a PR.) |
14335ca to
ee510df
Compare
|
Here is what the logs look like now: Successful runThe This also means that if someone rerun this workflow with the same Run ID, it will restore but not write the cache, is that okay, @Zac-HD ? Failed runThis job has been failing for a while, so a cache was never created. You can see that the run ID is properly populated here, hiding my shame a little. Since it is still failing, a cache is also not written out. |
I think it's unlikely enough to ever be a problem that we should just ignore the possibility - we'd only care if the repeat run found a bug that the first run didn't. You could use eg unix timestamps instead of run ID, but I'd just leave it as is. |
|
Okay, I'll leave it as-is then, because I am not sure how to do the timestamp thing in an OS-agnostic way and I don't feel like dabbling in Powershell for the Windows job. 😬 Thanks for the review and advice! 😸 |
|
It's been a while and we haven't seen any problems that indicates that we actually need this. Should we close without merge? |
|
@saimn voted to close. Can always revisit if the need arises. |
The 'problem' that caching On the other hand, TLDR; closing this is fine 👍 |
Description
This pull request is to address the caching
.hypothesisportion of #11038 using actions/cache according to advise at #11038 (comment) . I guess it makes the most sense to insert this step right after setting up Python but before installing dependencies.Open questions