Skip to content

Commit

Permalink
Merge pull request #63 from the-virtual-brain/fix-notebookrun
Browse files Browse the repository at this point in the history
Fix notebooks run
  • Loading branch information
liadomide authored Aug 6, 2024
2 parents 8832fd4 + 524b4ff commit e0a83c0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
matrix:
python-version: [ "3.8", "3.9" ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
name: Test Notebooks
on:
push:
branches:
- '*'
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
name: Run notebooks
runs-on: windows-latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: 3.8

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgl1 xvfb
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install nbformat nbconvert
- name: Run notebooks
run: python ./dev/notebook_runner.py notebooks
run: xvfb-run -a python ./dev/notebook_runner.py notebooks
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install dependencies
run: |
Expand Down
84 changes: 14 additions & 70 deletions notebooks/TimeSeriesEDF.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "56d5c4b6-7804-46d6-931f-fcc5593977d1",
"metadata": {},
"outputs": [],
Expand All @@ -36,26 +36,13 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "28420169-2274-4e0e-a73d-c1ab54e6da9c",
"metadata": {
"scrolled": true,
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"17-04-2024 05:02:37 - DEBUG - tvbwidgets - Package is not fully installed\n",
"17-04-2024 05:02:37 - DEBUG - tvbwidgets - Version read from the internal package.json file\n",
"17-04-2024 05:02:37 - INFO - tvbwidgets - Version: 2.0.0\n",
"Using matplotlib as 2D backend.\n",
" INFO Cannot import syncrypto library.\n",
"17-04-2024 05:02:49 - INFO - tvbwidgets.core.pse.parameters - ImportError: Dask dependency is not included, so this functionality won't be available\n"
]
}
],
"outputs": [],
"source": [
"import numpy as np\n",
"from tvbwidgets.api import plot_timeseries\n",
Expand All @@ -72,45 +59,27 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "94687d23-0222-4e9f-887e-e97169737304",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Extracting EDF parameters from C:\\Work\\TVB\\tvb-widgets\\tvbwidgets\\tests\\data\\test_file.edf...\n",
"EDF file detected\n",
"Setting channel info structure...\n",
"Creating raw.info structure...\n"
]
}
],
"outputs": [],
"source": [
"edf_file_path = '../tvbwidgets/tests/data/test_file.edf' # replace path with your actual EDF file path\n",
"edf_file_path = 'tvbwidgets/tests/data/test_file.edf' # replace path with your actual EDF file path\n",
" # set this path file for notebooks tests\n",
"# you can use: '../tvbwidgets/tests/data/test_file.edf'\n",
"data, freq, index = read_edf_file(edf_file_path)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "12da93b3-f96f-44cf-8555-52eee8aaecfd",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(92000, 32)\n",
"400.0\n"
]
}
],
"outputs": [],
"source": [
"print(data.shape)\n",
"print(freq)"
Expand All @@ -126,7 +95,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "cac83fe3-b4fe-486a-8955-70203dda1004",
"metadata": {},
"outputs": [],
Expand All @@ -136,35 +105,10 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "20c3eae2-49dd-4d01-af9a-06a0dba15888",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"17-04-2024 05:02:49 - INFO - tvbwidgets.ui.ts.plotly_ts_widget - TimeSeries Widget with Plotly initialized\n",
"Creating RawArray with float64 data, n_channels=32, n_times=92000\n",
" Range : 0 ... 91999 = 0.000 ... 229.998 secs\n",
"Ready.\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "28d8ffb85be94f28b59e85b521e4aeeb",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"TimeSeriesWidgetPlotly(children=(HBox(children=(Output(),)), VBox(children=(Dropdown(description='Colormap:', …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"tsw = plot_timeseries(data=data, sample_freq=freq, ch_idx=index, backend=backend)"
]
Expand Down Expand Up @@ -194,7 +138,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.18"
"version": "3.9.19"
}
},
"nbformat": 4,
Expand Down
10 changes: 6 additions & 4 deletions tvbwidgets/ui/connectivity_ipy/connectivity_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
from tvbwidgets.ui.connectivity_ipy.global_context import CONTEXT, ObservableAttrs

DROPDOWN_KEY = 'dropdown'

pyvista.set_jupyter_backend('trame')


class CustomOutput(ipywidgets.Output):
CONFIG = ConnectivityConfig()

Expand Down Expand Up @@ -118,10 +118,9 @@ def __init__(self, width, height, **kwargs):
super(Connectivity3DViewer, self).__init__([self.output], *kwargs)

self.__init_view_connectivity()
CONTEXT.observe(lambda *args: self.__init_view_connectivity(), ObservableAttrs.CONNECTIVITY)
CONTEXT.observe(lambda *args: self.__refresh_connectivity(), ObservableAttrs.CONNECTIVITY)

def __init_view_connectivity(self):
self.output.plotter.clear()
points, edges = self.__add_actors()
points_toggle, edges_toggle = self.__init_controls()

Expand All @@ -143,13 +142,16 @@ def on_change_edges(change):

edges_toggle.observe(on_change_edges, 'value')


self.children = [
ipywidgets.HBox(children=(
points_toggle, edges_toggle)),
self.output]
self.output.display_actor(points)
self.output.display_actor(edges)

def __refresh_connectivity(self):
self.output.plotter.clear()
self.__init_view_connectivity()
self.output.update_plot()

def __init_controls(self):
Expand Down
3 changes: 3 additions & 0 deletions tvbwidgets/ui/head_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

from tvbwidgets.ui.base_widget import TVBWidget
from tvbwidgets.ui.widget_with_browser import TVBWidgetWithBrowser
from tvbwidgets.core.logger.builder import get_logger

LOGGER = get_logger(__name__)
pyvista.set_jupyter_backend('trame')


Expand Down Expand Up @@ -85,6 +87,7 @@ def hide_actor(self, actor):

def update_plot(self):
with self:
LOGGER.info('Update plot.')
self.clear_output(wait=True)
self.plotter.show()

Expand Down

0 comments on commit e0a83c0

Please sign in to comment.