From cb23b3ff9d3ed3020e3f52af8f1680df82a0abec Mon Sep 17 00:00:00 2001 From: "Maarten A. Breddels" Date: Tue, 29 Nov 2022 19:53:43 +0100 Subject: [PATCH 01/12] fix: kernel in Comm should not be None --- ipykernel/comm/comm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ipykernel/comm/comm.py b/ipykernel/comm/comm.py index 97c2f1b86..87748fd65 100644 --- a/ipykernel/comm/comm.py +++ b/ipykernel/comm/comm.py @@ -7,6 +7,7 @@ import comm.base_comm import traitlets.config +from traitlets import Instance, default from ipykernel.jsonutil import json_clean from ipykernel.kernelbase import Kernel @@ -43,8 +44,14 @@ def publish_msg(self, msg_type, data=None, metadata=None, buffers=None, **keys): class Comm(traitlets.config.LoggingConfigurable, BaseComm): """Class for communicating between a Frontend and a Kernel""" + kernel = Instance("ipykernel.kernelbase.Kernel", allow_none=True) + @default("kernel") + def _default_kernel(self): + if Kernel.initialized(): + return Kernel.instance() + + def __init__(self, *args, **kwargs): - self.kernel = None # Comm takes positional arguments, LoggingConfigurable does not, so we explicitly forward arguments traitlets.config.LoggingConfigurable.__init__(self, **kwargs) BaseComm.__init__(self, *args, **kwargs) From 5a3e2126e08d96d59f3f15c8cf8b4d46284e9529 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 18:55:34 +0000 Subject: [PATCH 02/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ipykernel/comm/comm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipykernel/comm/comm.py b/ipykernel/comm/comm.py index 87748fd65..01cfb4dc4 100644 --- a/ipykernel/comm/comm.py +++ b/ipykernel/comm/comm.py @@ -45,12 +45,12 @@ class Comm(traitlets.config.LoggingConfigurable, BaseComm): """Class for communicating between a Frontend and a Kernel""" kernel = Instance("ipykernel.kernelbase.Kernel", allow_none=True) + @default("kernel") def _default_kernel(self): if Kernel.initialized(): return Kernel.instance() - def __init__(self, *args, **kwargs): # Comm takes positional arguments, LoggingConfigurable does not, so we explicitly forward arguments traitlets.config.LoggingConfigurable.__init__(self, **kwargs) From 769ffea5fe3e037d5ea157a4790287ffe8f2b36d Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 29 Nov 2022 10:55:52 -0600 Subject: [PATCH 03/12] add ipywidgets downstream test --- .github/workflows/downstream.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 0d314fa44..ab1f10350 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -25,6 +25,20 @@ jobs: package_name: nbclient env_values: IPYKERNEL_CELL_NAME=\ + ipywidgets: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Base Setup + uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + + - name: Run Test + uses: jupyterlab/maintainer-tools/.github/actions/downstream-test@v1 + with: + package_name: ipywidgets + jupyter_client: runs-on: ubuntu-latest steps: @@ -69,3 +83,18 @@ jobs: cd jupyter_kernel_test pip install -e ".[test]" python test_ipykernel.py + + downstream_check: # This job does nothing and is only used for the branch protection + if: always() + needs: + - nbclient + - ipywidgets + - jupyter_client + - ipyparallel + - jupyter_kernel_test + runs-on: ubuntu-latest + steps: + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }} From dd605ce283e03445e8695701757a73bfc94157a2 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 29 Nov 2022 14:20:24 -0600 Subject: [PATCH 04/12] reinstate traits --- ipykernel/comm/comm.py | 16 ++++++++++++++-- ipykernel/comm/manager.py | 7 +++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/ipykernel/comm/comm.py b/ipykernel/comm/comm.py index 01cfb4dc4..5b14c0560 100644 --- a/ipykernel/comm/comm.py +++ b/ipykernel/comm/comm.py @@ -7,7 +7,7 @@ import comm.base_comm import traitlets.config -from traitlets import Instance, default +from traitlets import Instance, default, Unicode, Bool, Bytes from ipykernel.jsonutil import json_clean from ipykernel.kernelbase import Kernel @@ -44,13 +44,25 @@ def publish_msg(self, msg_type, data=None, metadata=None, buffers=None, **keys): class Comm(traitlets.config.LoggingConfigurable, BaseComm): """Class for communicating between a Frontend and a Kernel""" - kernel = Instance("ipykernel.kernelbase.Kernel", allow_none=True) + kernel = Instance("ipykernel.kernelbase.Kernel", allow_none=True) # type:ignore[assignment] + comm_id = Unicode() + primary = Bool(True, help="Am I the primary or secondary Comm?") + + target_name = Unicode('comm') + target_module = Unicode(None, allow_none=True, help="""requirejs module from + which to load comm target.""") + + topic = Bytes() @default("kernel") def _default_kernel(self): if Kernel.initialized(): return Kernel.instance() + @default('comm_id') + def _default_comm_id(self): + return uuid.uuid4().hex + def __init__(self, *args, **kwargs): # Comm takes positional arguments, LoggingConfigurable does not, so we explicitly forward arguments traitlets.config.LoggingConfigurable.__init__(self, **kwargs) diff --git a/ipykernel/comm/manager.py b/ipykernel/comm/manager.py index 0314d6ffa..5697fb9aa 100644 --- a/ipykernel/comm/manager.py +++ b/ipykernel/comm/manager.py @@ -6,9 +6,16 @@ import comm.base_comm import traitlets.config +import traitlets + class CommManager(traitlets.config.LoggingConfigurable, comm.base_comm.CommManager): + + kernel = traitlets.Instance('ipykernel.kernelbase.Kernel') + comms = traitlets.Dict() + targets = traitlets.Dict() + def __init__(self, **kwargs): # CommManager doesn't take arguments, so we explicitly forward arguments traitlets.config.LoggingConfigurable.__init__(self, **kwargs) From ad033f19b426d4f63b1b6b5d1d9aef4f38f13b3c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 29 Nov 2022 20:20:38 +0000 Subject: [PATCH 05/12] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ipykernel/comm/comm.py | 14 +++++++++----- ipykernel/comm/manager.py | 5 ++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/ipykernel/comm/comm.py b/ipykernel/comm/comm.py index 5b14c0560..5d7237d31 100644 --- a/ipykernel/comm/comm.py +++ b/ipykernel/comm/comm.py @@ -7,7 +7,7 @@ import comm.base_comm import traitlets.config -from traitlets import Instance, default, Unicode, Bool, Bytes +from traitlets import Bool, Bytes, Instance, Unicode, default from ipykernel.jsonutil import json_clean from ipykernel.kernelbase import Kernel @@ -48,9 +48,13 @@ class Comm(traitlets.config.LoggingConfigurable, BaseComm): comm_id = Unicode() primary = Bool(True, help="Am I the primary or secondary Comm?") - target_name = Unicode('comm') - target_module = Unicode(None, allow_none=True, help="""requirejs module from - which to load comm target.""") + target_name = Unicode("comm") + target_module = Unicode( + None, + allow_none=True, + help="""requirejs module from + which to load comm target.""", + ) topic = Bytes() @@ -59,7 +63,7 @@ def _default_kernel(self): if Kernel.initialized(): return Kernel.instance() - @default('comm_id') + @default("comm_id") def _default_comm_id(self): return uuid.uuid4().hex diff --git a/ipykernel/comm/manager.py b/ipykernel/comm/manager.py index 5697fb9aa..6bf73ad81 100644 --- a/ipykernel/comm/manager.py +++ b/ipykernel/comm/manager.py @@ -5,14 +5,13 @@ import comm.base_comm -import traitlets.config import traitlets - +import traitlets.config class CommManager(traitlets.config.LoggingConfigurable, comm.base_comm.CommManager): - kernel = traitlets.Instance('ipykernel.kernelbase.Kernel') + kernel = traitlets.Instance("ipykernel.kernelbase.Kernel") comms = traitlets.Dict() targets = traitlets.Dict() From d1148735de6b6039cbe7b64e91871cae548e0092 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 29 Nov 2022 14:22:59 -0600 Subject: [PATCH 06/12] add missing import --- ipykernel/comm/comm.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ipykernel/comm/comm.py b/ipykernel/comm/comm.py index 5d7237d31..f1fb0c88f 100644 --- a/ipykernel/comm/comm.py +++ b/ipykernel/comm/comm.py @@ -3,6 +3,7 @@ # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. +import uuid from typing import Optional import comm.base_comm From 6322804261dde890a4acdc6ac3ae40e9e794ecb9 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 29 Nov 2022 14:32:20 -0600 Subject: [PATCH 07/12] add jdaviz downstream check --- .github/workflows/downstream.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index ab1f10350..a984b859f 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -39,6 +39,20 @@ jobs: with: package_name: ipywidgets + jdaviz: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Base Setup + uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + + - name: Run Test + uses: jupyterlab/maintainer-tools/.github/actions/downstream-test@v1 + with: + package_name: jdaviz + jupyter_client: runs-on: ubuntu-latest steps: From 771ef14bae03089cfb01c20d69c6a1b0140751a5 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 29 Nov 2022 14:37:15 -0600 Subject: [PATCH 08/12] update test command --- .github/workflows/downstream.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index a984b859f..9ab96f79b 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -52,6 +52,7 @@ jobs: uses: jupyterlab/maintainer-tools/.github/actions/downstream-test@v1 with: package_name: jdaviz + test_command: pytest --pyargs jdaviz jupyter_client: runs-on: ubuntu-latest From 37ed7e05fac030c92dcd468a869f92c715cba045 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 29 Nov 2022 14:41:13 -0600 Subject: [PATCH 09/12] disable warnings --- .github/workflows/downstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 9ab96f79b..58896b188 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -52,7 +52,7 @@ jobs: uses: jupyterlab/maintainer-tools/.github/actions/downstream-test@v1 with: package_name: jdaviz - test_command: pytest --pyargs jdaviz + test_command: pytest --pyargs jdaviz -W defaulut jupyter_client: runs-on: ubuntu-latest From 4cf9f6d2ad7bf9513d37e8fbd5274317f3c2c767 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 29 Nov 2022 14:44:34 -0600 Subject: [PATCH 10/12] spelling --- .github/workflows/downstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 58896b188..b7ef38dc7 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -52,7 +52,7 @@ jobs: uses: jupyterlab/maintainer-tools/.github/actions/downstream-test@v1 with: package_name: jdaviz - test_command: pytest --pyargs jdaviz -W defaulut + test_command: pytest --pyargs jdaviz -W default jupyter_client: runs-on: ubuntu-latest From fa46be9653981e7e67418678da47dc7546057764 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 29 Nov 2022 14:49:02 -0600 Subject: [PATCH 11/12] isolate dir --- .github/workflows/downstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index b7ef38dc7..57b15c459 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -52,7 +52,7 @@ jobs: uses: jupyterlab/maintainer-tools/.github/actions/downstream-test@v1 with: package_name: jdaviz - test_command: pytest --pyargs jdaviz -W default + test_command: cd $HOME && pytest --pyargs jdaviz -W default jupyter_client: runs-on: ubuntu-latest From ab4cdeb7bd380d19e2b947471015714ca28c51a0 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 29 Nov 2022 15:16:45 -0600 Subject: [PATCH 12/12] remove extra downstream test --- .github/workflows/downstream.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 57b15c459..ab1f10350 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -39,21 +39,6 @@ jobs: with: package_name: ipywidgets - jdaviz: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Base Setup - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - - - name: Run Test - uses: jupyterlab/maintainer-tools/.github/actions/downstream-test@v1 - with: - package_name: jdaviz - test_command: cd $HOME && pytest --pyargs jdaviz -W default - jupyter_client: runs-on: ubuntu-latest steps: