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

MRG: Use caching in Github Actions and Azure Pipelines #8695

Merged
merged 47 commits into from
Jan 6, 2021

Conversation

GuillaumeFavelier
Copy link
Contributor

@GuillaumeFavelier GuillaumeFavelier commented Jan 4, 2021

This PR follows #8685 (comment) and attempts to solve the recent failures related to testing data download.

ToDo:

  • Use $HOME for path variable
  • Use caching for Azure too

@GuillaumeFavelier GuillaumeFavelier self-assigned this Jan 4, 2021
id: cache-dataset
with:
path: /home/runner/mne_data
key: ${{ runner.os }}-dataset
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to separate by OS, the data files should all be the same

@GuillaumeFavelier
Copy link
Contributor Author

Among the first batch of runners, no one detected the cache:

Run actions/cache@v2
Cache not found for input keys: macOS-dataset

and

Run actions/cache@v2
Cache not found for input keys: Linux-dataset

Failing skips the Post Cache dataset step.

I'll push an empty commit to confirm that they at least restore the cache successfully.

@GuillaumeFavelier
Copy link
Contributor Author

compat_old was the first to finish Post Cache dataset with:

Post job cleanup.
/bin/tar --posix --use-compress-program zstd -T0 -cf cache.tzst -P -C /home/runner/work/mne-python/mne-python --files-from manifest.txt
Cache saved successfully

@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Jan 4, 2021

I see no problem at restoration 👌 :

Cache dataset

Run actions/cache@v2
Received 79691776 of 1053312637 (7.6%), 75.9 MBs/sec
Received 209715200 of 1053312637 (19.9%), 99.9 MBs/sec
Received 360710144 of 1053312637 (34.2%), 114.6 MBs/sec
Received 486539264 of 1053312637 (46.2%), 115.9 MBs/sec
Received 629145600 of 1053312637 (59.7%), 119.9 MBs/sec
Received 750780416 of 1053312637 (71.3%), 119.2 MBs/sec
Received 864026624 of 1053312637 (82.0%), 117.6 MBs/sec
Received 981467136 of 1053312637 (93.2%), 116.9 MBs/sec
Received 1053312637 of 1053312637 (100.0%), 72.2 MBs/sec
Cache Size: ~1005 MB (1053312637 B)
/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/6a73b959-0e9e-4b55-b734-c336d86abe67/cache.tzst -P -C /home/runner/work/mne-python/mne-python
Cache restored from key: Linux-dataset

Download dataset

Run ./tools/github_actions_download.sh
Using default location ~/mne_data for testing...
Attempting to create new mne-python configuration file:
/home/runner/.mne/mne-python.json

@larsoner
Copy link
Member

larsoner commented Jan 4, 2021

Do you want to try dealing with testing dataset version.txt number mismatches here, or do you want me to open a quick PR for this?

@GuillaumeFavelier
Copy link
Contributor Author

You'll probably be more efficient than me 😅 . Go ahead if you have the time.

@larsoner
Copy link
Member

larsoner commented Jan 4, 2021

Will do now, could really use something in my wheelhouse to jump-start things over here...

@larsoner
Copy link
Member

larsoner commented Jan 4, 2021

@GuillaumeFavelier if you want to look into it, we should do the same for Azure

https://dev.azure.com/mne-tools/mne-python/_build/results?buildId=10834&view=logs&jobId=f8b184f0-8536-5d07-cb2e-df31a09e5d0f&j=f8b184f0-8536-5d07-cb2e-df31a09e5d0f&t=417aa5f0-1d30-5c85-3b8c-27e749125871

@larsoner
Copy link
Member

larsoner commented Jan 4, 2021

@GuillaumeFavelier you can use something like the following in a one-liner tools/get_testing_version.sh script that could be used with each action:

$ grep -oP "(?<=testing=')[0-9.]*(?=')" mne/datasets/utils.py
0.112

When Dan's #8679 is in progress (probably after my PR then yours) then this line can probably be adjusted fairly easily

@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Jan 5, 2021

Checking the key based on the testing version is a success!

Cache testing data

Run actions/cache@v2
Cache not found for input keys: 0.112

@GuillaumeFavelier
Copy link
Contributor Author

The Perl extension is not available on MacOS:

usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
	[-e pattern] [-f file] [--binary-files=value] [--color=when]
	[--context[=num]] [--directories=action] [--label] [--line-buffered]
	[--null] [pattern] [file ...]
Error: Process completed with exit code 2.

@GuillaumeFavelier
Copy link
Contributor Author

Also, the cache is different depending on the OS:

On MacOS:

Run actions/cache@v2
Cache not found for input keys: 0.112

For the others (on Linux):

Cache restored from key: 0.112

@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Jan 6, 2021

Because there is a . in 0.112 it is interpreted as a file (instead of a string) by Azure...

Resolving key:
 - key0.112 [file] (not found)
##[error]One or more errors occurred. (File not found: key0.112)
Finishing: Cache testing data

And no way to make their tip work since it's not a fixed string but it comes from a variable:

image

I'll sed the . by - to see

@GuillaumeFavelier
Copy link
Contributor Author

I don't know what to say 🤦

Resolving key:
 - 0-112 [string]
Resolved to: 0-112
ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session a090b4b2-8116-473d-833f-0e69d60908b7
Getting a pipeline cache artifact with one of the following fingerprints:
Fingerprint: `0-112`
There is a cache miss.
ApplicationInsightsTelemetrySender correlated 1 events with X-TFS-Session a090b4b2-8116-473d-833f-0e69d60908b7
Finishing: Cache testing data

@GuillaumeFavelier
Copy link
Contributor Author

The jobs on Windows detected the key:

Resolving key:
 - 0-112 [string]
Resolved to: 0-112
ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session 77543406-ba53-47b0-a210-8120a5abf696
Getting a pipeline cache artifact with one of the following fingerprints:
Fingerprint: `0-112`
There is a cache hit: `0-112`

And restored the cache correctly

Folders: 103
Files: 738
Size:       1613467701
Compressed: 452608
Process exit code: 0
Cache restored.

But the data are downloaded anyway because the path is different on Windows.

@larsoner
Copy link
Member

larsoner commented Jan 6, 2021

@GuillaumeFavelier
Copy link
Contributor Author

GuillaumeFavelier commented Jan 6, 2021

Hm... But for some reason it downloads more no?

Restoring the cache:

Expected size to be downloaded: 1,614.1 MB

Compared to master:

Downloading archive mne-testing-data-0.112.tar.gz to C:\Users\VssAdministrator\mne_data
Downloading https://codeload.github.com/mne-tools/mne-testing-data/tar.gz/0.112 (1000.0 MB)

@GuillaumeFavelier GuillaumeFavelier changed the title WIP: Use caching in Github Actions WIP: Use caching in Github Actions and Azure Pipelines Jan 6, 2021
@larsoner
Copy link
Member

larsoner commented Jan 6, 2021

Hm... But for some reason it downloads more no?

That's probably the uncompressed size, vs the download which is compressed.

@GuillaumeFavelier
Copy link
Contributor Author

Unrelated failure on linux / conda / py3.8

mne/viz/tests/test_3d.py::test_plot_source_estimates[testing_data-testing_data-pyvista-surface-vector] PASSED [  6%]
mne/viz/tests/test_3d.py::test_plot_source_estimates[testing_data-testing_data-pyvista-surface-None] PASSED [  6%]
mne/viz/tests/test_3d.py::test_plot_source_estimates[testing_data-testing_data-pyvista-volume-vector] PASSED [  6%]
mne/viz/tests/test_3d.py::test_plot_source_estimates[testing_data-testing_data-pyvista-volume-None] PASSED [  6%]
mne/viz/tests/test_3d.py::test_plot_source_estimates[testing_data-testing_data-pyvista-mixed-vector] PASSED [  6%]
Fatal Python error: Segmentation fault

Thread 0x00007fa9133ad700 (most recent call first):
  File "/usr/share/miniconda/envs/mne/lib/python3.8/threading.py", line 306 in wait
  File "/usr/share/miniconda/envs/mne/lib/python3.8/threading.py", line 558 in wait
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/tqdm/_monitor.py", line 59 in run
  File "/usr/share/miniconda/envs/mne/lib/python3.8/threading.py", line 932 in _bootstrap_inner
  File "/usr/share/miniconda/envs/mne/lib/python3.8/threading.py", line 890 in _bootstrap

Current thread 0x00007fa953cb6740 (most recent call first):
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pyvistaqt/plotting.py", line 696 in set_icon
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pyvistaqt/plotting.py", line 597 in __init__
  File "/home/runner/work/mne-python/mne-python/mne/viz/backends/_pyvista.py", line 95 in build
  File "/home/runner/work/mne-python/mne-python/mne/viz/backends/_pyvista.py", line 199 in __init__
  File "/home/runner/work/mne-python/mne-python/mne/viz/backends/renderer.py", line 38 in _get_renderer
  File "/home/runner/work/mne-python/mne-python/mne/viz/_brain/_brain.py", line 427 in __init__
  File "/home/runner/work/mne-python/mne-python/mne/viz/_3d.py", line 1904 in _plot_stc
  File "/home/runner/work/mne-python/mne-python/mne/viz/_3d.py", line 1824 in plot_source_estimates
  File "<decorator-gen-142>", line 22 in plot_source_estimates
  File "/home/runner/work/mne-python/mne-python/mne/source_estimate.py", line 653 in plot
  File "/home/runner/work/mne-python/mne-python/mne/viz/tests/test_3d.py", line 676 in test_plot_source_estimates
  File "/home/runner/work/mne-python/mne-python/mne/utils/_testing.py", line 251 in dec
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/python.py", line 183 in pytest_pyfunc_call
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/python.py", line 1641 in runtest
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/runner.py", line 162 in pytest_runtest_call
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/runner.py", line 255 in <lambda>
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/runner.py", line 311 in from_call
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/runner.py", line 254 in call_runtest_hook
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/runner.py", line 215 in call_and_report
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/runner.py", line 126 in runtestprotocol
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/runner.py", line 109 in pytest_runtest_protocol
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/main.py", line 348 in pytest_runtestloop
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/main.py", line 323 in _main
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/main.py", line 269 in wrap_session
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/main.py", line 316 in pytest_cmdline_main
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/callers.py", line 187 in _multicall
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/manager.py", line 84 in <lambda>
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/manager.py", line 93 in _hookexec
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/pluggy/hooks.py", line 286 in __call__
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/config/__init__.py", line 162 in main
  File "/usr/share/miniconda/envs/mne/lib/python3.8/site-packages/_pytest/config/__init__.py", line 185 in console_main
  File "/usr/share/miniconda/envs/mne/bin/pytest", line 8 in <module>
./tools/github_actions_test.sh: line 22:  4547 Segmentation fault      (core dumped) pytest -m "${CONDITION}" --tb=short --cov=mne --cov-report xml -vv ${USE_DIRS}
mne/viz/tests/test_3d.py::test_plot_source_estimates[testing_data-testing_data-pyvista-mixed-None] 
Error: Process completed with exit code 139.

Maybe one last empty commit for testing but everything is ok for me. Is there something missing @larsoner ?

@larsoner
Copy link
Member

larsoner commented Jan 6, 2021

Maybe one last empty commit for testing but everything is ok for me. Is there something missing @larsoner ?

I don't think we need the empty commit, I'll just restart the segfaulted GitHub actions build, and it looks like everything else should be okay. Will merge once CIs are happy

@GuillaumeFavelier GuillaumeFavelier changed the title WIP: Use caching in Github Actions and Azure Pipelines MRG: Use caching in Github Actions and Azure Pipelines Jan 6, 2021
@larsoner larsoner merged commit c4215cb into mne-tools:master Jan 6, 2021
@larsoner
Copy link
Member

larsoner commented Jan 6, 2021

Thanks @GuillaumeFavelier !

@GuillaumeFavelier GuillaumeFavelier deleted the maint/cis branch January 6, 2021 14:40
@GuillaumeFavelier
Copy link
Contributor Author

Something interesting about caching:

The cache is scoped to the key and branch. The default branch cache is available to other branches.

Reference: https://github.com/actions/cache#cache-scopes

larsoner added a commit to larsoner/mne-python that referenced this pull request Jan 7, 2021
* upstream/master:
  MAINT: Actually use all caches (mne-tools#8702)
  MRG: Prototype of notebook viz (ipyvtk) (mne-tools#8503)
  MRG: Use caching in Github Actions and Azure Pipelines (mne-tools#8695)
cbrnr pushed a commit to cbrnr/mne-python that referenced this pull request Jan 15, 2021
* First test [skip azp][skip circle]

* Download anyway [skip azp][skip circle]

* Unify cache key [skip azp][skip circle]

* Test new key

* Test linux_pip [skip azp][skip circle]

* Try again [skip azp][skip circle]

* Deploy to all jobs

* Try another syntax

* Test new key format [skip azp][skip circle]

* Use home env variable

* Fix key [skip azp][skip circle]

* Try naive version on Azure

* Try again [skip github][skip circle]

* Try again [skip github][skip circle]

* Try another syntax [skip github][skip circle]

* Try again [skip github]

* Try again [skip github]

* Try again [skip github]

* Try again [skip github]

* Try again [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Test again? [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Debug variable [skip github]

* Test new key format [skip github]

* Test new key format [skip github]

* Test new key format [skip github]

* Try again [skip github]

* Try again [skip github]

* Try again [skip github]

* Deploy to all jobs

* Try another syntax [skip github][skip circle]

* Try another syntax [skip github][skip circle]

* Try another syntax [skip github][skip circle]

* Test again
@larsoner larsoner mentioned this pull request Jun 3, 2022
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