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

ENH: Fix GitHub actions notebook test workflow #96

Merged
merged 4 commits into from
Mar 27, 2021
Merged

ENH: Fix GitHub actions notebook test workflow #96

merged 4 commits into from
Mar 27, 2021

Conversation

jhlegarreta
Copy link
Contributor

Fix GitHub actions notebook test workflow

Fixes #31.

Download the data to the path expected by the notebooks.
Define explicitly the Jupyter notebooks to be tested.

Although not strictly necessay since notebooks do not depend on each other's
results, the notebooks are listed in the order they are expected to be run (by
default `pytest` collects them in alphabetical order).
Change GitHub Actions test workflow to run weekly instead of on `push` events.
@jhlegarreta jhlegarreta added the type:enhancement Propose enhancement to the lesson label Mar 27, 2021
@jhlegarreta jhlegarreta requested review from kaitj and josephmje March 27, 2021 20:25
@netlify
Copy link

netlify bot commented Mar 27, 2021

Deploy preview for carpentries-dmri ready!

Built with commit 74da157

https://deploy-preview-96--carpentries-dmri.netlify.app

@jhlegarreta
Copy link
Contributor Author

jhlegarreta commented Mar 27, 2021

We will not know if this works until we merge it. And hopefully we can know by tomorrow if we merge it before.

After what we have discussed so far about the CI tests and cross referencing PRs #41 and #46, this PR proposed to:

  • Leave the preprocessing notebook out for now due to our concerns about its dependencies on FSL and ANTs.
  • Run the solution files for the notebooks having exercises.
  • Run the tests once a week.

As far as I see, our notebooks do not have fill-in-the-gaps like exercises as it was the case in previous versions (cross referencing #85 (comment)). However, I've seen that exercises are only stated in the Markdown files, being the code/*.ipynb and code/*/solutions/*.ipynb files exactly the same. Not sure about the rationale behind (see the related comment in #85 (comment)), but that is something to be addressed in a separate PR.

Adding the non-solutions files to the CI tests is left for a separate PR.

If at some point we switch to fill-in-the-gaps like exercises:

If the weekly tests pass after this PR is merged:

Triggering tests on PRs might be considered once all the above has hopefully been addressed and we are still under the time limit bill. Or we may think of triggering the tests only for the lightest notebooks on PRs, reduce the number of Python versions tested while keeping the weekly cron job for all notebooks.

So in summary, this PR is ready to be merged and the rest of the enhancements can come in separate PRs.

Copy link
Contributor

@josephmje josephmje left a comment

Choose a reason for hiding this comment

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

Thanks for this @jhlegarreta. Could you try changing the cache key?
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}

and restore keys to

restore-keys: |
    ${{ runner.os }}-pip-${{ matrix.python-version }}-
    ${{ runner.os }}-pip-

Fix the cache key.
@jhlegarreta
Copy link
Contributor Author

@josephmje Done in 74da157.

@jhlegarreta jhlegarreta merged commit a8f5d6a into carpentries-incubator:master Mar 27, 2021
@jhlegarreta jhlegarreta deleted the FixGitHubActionsNotebookTestWorkflow branch March 27, 2021 21:49
@jhlegarreta
Copy link
Contributor Author

jhlegarreta commented Apr 4, 2021

Also, I've seen the CI output from yesterday:
https://github.com/carpentries-incubator/SDC-BIDS-dMRI/runs/2262435829?check_suite_focus=true

We made progress (intro and DTI passing), but now the CSD fails due to a timeout. Cells have 30 minutes to do their job, which seem largely enough; especially for the one failing, which is the FRF display. That cell takes almost no time when running the notebook on the browser, but I've tested locally with the pytest command, and it shows the same behavior as in the CI. A few thoughts:

  • I've done some debugging and the statements that trigger this behavior are the window.snapshot calls.
  • Mark the relevant cells with # NBVAL_SKIP. Have tried locally and it works. Can be a distracting element: even if we aim for the solutions for now (including CSD and prob tracking eventually), at term we'll want to check the non-solution notebooks, so we'll end up by including it in the relevant cells. Also, it means that we should make statements related to the skipped cells (e.g. scene.rm(response_actor)) either dwell in the same cell or mark to be skipped as well, and splitting the cells that do some processing and visualization to be able to mark with # NBVAL_SKIP only those calling the visualization methods.
  • I've tried locally with the --nbval flag instead of --nbval-lax (have put testing the CSD and followed by another notebook to a shell file and have called it): the second notebook gets tested regardless of the flag provided, so not sure why the CI build shows a different behavior.
  • The execution does not follow because we are not allowing pytest to collect the notebooks by itself. We could try to ignore tests with the --ignore, e.g.:
pytest --nbval -v code/**/*.ipynb --ignore=code/preprocessing/**/*.ipynb

or

pytest --nbval-lax -v code/**/*.ipynb --ignore=code/preprocessing/**/*.ipynb

I've been unable to successfully exclude the preprocessing notebobok even.

We'd still need to mark the problematic cells with # NBVAL_SKIP to see the tests passing.

Also, that would collect the tests in alphabetic order (i.e. CSD before any other one for the current episodes). Although not a problem, does not follow the lesson workflow.

So we're left with the following possibility to see the tests passing:

  • Refactor the cells having some visualization part using fury to isolate such parts and skip them by adding the # NBVAL_SKIP flag to the visualization cells.

@jhlegarreta
Copy link
Contributor Author

So we're left with the following possibility to see the tests passing:

  • Refactor the cells having some visualization part using fury to isolate such parts and skip them by adding the # NBVAL_SKIP flag to the visualization cells.

Cross-referencing #128.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Propose enhancement to the lesson
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Github Actions Test Failure
2 participants