From b2bbe8047d14eb1ff000f95bb0b6ec8c9c3b7a7e Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 11:00:13 +0200 Subject: [PATCH 01/12] reorder examples --- ...0_player_separate_process.py => 00_player_separate_process.py} | 0 examples/{00_peak_detection.py => 10_peak_detection.py} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename examples/{10_player_separate_process.py => 00_player_separate_process.py} (100%) rename examples/{00_peak_detection.py => 10_peak_detection.py} (100%) diff --git a/examples/10_player_separate_process.py b/examples/00_player_separate_process.py similarity index 100% rename from examples/10_player_separate_process.py rename to examples/00_player_separate_process.py diff --git a/examples/00_peak_detection.py b/examples/10_peak_detection.py similarity index 100% rename from examples/00_peak_detection.py rename to examples/10_peak_detection.py From 73765a55c9f8097967b338d480d0fd0e53f2d560 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 11:02:26 +0200 Subject: [PATCH 02/12] improve peak detector example --- examples/10_peak_detection.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/10_peak_detection.py b/examples/10_peak_detection.py index 8fa0e46ff..4b0e5da1f 100644 --- a/examples/10_peak_detection.py +++ b/examples/10_peak_detection.py @@ -288,6 +288,7 @@ def __init__( self._stream.notch_filter(100, picks=ch_name) sleep(bufsize) # prefill an entire buffer # peak detection settings + self._last_acq_time = None self._last_peak = None self._peak_candidates = None self._peak_candidates_count = None @@ -301,6 +302,10 @@ def detect_peaks(self) -> NDArray[np.float64]: The timestamps of all detected peaks. """ data, ts = self._stream.get_data() # we have a single channel in the stream + if self._last_acq_time is None: + self._last_acq_time = ts[-1] + elif self._last_acq_time == ts[-1]: + return np.array([]) # nothing new to do data = data.squeeze() peaks, _ = find_peaks( data, From 60b36c498f68f3ab50d5fa964134036bd7a5d183 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 11:11:52 +0200 Subject: [PATCH 03/12] update performance figure --- .../tutorials/qrs-detector-performance.png | Bin 13339 -> 9389 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/doc/_static/tutorials/qrs-detector-performance.png b/doc/_static/tutorials/qrs-detector-performance.png index 845ffd7c50416e8f79361212e81c31e22109e91e..82e3b4ed5b7ac346e6d07b765ab7963374920451 100644 GIT binary patch literal 9389 zcmeHtXH-*Z*Y-h1nIdAwf^ah#(LnCG_CvNR%cPK&pZR z(j`bQK_vu5K&00|5KsuA2}yv!w~zCz_xxp``rHB z)JXJu$?p*a5k2)UgR=;-DI7tBM!www|D)bM_z`|-`JS}#wIE#bC0)4YikMvRz3NHu z^>laM>+gEa$DQD)W4L9kFTZoso3vX?*d> zL#4maN!0JrUmXhjGWXf!#iGFrufKWP=R0f0=uMbxGlxgY?$M7q=~BV1A^Quw)PQ2kYgP`!k%wq{(h-f z$_eIjh;Q~MsB!mb?Kp6T^2Z;4q*l%DPq6=SsG3CRz3yK>H~QLzH#cfhhj;2Zh+M#` zd-cCKbm&l%!=1>;Op9z&73T&DkFFesk<#$&{p>~KPb8~ccy-gJ*!kpZ(G)CTz}*jF5FjFu8FXNCpqF88_+doM(U zj(OF=-OMd5cfF1fBXp`-E7#2ZcFxk0j;;@uk>fK!b!~Pos$IiQmCtutn5lEWtyemY zyz=(`*c3wHS+avugmeD&SIkB-ic6<05KryfiT*cYR}&bvHR<@eyhgNA43nXG8+aIZ%U z>`$jvYcl0>PocvLkFHF1hy7-08|!v0e-AM&?*;XR~n z7%MBI>ed=Xp*%Se(P(MyunU7Bb4g_Jj%>5o&mGxDv%|IW`*ckF^IXRL-DQVR{ z(yG6)MxpTdZRE58vugjDg>~GO?)=*?Z-_7;;A2MmE9PfXG*w_LC7OaS9X=)Gu8(i- zyG*=$L~K#-F>rNtt@-l7m^k{UxHp$*N4tPjS@(bGjVy;;2j zrYU>G@gYQM-}lFf5EMoQag6oIE$ue!&zl<>ZIN~6wtS4{KJSXrTNO|inI|K66PNqk zdcNzARH{1UNER&FRQbB6uGXzBG*^B*AfdC`>q+EPP8x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kE~X^6h$26->_7sZ@m9h_BbQx=%;`>UR@_ zI)Wv=N zJN080pi%VZeP{YfQVlsbg=Zo$n1THRap8@qKykgW)(!uu9gFK#%EukE=XaUBLY!AH zKav~0>=>pII{zL)Om8~+V+iTAU#(#4)qG~cJX@>+kFu=n1d)gk;3D|Wb8+IV{L`bi zC_jBi502d<^@r*FWN+@`iqSR=Y%1c`qYR1M-P6_wC z#uS}6Hc_W|*l5z!|6=#FYeiM~U$IWThE#$R-H%&p2v_3E-VDqWns$E|9+xT9b)(z5-M4_7Yld4#^3paf+jqKJ&3fpZ9I4z061 z@(`q0Sd63Gb^FlVeWwvVBGNwry9kmG^>K^GMNicMSzAa1v3t%LqB=YXRfW|otcGsr zGUhP+2&h1MBv$egC9{qCpRX7L#*s2dTH95Fh6A-3a-z&&S)wJZ=ggY+IT?H;C z3G_y6j^QQAxi0!Dq(Xv)?PKv~xM+457>aB+bOIbaQ=ND^*XVxE$4<&IZ%VZiM<%Ng z{$vWy`6D}pENpjzlx>plhgwkRLzsvpteI1?vg~Go8d67#PQg2M8T_RUmV8(Sl3~f{ z-nVNXBUfJDVS-3rBNEdiLk8{>w~%4ETs+?w()jiD?G&^w9atOL)UnR7J5shGpQ~%& zq@>`TX_4sJmjgmVOO(_U4SjTGEKaQqGj_A%}V+s1O0{OJn%W@-EwX)9-_gzm!cV*FYG>--T;xB{Qm-k z%A^n|>3+Oj7PFkhYZ^c@etZTAb_O{jO%hdF>29xXE;^Tqo@6>!hk<4xp+Q6f5(v%2 zX>zkdO0L9lzskC0~V8v7pDUxM Date: Thu, 30 May 2024 11:54:28 +0200 Subject: [PATCH 04/12] improve coverage and remove assert executor._shutdown --- mne_lsl/player/player_lsl.py | 6 +++--- mne_lsl/player/tests/test_player_lsl.py | 6 ++++++ mne_lsl/stream/_base.py | 2 +- mne_lsl/stream/stream_lsl.py | 14 +++++++------- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/mne_lsl/player/player_lsl.py b/mne_lsl/player/player_lsl.py index 982929db0..1290f9370 100644 --- a/mne_lsl/player/player_lsl.py +++ b/mne_lsl/player/player_lsl.py @@ -279,7 +279,7 @@ def _stream(self) -> None: else: self._outlet.push_chunk(data, timestamp=self._target_timestamp) self._stream_annotations(start, stop, start_timestamp) - except Exception as exc: + except Exception as exc: # pragma: no cover logger.error("%s: Stopping due to exception: %s", self._name, exc) self._del_outlets() self._reset_variables() @@ -296,8 +296,8 @@ def _stream(self) -> None: sleep(delay) try: self._executor.submit(self._stream) - except RuntimeError: - assert self._executor._shutdown # pragma: no cover + except RuntimeError: # pragma: no cover + pass # shutdown def _stream_annotations( self, start: int, stop: int, start_timestamp: float diff --git a/mne_lsl/player/tests/test_player_lsl.py b/mne_lsl/player/tests/test_player_lsl.py index 41a8ecfb4..2127c6c4f 100644 --- a/mne_lsl/player/tests/test_player_lsl.py +++ b/mne_lsl/player/tests/test_player_lsl.py @@ -114,6 +114,7 @@ def test_player_context_manager_raw_annotations(raw_annotations): with Player( raw_annotations, chunk_size=200, name=name, annotations=False ) as player: + assert player.running streams = resolve_streams(timeout=2) assert len(streams) == 1 assert streams[0].name == name @@ -122,6 +123,7 @@ def test_player_context_manager_raw_annotations(raw_annotations): assert len(streams) == 0 with Player(raw_annotations, chunk_size=200, name=name) as player: + assert player.running streams = resolve_streams(timeout=2) assert len(streams) == 2 assert any(stream.name == name for stream in streams) @@ -336,6 +338,7 @@ def test_player_annotations(raw_annotations, close_io): name = "Player-test_player_annotations" annotations = sorted(set(raw_annotations.annotations.description)) player = Player(raw_annotations, chunk_size=200, name=name) + assert f"Player: {name}" in repr(player) assert player.name == name assert player.fname == Path(raw_annotations.filenames[0]) streams = resolve_streams(timeout=0.1) @@ -410,7 +413,10 @@ def test_player_n_repeat(raw): player = Player( raw, chunk_size=200, n_repeat=4, name="Player-test_player_n_repeat-2" ) + assert player.n_repeat == 4 player.start() + assert player.n_repeat == 4 + assert player.running time.sleep((raw.times.size / raw.info["sfreq"]) * 1.8) assert player._executor is not None streams = resolve_streams(timeout=2) diff --git a/mne_lsl/stream/_base.py b/mne_lsl/stream/_base.py index e18ba2bf1..41c93a704 100644 --- a/mne_lsl/stream/_base.py +++ b/mne_lsl/stream/_base.py @@ -567,7 +567,7 @@ def get_data( "The Stream is not connected. Please connect to the stream before " "retrieving data from the buffer." ) - else: + else: # pragma: no cover logger.error( "Something went wrong while retrieving data from a connected " "stream. Please open an issue on GitHub and provide the error " diff --git a/mne_lsl/stream/stream_lsl.py b/mne_lsl/stream/stream_lsl.py index 323c03ac0..4c710b948 100644 --- a/mne_lsl/stream/stream_lsl.py +++ b/mne_lsl/stream/stream_lsl.py @@ -230,8 +230,8 @@ def _acquire(self) -> None: sleep(self._acquisition_delay) try: self._executor.submit(self._acquire) - except RuntimeError: - assert self._executor._shutdown # pragma: no cover + except RuntimeError: # pragma: no cover + pass # shutdown return # interrupt early # process acquisition window @@ -249,8 +249,8 @@ def _acquire(self) -> None: sleep(self._acquisition_delay) try: self._executor.submit(self._acquire) - except RuntimeError: - assert self._executor._shutdown # pragma: no cover + except RuntimeError: # pragma: no cover + pass # shutdown return # interrupt early if len(self._added_channels) != 0: refs = np.zeros( @@ -296,7 +296,7 @@ def _acquire(self) -> None: "argument or consider retrieving new samples more often with " "Stream.get_data()." ) - except Exception as error: + except Exception as error: # pragma: no cover logger.exception(error) self._reset_variables() # disconnects from the stream if os.getenv("MNE_LSL_RAISE_STREAM_ERRORS", "false").lower() == "true": @@ -305,8 +305,8 @@ def _acquire(self) -> None: try: sleep(self._acquisition_delay) self._executor.submit(self._acquire) - except RuntimeError: - assert self._executor._shutdown # pragma: no cover + except RuntimeError: # pragma: no cover + pass # shutdown def _reset_variables(self) -> None: """Reset variables define after connection.""" From 6976f984978fe9ae3dcef236c7090712f69ff218 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 13:30:56 +0200 Subject: [PATCH 05/12] fix missed --- examples/10_peak_detection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/10_peak_detection.py b/examples/10_peak_detection.py index 4b0e5da1f..9f0d5fed4 100644 --- a/examples/10_peak_detection.py +++ b/examples/10_peak_detection.py @@ -305,6 +305,7 @@ def detect_peaks(self) -> NDArray[np.float64]: if self._last_acq_time is None: self._last_acq_time = ts[-1] elif self._last_acq_time == ts[-1]: + self._last_acq_time = ts[-1] return np.array([]) # nothing new to do data = data.squeeze() peaks, _ = find_peaks( From 49cccb61b521ab5e5653d2b8214006a219c2b8d4 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 13:54:55 +0200 Subject: [PATCH 06/12] try composite action to install liblsl --- .github/actions/install-liblsl/action.yaml | 33 ++++++++++++++++++++++ .github/workflows/pytest.yaml | 26 ++--------------- 2 files changed, 35 insertions(+), 24 deletions(-) create mode 100644 .github/actions/install-liblsl/action.yaml diff --git a/.github/actions/install-liblsl/action.yaml b/.github/actions/install-liblsl/action.yaml new file mode 100644 index 000000000..796f799e7 --- /dev/null +++ b/.github/actions/install-liblsl/action.yaml @@ -0,0 +1,33 @@ +name: "Install liblsl" +description: "A composite action to install liblsl on different operating systems." + +runs: + using: "composite" + steps: + - name: Install liblsl (linux) + if: ${{ runner.os == 'Linux' }} + shell: bash + run: | + curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-jammy_amd64.deb -o liblsl-1.16.2-jammy_amd64.deb + sudo apt update + sudo apt install -y binutils libpugixml-dev qtbase5-dev qt5-qmake + sudo apt install -y ./liblsl-1.16.2-jammy_amd64.deb + rm liblsl-1.16.2-jammy_amd64.deb + - name: Install liblsl (macOS) + if: ${{ runner.os == 'macOS' }} + shell: bash + run: | + curl -L https://github.com/sccn/liblsl/releases/download/v1.16.0/liblsl-1.16.0-OSX_arm64.tar.bz2 -o liblsl-1.16.0-OSX_arm64.tar.bz2 + tar -xf liblsl-1.16.0-OSX_arm64.tar.bz2 + mv lib/liblsl.1.16.0.dylib . + echo "MNE_LSL_LIB=$PWD/liblsl.1.16.0.dylib" >> $GITHUB_ENV + rm -R lib include bin + rm liblsl-1.16.0-OSX_arm64.tar.bz2 + - name: Install liblsl (windows) + if: ${{ runner.os == 'Windows' }} + shell: bash + run: | + curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-Win_amd64.zip -o liblsl-1.16.2-Win_amd64.zip + 7z x -oliblsl liblsl-1.16.2-Win_amd64.zip + echo "MNE_LSL_LIB=$PWD/liblsl/bin/lsl.dll" >> $GITHUB_ENV + rm liblsl-1.16.2-Win_amd64.zip diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 9fe6f7bf3..feabf860e 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -28,30 +28,8 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install liblsl (linux) - if: ${{ matrix.os == 'ubuntu' }} - run: | - curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-jammy_amd64.deb -o liblsl-1.16.2-jammy_amd64.deb - sudo apt update - sudo apt install -y binutils libpugixml-dev qtbase5-dev qt5-qmake - sudo apt install -y ./liblsl-1.16.2-jammy_amd64.deb - rm liblsl-1.16.2-jammy_amd64.deb - - name: Install liblsl (macOS) - if: ${{ matrix.os == 'macos' }} - run: | - curl -L https://github.com/sccn/liblsl/releases/download/v1.16.0/liblsl-1.16.0-OSX_arm64.tar.bz2 -o liblsl-1.16.0-OSX_arm64.tar.bz2 - tar -xf liblsl-1.16.0-OSX_arm64.tar.bz2 - mv lib/liblsl.1.16.0.dylib . - echo "MNE_LSL_LIB=$PWD/liblsl.1.16.0.dylib" >> $GITHUB_ENV - rm -R lib include bin - rm liblsl-1.16.0-OSX_arm64.tar.bz2 - - name: Install liblsl (windows) - if: ${{ matrix.os == 'windows' }} - run: | - curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-Win_amd64.zip -o liblsl-1.16.2-Win_amd64.zip - 7z x -oliblsl liblsl-1.16.2-Win_amd64.zip - echo "MNE_LSL_LIB=$PWD/liblsl/bin/lsl.dll" >> $GITHUB_ENV - rm liblsl-1.16.2-Win_amd64.zip + - name: Install liblsl + uses: ./.github/actions/install-liblsl - name: Install dependencies run: | python -m pip install --progress-bar off --upgrade pip setuptools From 142e4f45cc32a708a558a9a4ba8c762198d8b489 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 14:00:54 +0200 Subject: [PATCH 07/12] use action everywhere --- .../action.yaml | 0 .github/workflows/doc.yaml | 9 ++----- .github/workflows/publish.yaml | 11 +++----- .github/workflows/pytest.yaml | 27 +++++++------------ .github/workflows/stubs.yaml | 9 ++----- 5 files changed, 16 insertions(+), 40 deletions(-) rename .github/actions/{install-liblsl => install-system-dependencies}/action.yaml (100%) diff --git a/.github/actions/install-liblsl/action.yaml b/.github/actions/install-system-dependencies/action.yaml similarity index 100% rename from .github/actions/install-liblsl/action.yaml rename to .github/actions/install-system-dependencies/action.yaml diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index d8542c15d..20acd498b 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -22,13 +22,8 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.11 - - name: Install linux dependencies - run: | - curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-jammy_amd64.deb -o liblsl-1.16.2-jammy_amd64.deb - sudo apt update - sudo apt install -y libpugixml-dev qtbase5-dev qt5-qmake optipng - sudo apt install -y ./liblsl-1.16.2-jammy_amd64.deb - rm liblsl-1.16.2-jammy_amd64.deb + - name: Install system dependencies + uses: ./.github/actions/install-system-dependencies - name: Install package run: | python -m pip install --progress-bar off --upgrade pip setuptools diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 9a3865571..2f265cccc 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -15,14 +15,9 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.11 - - name: Install linux dependencies - run: | - curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-jammy_amd64.deb -o liblsl-1.16.2-jammy_amd64.deb - sudo apt update - sudo apt install -y libpugixml-dev qtbase5-dev qt5-qmake optipng - sudo apt install -y ./liblsl-1.16.2-jammy_amd64.deb - rm liblsl-1.16.2-jammy_amd64.deb - - name: Install dependencies + - name: Install system dependencies + uses: ./.github/actions/install-system-dependencies + - name: Install package run: | python -m pip install --progress-bar off --upgrade pip setuptools python -m pip install --progress-bar off -e .[build,stubs] diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index feabf860e..41f76b0b5 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -28,9 +28,9 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install liblsl - uses: ./.github/actions/install-liblsl - - name: Install dependencies + - name: Install system dependencies + uses: ./.github/actions/install-system-dependencies + - name: Install package run: | python -m pip install --progress-bar off --upgrade pip setuptools python -m pip install --progress-bar off .[test] @@ -68,13 +68,9 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install liblsl & linux dependencies - run: | - curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-jammy_amd64.deb -o liblsl-1.16.2-jammy_amd64.deb - sudo apt update - sudo apt install -y binutils libpugixml-dev qtbase5-dev qt5-qmake - sudo apt install -y ./liblsl-1.16.2-jammy_amd64.deb - - name: Install dependencies + - name: Install system dependencies + uses: ./.github/actions/install-system-dependencies + - name: Install package run: | python -m pip install --progress-bar off --upgrade pip setuptools python -m pip install --progress-bar off .[test] @@ -117,14 +113,9 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - name: Install liblsl (linux) - run: | - curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-jammy_amd64.deb -o liblsl-1.16.2-jammy_amd64.deb - sudo apt update - sudo apt install -y binutils libpugixml-dev qtbase5-dev qt5-qmake - sudo apt install -y ./liblsl-1.16.2-jammy_amd64.deb - rm liblsl-1.16.2-jammy_amd64.deb - - name: Install dependencies + - name: Install system dependencies + uses: ./.github/actions/install-system-dependencies + - name: Install package run: | python -m pip install --progress-bar off --upgrade pip setuptools python -m pip install --progress-bar off .[test] diff --git a/.github/workflows/stubs.yaml b/.github/workflows/stubs.yaml index 07e48a621..18105fc96 100644 --- a/.github/workflows/stubs.yaml +++ b/.github/workflows/stubs.yaml @@ -22,13 +22,8 @@ jobs: uses: actions/setup-python@v5 with: python-version: 3.11 - - name: Install linux dependencies - run: | - curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-jammy_amd64.deb -o liblsl-1.16.2-jammy_amd64.deb - sudo apt update - sudo apt install -y libpugixml-dev qtbase5-dev qt5-qmake - sudo apt install -y ./liblsl-1.16.2-jammy_amd64.deb - rm liblsl-1.16.2-jammy_amd64.deb + - name: Install system dependencies + uses: ./.github/actions/install-system-dependencies - name: Install package run: | python -m pip install --progress-bar off --upgrade pip setuptools From e089c5719ff2d36fc0f8b152c96268803a190898 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 14:08:34 +0200 Subject: [PATCH 08/12] add dataset caching --- .../actions/get-testing-dataset/action.yaml | 23 +++++++++++++++++++ .../install-system-dependencies/action.yaml | 12 ++++++---- .github/workflows/pytest.yaml | 6 +++++ mne_lsl/datasets/testing.py | 2 +- 4 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 .github/actions/get-testing-dataset/action.yaml diff --git a/.github/actions/get-testing-dataset/action.yaml b/.github/actions/get-testing-dataset/action.yaml new file mode 100644 index 000000000..6f7b0a65e --- /dev/null +++ b/.github/actions/get-testing-dataset/action.yaml @@ -0,0 +1,23 @@ +name: "Get MNE-LSL testing dataset" +description: "A composite action to get MNE-LSL testing dataset from cache or remote." + +runs: + using: "composite" + steps: + - name: Get testing dataset version + shell: bash + run: | + curl https://raw.githubusercontent.com/mscheltienne/mne-lsl-datasets/main/version.txt -o mne_lsl_testing_data_version.txt + - name: Cache testing dataset + id: cache + uses: actions/cache@v4 + with: + key: mne-lsl-testing-${{ runner.os }}-${{ hashFiles('mne_testing_data_version.txt') }} + path: ~/mne_data/MNE-LSL-data + - name: Download testing dataset + if: steps.cache.outputs.cache-hit != 'true' + shell: bash + run: python -c "import mne_lsl; mne_lsl.datasets.testing.data_path()" + - name: Remove dataset version file + shell: bash + run: rm mne_lsl_testing_data_version.txt diff --git a/.github/actions/install-system-dependencies/action.yaml b/.github/actions/install-system-dependencies/action.yaml index 796f799e7..edb569ec5 100644 --- a/.github/actions/install-system-dependencies/action.yaml +++ b/.github/actions/install-system-dependencies/action.yaml @@ -1,16 +1,20 @@ -name: "Install liblsl" -description: "A composite action to install liblsl on different operating systems." +name: "Install system dependencies" +description: "A composite action to install liblsl and system dependencies on different operating systems." runs: using: "composite" steps: - - name: Install liblsl (linux) + - name: Install linux dependencies if: ${{ runner.os == 'Linux' }} shell: bash run: | - curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-jammy_amd64.deb -o liblsl-1.16.2-jammy_amd64.deb sudo apt update sudo apt install -y binutils libpugixml-dev qtbase5-dev qt5-qmake + - name: Install liblsl (linux) + if: ${{ runner.os == 'Linux' }} + shell: bash + run: | + curl -L https://github.com/sccn/liblsl/releases/download/v1.16.2/liblsl-1.16.2-jammy_amd64.deb -o liblsl-1.16.2-jammy_amd64.deb sudo apt install -y ./liblsl-1.16.2-jammy_amd64.deb rm liblsl-1.16.2-jammy_amd64.deb - name: Install liblsl (macOS) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 41f76b0b5..1d19ce688 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -36,6 +36,8 @@ jobs: python -m pip install --progress-bar off .[test] - name: Display system information run: mne_lsl-sys_info --developer + - name: Get testing dataset + uses: ./.github/actions/get-testing-dataset - name: Run pytest run: pytest mne_lsl --cov=mne_lsl --cov-report=xml --cov-config=pyproject.toml -s env: @@ -80,6 +82,8 @@ jobs: python -m pip install --progress-bar off --upgrade --pre --only-binary :all: -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple --timeout=180 numpy scipy - name: Display system information run: mne_lsl-sys_info --developer + - name: Get testing dataset + uses: ./.github/actions/get-testing-dataset - name: Run pytest run: pytest mne_lsl --cov=mne_lsl --cov-report=xml --cov-config=pyproject.toml -s env: @@ -123,6 +127,8 @@ jobs: python -m pip install --progress-bar off mne==${{ matrix.mne-version }} - name: Display system information run: mne_lsl-sys_info --developer + - name: Get testing dataset + uses: ./.github/actions/get-testing-dataset - name: Run pytest run: pytest mne_lsl --cov=mne_lsl --cov-report=xml --cov-config=pyproject.toml -s env: diff --git a/mne_lsl/datasets/testing.py b/mne_lsl/datasets/testing.py index f245f026b..28f031bf0 100644 --- a/mne_lsl/datasets/testing.py +++ b/mne_lsl/datasets/testing.py @@ -44,7 +44,7 @@ def data_path() -> Path: path = ( Path(get_config("MNE_DATA", Path.home())).expanduser() / "mne_data" - / "MNE-LSL" + / "MNE-LSL-data" / "testing" ) base_url = "https://github.com/mscheltienne/mne-lsl-datasets/raw/main/testing" From 32f8b868c3e3c4b0c0b33e5d613670eaed495481 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 14:09:03 +0200 Subject: [PATCH 09/12] fix var name --- .github/actions/get-testing-dataset/action.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/get-testing-dataset/action.yaml b/.github/actions/get-testing-dataset/action.yaml index 6f7b0a65e..f4220e0e7 100644 --- a/.github/actions/get-testing-dataset/action.yaml +++ b/.github/actions/get-testing-dataset/action.yaml @@ -7,12 +7,12 @@ runs: - name: Get testing dataset version shell: bash run: | - curl https://raw.githubusercontent.com/mscheltienne/mne-lsl-datasets/main/version.txt -o mne_lsl_testing_data_version.txt + curl https://raw.githubusercontent.com/mscheltienne/mne-lsl-datasets/main/version.txt -o mne_lsl_dataset_version.txt - name: Cache testing dataset id: cache uses: actions/cache@v4 with: - key: mne-lsl-testing-${{ runner.os }}-${{ hashFiles('mne_testing_data_version.txt') }} + key: mne-lsl-testing-${{ runner.os }}-${{ hashFiles('mne_lsl_dataset_version.txt') }} path: ~/mne_data/MNE-LSL-data - name: Download testing dataset if: steps.cache.outputs.cache-hit != 'true' @@ -20,4 +20,4 @@ runs: run: python -c "import mne_lsl; mne_lsl.datasets.testing.data_path()" - name: Remove dataset version file shell: bash - run: rm mne_lsl_testing_data_version.txt + run: rm mne_lsl_dataset_version.txt From ca2dc01c6af57043f03c9f55cf3c8203553f3b1c Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 14:48:32 +0200 Subject: [PATCH 10/12] add action for both dataset download --- .../actions/get-testing-dataset/action.yaml | 29 ++++++++++++++++--- .github/workflows/doc.yaml | 11 +++---- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/actions/get-testing-dataset/action.yaml b/.github/actions/get-testing-dataset/action.yaml index f4220e0e7..523239a02 100644 --- a/.github/actions/get-testing-dataset/action.yaml +++ b/.github/actions/get-testing-dataset/action.yaml @@ -1,23 +1,44 @@ name: "Get MNE-LSL testing dataset" description: "A composite action to get MNE-LSL testing dataset from cache or remote." +inputs: + sample: + description: "If True, retrieve the sample dataset." + required: false + default: "false" + testing: + description: "If True, retrieve the testing dataset." + required: false + default: "true" runs: using: "composite" steps: - - name: Get testing dataset version + - name: Get dataset version file shell: bash run: | curl https://raw.githubusercontent.com/mscheltienne/mne-lsl-datasets/main/version.txt -o mne_lsl_dataset_version.txt - name: Cache testing dataset - id: cache + if: ${{ inputs.testing == 'true' }} + id: cache_testing uses: actions/cache@v4 with: key: mne-lsl-testing-${{ runner.os }}-${{ hashFiles('mne_lsl_dataset_version.txt') }} - path: ~/mne_data/MNE-LSL-data + path: ~/mne_data/MNE-LSL-data/testing - name: Download testing dataset - if: steps.cache.outputs.cache-hit != 'true' + if: ${{ inputs.testing == 'true' && steps.cache_testing.outputs.cache-hit != 'true' }} shell: bash run: python -c "import mne_lsl; mne_lsl.datasets.testing.data_path()" + - name: Cache sample dataset + if: ${{ inputs.sample == 'true' }} + id: cache_sample + uses: actions/cache@v4 + with: + key: mne-lsl-sample-${{ runner.os }}-${{ hashFiles('mne_lsl_dataset_version.txt') }} + path: ~/mne_data/MNE-LSL-data/sample + - name: Download sample dataset + if: ${{ inputs.sample == 'true' && steps.cache_sample.outputs.cache-hit != 'true' }} + shell: bash + run: python -c "import mne_lsl; mne_lsl.datasets.sample.data_path()" - name: Remove dataset version file shell: bash run: rm mne_lsl_dataset_version.txt diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index 20acd498b..c23b552ee 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -30,12 +30,13 @@ jobs: python -m pip install --progress-bar off .[doc] - name: Display system information run: mne_lsl-sys_info --developer - - name: Build doc - uses: nick-fields/retry@v3 + - name: Get testing dataset + uses: ./.github/actions/get-testing-dataset with: - timeout_minutes: 10 - max_attempts: 3 - command: make -C doc html + sample: "true" + testing: "false" + - name: Build doc + run: make -C doc html - name: Prune sphinx environment run: rm -R ./doc/_build/html/.doctrees - name: Upload documentation From 81553e2b7b527af392247363b44f6b467d07ae7e Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 14:52:20 +0200 Subject: [PATCH 11/12] install optipng --- .github/workflows/doc.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index c23b552ee..e80aa349f 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -24,6 +24,8 @@ jobs: python-version: 3.11 - name: Install system dependencies uses: ./.github/actions/install-system-dependencies + - name: Install optipng (for sphinx-gallery) + run: sudo apt install optipng - name: Install package run: | python -m pip install --progress-bar off --upgrade pip setuptools From d6876638c5859c68cd460b69fe7d1a054556b878 Mon Sep 17 00:00:00 2001 From: mscheltienne Date: Thu, 30 May 2024 14:56:49 +0200 Subject: [PATCH 12/12] fix step name --- .github/workflows/doc.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index e80aa349f..909362fe7 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -32,7 +32,7 @@ jobs: python -m pip install --progress-bar off .[doc] - name: Display system information run: mne_lsl-sys_info --developer - - name: Get testing dataset + - name: Get dataset uses: ./.github/actions/get-testing-dataset with: sample: "true"