Skip to content

Commit

Permalink
Update CI (#1642)
Browse files Browse the repository at this point in the history
* Fixing codespell

* Always build everything

* Fix pep8

* Fix Python test

* Update micromamba setup

* Fix env name

* Update env

* remove nbext tests

* Remove nbext test

* I'm clueless

* Debug msg

* Another attempt

* Iterate

* Increase diff threshold

* Fix bot
  • Loading branch information
martinRenou committed Mar 22, 2024
1 parent c186fcd commit 1366ac5
Show file tree
Hide file tree
Showing 14 changed files with 1,257 additions and 1,390 deletions.
31 changes: 5 additions & 26 deletions .github/workflows/build.yml
Expand Up @@ -3,16 +3,8 @@ name: Build
on:
push:
branches: [ master ]
paths:
- js/**
- bqplot/**
pull_request:
branches: '*'
paths:
- js/**
- bqplot/**
- .github/workflows/**
- setup.cfg

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
Expand Down Expand Up @@ -47,15 +39,9 @@ jobs:
test -f $CONDA_PREFIX/share/jupyter/labextensions/bqplot/package.json
test -d $CONDA_PREFIX/share/jupyter/labextensions/bqplot/static
- name: Debug nbextension
run: jupyter nbextension list

- name: Debug labextension
run: jupyter labextension list

- name: Validate the nbextension
run: jupyter nbextension list 2>&1 | grep "bqplot/extension"

- name: Validate the labextension
run: jupyter labextension list 2>&1 | grep bqplot

Expand Down Expand Up @@ -105,9 +91,12 @@ jobs:
uses: actions/checkout@v3

- name: Install Conda environment with Micromamba
uses: mamba-org/setup-micromamba@main
uses: mamba-org/provision-with-micromamba@main
with:
environment-name: bqplot-test
environment-file: test-environment.yml
python-version: 3.9
auto-activate-base: false
channels: conda-forge

- uses: actions/download-artifact@v3
Expand All @@ -126,13 +115,6 @@ jobs:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
run: jlpm install

- name: Set up browser cache
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/pw-browsers
key: ${{ runner.os }}-${{ hashFiles('ui-tests/yarn.lock') }}

- name: Install browser
shell: bash -l {0}
run: npx playwright install chromium
Expand All @@ -141,7 +123,7 @@ jobs:
- name: Execute integration tests
shell: bash -l {0}
working-directory: ui-tests
run: npx playwright test
run: jlpm run test

- name: Upload Playwright Test report
if: always()
Expand Down Expand Up @@ -192,8 +174,5 @@ jobs:
test -f $CONDA_PREFIX/share/jupyter/labextensions/bqplot/package.json
test -d $CONDA_PREFIX/share/jupyter/labextensions/bqplot/static
- name: Validate the nbextension
run: jupyter nbextension list 2>&1 | grep "bqplot/extension"

- name: Validate the labextension
run: jupyter labextension list 2>&1 | grep bqplot
3 changes: 3 additions & 0 deletions .github/workflows/update_galata_references.yaml
Expand Up @@ -27,6 +27,9 @@ jobs:
- name: Configure git to use https
run: git config --global hub.protocol https

- name: Install hub
run: sudo apt-get update && sudo apt-get install -y hub

- name: Checkout the branch from the PR that triggered the job
run: hub pr checkout ${{ github.event.issue.number }}
env:
Expand Down
4 changes: 2 additions & 2 deletions bqplot/pyplot.py
Expand Up @@ -666,7 +666,7 @@ def plot(*args, **kwargs):
else:
kwargs['x'] = _infer_x_for_line(args[0])
elif len(args) == 2:
if type(args[1]) == str:
if isinstance(args[1], str):
kwargs['y'] = args[0]
kwargs['x'] = _infer_x_for_line(args[0])
marker_str = args[1].strip()
Expand All @@ -676,7 +676,7 @@ def plot(*args, **kwargs):
elif len(args) == 3:
kwargs['x'] = args[0]
kwargs['y'] = args[1]
if type(args[2]) == str:
if isinstance(args[2], str):
marker_str = args[2].strip()

if marker_str:
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Expand Up @@ -19,7 +19,7 @@ site_url: https://bqplot.github.io/bqplot
* __2D selectors__ Select slices of data along two dimensions (x and y) using rectangular brushing
* __Lasso__ Select slices of data along two dimensions (x and y) using a lasso
* __Jupyter Widget Integration__ Seamless integration and linking with Jupyter widgets
* __Extensibility__ `Object Model` can be extended to build re-usable compound plotting widgets and widget libraries
* __Extensibility__ `Object Model` can be extended to build reusable compound plotting widgets and widget libraries
* __Dashboards/Apps__ Build rich interactive dashboards and apps by integrating `bqplot` with other Jupyter widget libraries and `voila` dashboarding tool

While `bqplot` provides support for static plotting for most of the chart types, it really shines in interactive plotting where data attributes are updated in an event-driven fashion (using ipywidgets, click handlers etc.)
Expand Down
16 changes: 8 additions & 8 deletions docs/usage/marks/label.md
Expand Up @@ -40,7 +40,7 @@ fig
```
![plot](../../assets/images/label-image1.png)
!!! tip
To render labels professionally it's better to offset the label to avoid obscuring the true graph below. To do so, set the `x_offset` and `y_offset` attrbiutes (which accepts values in pixels), like so:
To render labels professionally it's better to offset the label to avoid obscuring the true graph below. To do so, set the `x_offset` and `y_offset` attributes (which accepts values in pixels), like so:
```py
label.x_offset = 10
label.y_offset = 10
Expand All @@ -59,9 +59,9 @@ fig = plt.figure()
y = np.cumsum(np.random.randn(100))
line = plt.plot(np.arange(y.size), y_data)
label = plt.label(
["Halfway Point"],
default_size=26,
font_weight="bolder",
["Halfway Point"],
default_size=26,
font_weight="bolder",
colors=["orange"]
)

Expand All @@ -70,7 +70,7 @@ label.y = [0.5]
```
![plot](../../assets/images/label-image2.png)

Further, we can use values expressed in the units of the data. For example, if we consider a time series, we might want to label a specific date. Rather than calculating the position of the data with respect to the figure, we can simply pass in the date to the label function.
Further, we can use values expressed in the units of the data. For example, if we consider a time series, we might want to label a specific date. Rather than calculating the position of the data with respect to the figure, we can simply pass in the date to the label function.
```py
fig = plt.figure()
y = pd.Series(
Expand All @@ -80,8 +80,8 @@ y = pd.Series(
)

lines = plt.plot(y.index, y)
label = plt.label(["Special Day"],
x=[np.datetime64("2007-02-14")],
label = plt.label(["Special Day"],
x=[np.datetime64("2007-02-14")],
colors=["orange"])

labels.y = [0.5]
Expand All @@ -100,4 +100,4 @@ labels.enable_move = True
For detailed examples of bar plots, refer to the following example notebooks

1. [pyplot](https://github.com/bqplot/bqplot/blob/master/examples/Marks/Pyplot/Label.ipynb)
2. [Object Model](https://github.com/bqplot/bqplot/blob/master/examples/Marks/Object%20Model/Label.ipynb)
2. [Object Model](https://github.com/bqplot/bqplot/blob/master/examples/Marks/Object%20Model/Label.ipynb)
2 changes: 1 addition & 1 deletion docs/usage/object-model.md
Expand Up @@ -105,4 +105,4 @@ bq.Figure(marks=[line, scatter], axes=[xax, yax], title="Scatter and Line")
__Object Model__ is a verbose but fully customizable object-oriented API for plotting. Lower level constructs like scales, axes etc. have to explicitly constructed.
For detailed usage refer to the [example notebooks](https://github.com/bqplot/bqplot/tree/master/examples/Marks/Object%20Model) using `Object Model`.

__Object Model__ can be used to build re-usable plotting widgets and widget libraries. More details can be found in [here]
__Object Model__ can be used to build reusable plotting widgets and widget libraries. More details can be found in [here]
4 changes: 2 additions & 2 deletions examples/Marks/Object Model/GridHeatMap.ipynb
Expand Up @@ -183,7 +183,7 @@
"metadata": {},
"source": [
"By default, for `N` points along any dimension, data aligns to the `start` of the rectangles in the grid.\n",
"The grid extends infinitely in the other direction. By default, the grid extends infintely\n",
"The grid extends infinitely in the other direction. By default, the grid extends infinitely\n",
"towards the bottom and the right."
]
},
Expand Down Expand Up @@ -247,7 +247,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"For `N+1` points on any direction, the grid extends infintely in both directions"
"For `N+1` points on any direction, the grid extends infinitely in both directions"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/Marks/Pyplot/GridHeatMap.ipynb
Expand Up @@ -191,7 +191,7 @@
"metadata": {},
"source": [
"By default, for `N` points along any dimension, data aligns to the `start` of the rectangles in the grid.\n",
"The grid extends infinitely in the other direction. By default, the grid extends infintely\n",
"The grid extends infinitely in the other direction. By default, the grid extends infinitely\n",
"towards the bottom and the right."
]
},
Expand Down Expand Up @@ -246,7 +246,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"For `N+1` points on any direction, the grid extends infintely in both directions"
"For `N+1` points on any direction, the grid extends infinitely in both directions"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/Tutorials/Gaussian Density Widget.ipynb
Expand Up @@ -11,7 +11,7 @@
"2. Inside the class constructor call the super class constructor passing in the widgets as children\n",
"3. Register any widget callbacks inside the constructor and define callbacks as class methods\n",
"\n",
"Once the compound widget is defined in a class, it can be put in a library and used along with other interactive widgets! Compound widgets are an excellent way of building re-usable components (**using just python code**) which can be seamlessly integrated with `ipywidgets`, `bqplot` and other interactive widgets."
"Once the compound widget is defined in a class, it can be put in a library and used along with other interactive widgets! Compound widgets are an excellent way of building reusable components (**using just python code**) which can be seamlessly integrated with `ipywidgets`, `bqplot` and other interactive widgets."
]
},
{
Expand Down
5 changes: 1 addition & 4 deletions test-environment.yml
Expand Up @@ -11,16 +11,13 @@ dependencies:
- pandas >=1.0.0,<2.0.0
- bqscales >=0.3.3
- scipy
- notebook
- nodejs =20
- yarn =3
# Using Notebook 6 in CI st. we can test the old nbextension
- notebook =6
- jupyterlab =4
- jupyter-packaging
- pytest
- nbval
- pytest-cov
- selenium
- flake8
- nose
- codespell
2 changes: 1 addition & 1 deletion tests/binary_serialization_test.py
Expand Up @@ -78,7 +78,7 @@ def test_dtype_with_str():
# dtype object is not supported
text = np.array(['foo', None, 'bar'])
assert text.dtype == object
with pytest.raises(ValueError, match='.*Unsupported dtype object*'), pytest.warns(UserWarning):
with pytest.raises(ValueError, match='.*Unsupported dtype object*'):
array_to_json(text)
# but if they contain all strings, it should convert them.
# This is for backward compatibility of expecting pandas dataframe
Expand Down
6 changes: 3 additions & 3 deletions ui-tests/package.json
Expand Up @@ -5,9 +5,9 @@
"private": true,
"scripts": {
"start": "jupyter lab --config jupyter_server_config.py",
"test": "npx playwright test",
"test:update": "npx playwright test --update-snapshots",
"test:debug": "PWDEBUG=1 npx playwright test"
"test": "playwright test",
"test:update": "playwright test --update-snapshots",
"test:debug": "PWDEBUG=1 playwright test"
},
"author": "bqplot",
"license": "Apache-2.0",
Expand Down
4 changes: 2 additions & 2 deletions ui-tests/tests/bqplot.test.ts
Expand Up @@ -43,7 +43,7 @@ const testCellOutputs = async (page: IJupyterLabPageFixture, tmpPath: string, th
await page.notebook.save();

for (let c = 0; c < numCellImages; ++c) {
expect(results[c]).toMatchSnapshot(getCaptureImageName(contextPrefix, notebook, c));
expect(results[c]).toMatchSnapshot(getCaptureImageName(contextPrefix, notebook, c), {threshold: 0.3});

Check failure on line 46 in ui-tests/tests/bqplot.test.ts

View workflow job for this annotation

GitHub Actions / visual-regression-tests

tests/bqplot.test.ts:112:7 › bqplot Visual Regression › Dark theme: Check bqplot first renders

1) tests/bqplot.test.ts:112:7 › bqplot Visual Regression › Dark theme: Check bqplot first renders Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 656 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts-snapshots/dark-gridheatmap-ipynb-cell-4-linux.png Received: /home/runner/work/bqplot/bqplot/ui-tests/test-results/tests-bqplot-bqplot-Visual-Regression-Dark-theme-Check-bqplot-first-renders-retry1/dark-gridheatmap-ipynb-cell-4-actual.png Diff: /home/runner/work/bqplot/bqplot/ui-tests/test-results/tests-bqplot-bqplot-Visual-Regression-Dark-theme-Check-bqplot-first-renders-retry1/dark-gridheatmap-ipynb-cell-4-diff.png 44 | 45 | for (let c = 0; c < numCellImages; ++c) { > 46 | expect(results[c]).toMatchSnapshot(getCaptureImageName(contextPrefix, notebook, c), {threshold: 0.3}); | ^ 47 | } 48 | 49 | await page.notebook.close(true); at testCellOutputs (/home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:46:26) at /home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:116:5
}

await page.notebook.close(true);

Check failure on line 49 in ui-tests/tests/bqplot.test.ts

View workflow job for this annotation

GitHub Actions / Update Galata References

tests/bqplot.test.ts:105:7 › bqplot Visual Regression › Light theme: Check bqplot first renders

1) tests/bqplot.test.ts:105:7 › bqplot Visual Regression › Light theme: Check bqplot first renders Error: page.evaluate: Execution context was destroyed, most likely because of a navigation. 47 | } 48 | > 49 | await page.notebook.close(true); | ^ 50 | } 51 | } 52 | at NotebookHelper.revertChanges (/home/runner/work/bqplot/bqplot/ui-tests/node_modules/@jupyterlab/galata/src/helpers/notebook.ts:253:21) at NotebookHelper.close (/home/runner/work/bqplot/bqplot/ui-tests/node_modules/@jupyterlab/galata/src/helpers/notebook.ts:416:13) at testCellOutputs (/home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:49:5) at /home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:109:5

Check failure on line 49 in ui-tests/tests/bqplot.test.ts

View workflow job for this annotation

GitHub Actions / Update Galata References

tests/bqplot.test.ts:112:7 › bqplot Visual Regression › Dark theme: Check bqplot first renders

2) tests/bqplot.test.ts:112:7 › bqplot Visual Regression › Dark theme: Check bqplot first renders Error: page.evaluate: Execution context was destroyed, most likely because of a navigation. 47 | } 48 | > 49 | await page.notebook.close(true); | ^ 50 | } 51 | } 52 | at NotebookHelper.revertChanges (/home/runner/work/bqplot/bqplot/ui-tests/node_modules/@jupyterlab/galata/src/helpers/notebook.ts:253:21) at NotebookHelper.close (/home/runner/work/bqplot/bqplot/ui-tests/node_modules/@jupyterlab/galata/src/helpers/notebook.ts:416:13) at testCellOutputs (/home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:49:5) at /home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:116:5

Check failure on line 49 in ui-tests/tests/bqplot.test.ts

View workflow job for this annotation

GitHub Actions / visual-regression-tests

tests/bqplot.test.ts:112:7 › bqplot Visual Regression › Dark theme: Check bqplot first renders

1) tests/bqplot.test.ts:112:7 › bqplot Visual Regression › Dark theme: Check bqplot first renders Error: page.evaluate: Execution context was destroyed, most likely because of a navigation. 47 | } 48 | > 49 | await page.notebook.close(true); | ^ 50 | } 51 | } 52 | at NotebookHelper.revertChanges (/home/runner/work/bqplot/bqplot/ui-tests/node_modules/@jupyterlab/galata/src/helpers/notebook.ts:253:21) at NotebookHelper.close (/home/runner/work/bqplot/bqplot/ui-tests/node_modules/@jupyterlab/galata/src/helpers/notebook.ts:416:13) at testCellOutputs (/home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:49:5) at /home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:116:5
Expand Down Expand Up @@ -82,7 +82,7 @@ const testPlotUpdates = async (page: IJupyterLabPageFixture, tmpPath: string, th
await page.notebook.save();

for (let i = 0; i < cellCount; i++) {
expect(results[i]).toMatchSnapshot(getCaptureImageName(contextPrefix, notebook, i));
expect(results[i]).toMatchSnapshot(getCaptureImageName(contextPrefix, notebook, i), {threshold: 0.3});

Check failure on line 85 in ui-tests/tests/bqplot.test.ts

View workflow job for this annotation

GitHub Actions / visual-regression-tests

tests/bqplot.test.ts:126:7 › bqplot Visual Regression › Dark theme: Check bqplot update plot properties

2) tests/bqplot.test.ts:126:7 › bqplot Visual Regression › Dark theme: Check bqplot update plot properties Error: Screenshot comparison failed: 656 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts-snapshots/dark-bars-update-ipynb-cell-1-linux.png Received: /home/runner/work/bqplot/bqplot/ui-tests/test-results/tests-bqplot-bqplot-Visual-Regression-Dark-theme-Check-bqplot-update-plot-properties/dark-bars-update-ipynb-cell-1-actual.png Diff: /home/runner/work/bqplot/bqplot/ui-tests/test-results/tests-bqplot-bqplot-Visual-Regression-Dark-theme-Check-bqplot-update-plot-properties/dark-bars-update-ipynb-cell-1-diff.png 83 | 84 | for (let i = 0; i < cellCount; i++) { > 85 | expect(results[i]).toMatchSnapshot(getCaptureImageName(contextPrefix, notebook, i), {threshold: 0.3}); | ^ 86 | } 87 | 88 | await page.notebook.close(true); at testPlotUpdates (/home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:85:26) at /home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:130:5

Check failure on line 85 in ui-tests/tests/bqplot.test.ts

View workflow job for this annotation

GitHub Actions / visual-regression-tests

tests/bqplot.test.ts:126:7 › bqplot Visual Regression › Dark theme: Check bqplot update plot properties

2) tests/bqplot.test.ts:126:7 › bqplot Visual Regression › Dark theme: Check bqplot update plot properties Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Screenshot comparison failed: 656 pixels (ratio 0.01 of all image pixels) are different. Expected: /home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts-snapshots/dark-bars-update-ipynb-cell-1-linux.png Received: /home/runner/work/bqplot/bqplot/ui-tests/test-results/tests-bqplot-bqplot-Visual-Regression-Dark-theme-Check-bqplot-update-plot-properties-retry1/dark-bars-update-ipynb-cell-1-actual.png Diff: /home/runner/work/bqplot/bqplot/ui-tests/test-results/tests-bqplot-bqplot-Visual-Regression-Dark-theme-Check-bqplot-update-plot-properties-retry1/dark-bars-update-ipynb-cell-1-diff.png 83 | 84 | for (let i = 0; i < cellCount; i++) { > 85 | expect(results[i]).toMatchSnapshot(getCaptureImageName(contextPrefix, notebook, i), {threshold: 0.3}); | ^ 86 | } 87 | 88 | await page.notebook.close(true); at testPlotUpdates (/home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:85:26) at /home/runner/work/bqplot/bqplot/ui-tests/tests/bqplot.test.ts:130:5
}

await page.notebook.close(true);
Expand Down

0 comments on commit 1366ac5

Please sign in to comment.