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

separate tox testenvs to cache CRDS reference files retrieved by initial test #7323

Closed
wants to merge 35 commits into from

Conversation

zacharyburnett
Copy link
Collaborator

@zacharyburnett zacharyburnett commented Oct 28, 2022

This PR sets up dependent CI jobs and attempts to cache CRDS reference files, succeeding #6867 with suggestions from #6867 (review).

Checklist for maintainers

  • added entry in CHANGES.rst within the relevant release section
  • updated or added relevant tests
  • updated relevant documentation
  • added relevant milestone
  • added relevant label(s)
  • ran regression tests, post a link to the Jenkins job below.
    How to run regression tests on a PR
  • Make sure the JIRA ticket is resolved properly

Copy link
Collaborator

@jdavies-st jdavies-st left a comment

Choose a reason for hiding this comment

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

This looks good! Some comments below.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
tox.ini Outdated Show resolved Hide resolved
tox.ini Outdated Show resolved Hide resolved
.github/workflows/ci.yml Outdated Show resolved Hide resolved
.github/workflows/ci_cron.yml Outdated Show resolved Hide resolved
@zacharyburnett zacharyburnett force-pushed the cache_crds branch 2 times, most recently from 01ee2df to 2013cf4 Compare October 31, 2022 19:34
@codecov
Copy link

codecov bot commented Oct 31, 2022

Codecov Report

Base: 79.66% // Head: 79.63% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (dc70d1a) compared to base (91cde26).
Patch has no changes to coverable lines.

❗ Current head dc70d1a differs from pull request most recent head 1b703b3. Consider uploading reports for the commit 1b703b3 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7323      +/-   ##
==========================================
- Coverage   79.66%   79.63%   -0.04%     
==========================================
  Files         411      411              
  Lines       37347    37350       +3     
==========================================
- Hits        29752    29743       -9     
- Misses       7595     7607      +12     
Flag Coverage Δ *Carryforward flag
nightly 79.61% <ø> (-0.04%) ⬇️ Carriedforward from 88b8747
unit 51.98% <ø> (-0.01%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Impacted Files Coverage Δ
jwst/tweakreg/tweakreg_catalog.py 89.47% <0.00%> (-5.27%) ⬇️
jwst/tweakreg/tweakreg_step.py 55.00% <0.00%> (-4.62%) ⬇️
jwst/regtest/conftest.py 88.04% <0.00%> (-1.64%) ⬇️
jwst/associations/lib/rules_level3_base.py 93.50% <0.00%> (-0.30%) ⬇️
jwst/lib/wcs_utils.py 78.57% <0.00%> (+3.57%) ⬆️
jwst/pipeline/calwebb_image3.py 88.63% <0.00%> (+4.54%) ⬆️
jwst/transforms/integration.py 92.85% <0.00%> (+7.14%) ⬆️
jwst/datamodels/integration.py 90.90% <0.00%> (+9.09%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@zacharyburnett zacharyburnett force-pushed the cache_crds branch 3 times, most recently from c849a15 to 752d22b Compare November 1, 2022 17:26
Copy link
Collaborator

@jdavies-st jdavies-st left a comment

Choose a reason for hiding this comment

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

This is a hard nut to crack.

I really like the refactor of tox.ini. Structurally much better and easier to work with, and importantly, a good distinction between checks and tests. 🚀

I don't like the needs: [ quick_test ] dependency, as this dramatically increases the runtime of the test suite, likely doubling it. And it seems the main reason behind it is to get CRDS caching to work. Would be better to get the caching to work and keep the flat, concurrent set of checks we already have, I think.

The main problem with the CRDS cache is that we are trying to restore a cache whose contents we are using to make a hash. But it needs to be there before we can hash it, but we need to hash it before it is restored. Chicken, egg.

The next-best thing would be to hash files that exist after repo checkout, or some other state that corresponds with a state of the CRDS cache. While the cache of files needed for the tests will not change with every increment of the default context, it's probably the best proxy we have. Of course it needs to be created first and cached before it can be used, so still the chicken-egg problem, which I recall having a helluva time trying to get sorted when I first implemented (then unimplemented) this caching long ago.

I've been pinging some ideas around today and might have a solution based off the nice tox refactor you did here. Look for a PR.

Comment on lines 46 to 49
- uses: actions/cache@v3
with:
path: .tox
key: tox-${{ matrix.toxenv }}-${{ env.pythonLocation }}-${{ runner.os }}-${{ hashFiles('pyproject.toml', 'setup.*') }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it is not a good idea to cache .tox, especially since the requirements in setup.cfg do not accurately represent the state of the packages installed on any given run of the CI. I.e. setup.cfg could not change for months, meanwhile there may be patch releases of numpy and other direct dependencies, or other indirect dependencies. This caching would mask such updates to dependencies and defeat the purpose of daily CI testing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, nevermind, I see this has been removed. 👍

Comment on lines 32 to +33
- name: Code style check
os: ubuntu-latest
python-version: 3.9
toxenv: style

toxenv: check-style
Copy link
Collaborator

Choose a reason for hiding this comment

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

These and the other 2 are already in the matrix above. Probably no need to add them here.

if: ${{ contains(matrix.toxenv,'-cov') }}
- run: pip install tox
- run: tox -e ${{ matrix.toxenv }}
quick_test:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the sole purpose of this quick_test to generate a cache that the other tests can use?

path: reference_files_hash.txt
test:
name: ${{ matrix.toxenv }} (Python ${{ matrix.python-version }}, ${{ matrix.os }})
needs: [ quick_test ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since these tests don't even kick off until quick_test is finished, this is going to ~double the runtime of the test suite.

Comment on lines -50 to -52
- name: Upload coverage to codecov
if: ${{ contains(matrix.toxenv,'-cov') }}
uses: codecov/codecov-action@v3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Removing coverage reporting here is probably a good idea since nothing is changing on master when this cron job runs.

matrix:
toxenv: [ test-xdist, test-oldestdeps, test-sdpdeps-xdist ]
python-version: [ '3.8', '3.9', '3.10', '3.11' ]
os: [ ubuntu-latest, macos-latest ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

And I don't think we should be running on macos. The runners are too slow, and they don't test anything extra compared to the linux runners. If our test suite was 3 minutes, fine. But it is over an hour on the macos runners.

Likewise, oldestdeps probably only needs to run on the oldest supported version of python (and in fact probably only can), and the sdpdeps probably only should run on whatever version of python DMS/SDP is currently using, python 3.9 currently, i.e. whatever our JenkinsfileRT says.

@jdavies-st
Copy link
Collaborator

jdavies-st commented Nov 3, 2022

The other thing to keep in mind is that caches created in branches cannot be used on master, though caches created on master can be used on branches.

https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache

So this complicates any rollout. Probably will have to be 2 successive PRs. Chicken. Egg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation Continuous Integration (CI) and testing automation tools installation testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants