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

Fix registry state lookup #3653

Merged
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'yarn'
- name: Install Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: '3.8'
architecture: 'x64'
- name: Cache pip on Linux
uses: actions/cache@v1
uses: actions/cache@v3
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/devinstall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'yarn'
- name: Install Python
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: '3.8'
architecture: 'x64'
- name: Cache pip on Linux
uses: actions/cache@v1
uses: actions/cache@v3
if: startsWith(runner.os, 'Linux')
with:
path: ~/.cache/pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'yarn'
- name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: 'x64'

- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
cd dist
sha256sum * | tee SHA256SUMS
- name: Upload distributions
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: dist ${{ github.run_number }}
path: ./dist
Expand All @@ -91,19 +91,19 @@ jobs:
os: 'ubuntu'
steps:
- name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
architecture: 'x64'
- name: Checkout # For the cache keys
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: pip cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }}
Expand All @@ -113,7 +113,7 @@ jobs:
- name: Install the prerequisites
run: |
python -m pip install pip
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: dist ${{ github.run_number }}
path: ./dist
Expand Down
43 changes: 27 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -37,9 +37,10 @@ jobs:
js:
name: JavaScript
runs-on: ubuntu-latest

env:
CI: true
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -48,22 +49,27 @@ jobs:
cache-dependency-path: |
**/setup.cfg
**/requirements*.txt
- name: Install dependencies
- name: Install apt dependencies
run: |
sudo apt-get install -y firefox
python -m pip install --upgrade pip
python -m pip install jupyterlab~=3.0
- name: Install node
uses: actions/setup-node@v3
with:
node-version: '14'
cache: 'yarn'
- name: yarn install, build, test
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install jupyterlab~=3.0
- name: yarn install
run: |
yarn install --frozen-lockfile
- name: yarn build
run: |
yarn run build
yarn run build:examples

- name: yarn test
run: |
pushd packages/base
yarn run test:unit:firefox:headless
popd
Expand All @@ -83,9 +89,14 @@ jobs:
pushd examples/web1
yarn run test:firefox:headless
popd
- name: upload npm debug logs
if: failure()
uses: actions/upload-artifact@v3
with:
name: ipywidgets-js-debug-logs
path: |
~/.npm/_logs

env:
CI: true
python:
name: Python
runs-on: ubuntu-latest
Expand All @@ -95,7 +106,7 @@ jobs:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11-dev']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -117,7 +128,7 @@ jobs:
name: Message Specification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -139,7 +150,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -204,15 +215,15 @@ jobs:

- name: Upload Playwright Test assets
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ipywidgets-test-assets
path: |
ui-tests/test-results

- name: Upload Playwright Test report
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ipywidgets-test-report
path: |
Expand All @@ -226,7 +237,7 @@ jobs:

- name: Upload updated snapshots
if: failure()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ipywidgets-updated-snapshots
path: ui-tests/tests
12 changes: 7 additions & 5 deletions docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@ channels:
dependencies:
- bqplot
- build
- empack
- ipykernel
- ipykernel !=6.19.*
- jupyter_client
- jupyterlab >=3,<4
- jupyter-packaging
- matplotlib
- matplotlib-base
- nbsphinx
- nodejs=14
- numpy
- packaging
- pandoc
- pip
- python=3.10
- recommonmark
- scikit-image
- scikit-learn
- sphinx
- sphinx_rtd_theme
- sympy
# lite deps
- pip
- doit
- pkginfo
- pip:
- jupyterlite==0.1.0b14
- jupyterlite==0.1.0b15
- jupyterlite-sphinx~=0.7.2
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
bqplot
build
ipykernel
ipykernel !=6.19.*
jupyter_client
jupyterlab>=3,<4
jupyterlite-sphinx
Expand Down
34 changes: 31 additions & 3 deletions python/ipywidgets/ipywidgets/widgets/tests/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@

"""Test Widget."""

import inspect

import pytest
from IPython.core.interactiveshell import InteractiveShell
from IPython.display import display
from IPython.utils.capture import capture_output
import inspect
import pytest

from ..._version import __jupyter_widgets_controls_version__
from .. import widget
from ..widget import Widget
from ..widget import PROTOCOL_VERSION_MAJOR, Widget
from ..widget_button import Button
from .utils import DummyComm, setup, teardown


def test_no_widget_view():
# ensure IPython shell is instantiated
Expand Down Expand Up @@ -74,3 +78,27 @@ def test_compatibility():
caller_path = inspect.stack(context=0)[1].filename
assert all(x.filename == caller_path for x in record)
assert len(record) == 6


def test_create_from_frontend():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🎉

comm = DummyComm()
assert widget._instances == {}
msg = {
"content": {
"data": {
"model_id": "foo",
"model_name": "Button",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": __jupyter_widgets_controls_version__,
"_model_name": "ButtonModel",
"_view_module": "@jupyter-widgets/controls",
"_view_module_version": __jupyter_widgets_controls_version__,
"_view_name": "ButtonView",
},
}
},
"metadata": {"version": PROTOCOL_VERSION_MAJOR},
}
Widget.handle_comm_opened(comm, msg)
assert isinstance(list(widget._instances.values())[0], Button)
2 changes: 1 addition & 1 deletion python/ipywidgets/ipywidgets/widgets/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def handle_comm_opened(comm, msg):
state = data['state']

# Find the widget class to instantiate in the registered widgets
widget_class = register.get(state['_model_module'],
widget_class = _registry.get(state['_model_module'],
state['_model_module_version'],
state['_model_name'],
state['_view_module'],
Expand Down