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

Clean up dependency handling #750

Merged
merged 16 commits into from
Mar 4, 2022
1 change: 0 additions & 1 deletion .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches: ["main"]
pull_request:
branches: ["*"]

concurrency:
group: check-release-${{ github.ref }}
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: Test downstream projects

on:
push:
branches: "*"
branches: ["main"]
pull_request:
branches: "*"

concurrency:
group: downstream-${{ github.ref }}
Expand Down
38 changes: 36 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI

on:
push:
branches: ["main"]
pull_request:

concurrency:
Expand Down Expand Up @@ -51,7 +52,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]
python-version: [3.7, 3.8, 3.9, "3.10"]

env:
OS: ${{ matrix.os }}
Expand All @@ -65,7 +66,7 @@ jobs:

- name: Install dependencies
run: |
pip install --upgrade --upgrade-strategy eager --pre -e .[test]
pip install -e .[test]
pip freeze

- name: Check types
Expand All @@ -82,3 +83,36 @@ jobs:

- name: Code coverage
run: codecov

test_miniumum_verisons:
name: Test Minimum Versions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
with:
python_version: "3.7"
- name: Install miniumum versions
uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1
- name: Run the unit tests
run: pytest -vv jupyter_client || pytest -vv jupyter_client --lf

test_prereleases:
name: Test Prereleases
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install the Python dependencies
run: |
pip install --upgrade --upgrade-strategy eager --pre -e ".[test]"
- name: List installed packages
run: |
pip freeze
pip check
- name: Run the tests
run: |
pytest -vv jupyter_client || pytest -vv jupyter_client --lf
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
repos:
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.9.0
rev: v2.7.1
hooks:
- id: reorder-python-imports
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.1.0
hooks:
- id: black
args: ["--line-length", "100"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
rev: v2.5.1
hooks:
- id: prettier
- repo: https://gitlab.com/pycqa/flake8
rev: "3.8.4"
rev: "3.9.2"
hooks:
- id: flake8
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.1.0
hooks:
- id: end-of-file-fixer
- id: check-case-conflict
Expand Down
6 changes: 3 additions & 3 deletions jupyter_client/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ async def _recv(self, **kwargs) -> t.Dict[str, t.Any]:
return self.session.deserialize(smsg)

async def get_msg(self, timeout: t.Optional[float] = None) -> t.Dict[str, t.Any]:
""" Gets a message if there is one that is ready. """
"""Gets a message if there is one that is ready."""
assert self.socket is not None
if timeout is not None:
timeout *= 1000 # seconds to ms
Expand All @@ -230,7 +230,7 @@ async def get_msg(self, timeout: t.Optional[float] = None) -> t.Dict[str, t.Any]
raise Empty

async def get_msgs(self) -> t.List[t.Dict[str, t.Any]]:
""" Get all messages that are currently ready. """
"""Get all messages that are currently ready."""
msgs = []
while True:
try:
Expand All @@ -240,7 +240,7 @@ async def get_msgs(self) -> t.List[t.Dict[str, t.Any]]:
return msgs

async def msg_ready(self) -> bool:
""" Is there a message that has been received? """
"""Is there a message that has been received?"""
assert self.socket is not None
return bool(await self.socket.poll(timeout=0))

Expand Down
4 changes: 2 additions & 2 deletions jupyter_client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def _new_auth(self) -> None:

digest_history = Set()
digest_history_size = Integer(
2 ** 16,
2**16,
config=True,
help="""The maximum number of digests to remember.

Expand Down Expand Up @@ -504,7 +504,7 @@ def _unpack_changed(self, change):

# thresholds:
copy_threshold = Integer(
2 ** 16,
2**16,
config=True,
help="Threshold (in bytes) beyond which a buffer should be sent without copying.",
)
Expand Down
1 change: 0 additions & 1 deletion jupyter_client/ssh/tunnel.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
class SSHException(Exception): # type: ignore
pass


else:
from .forward import forward_tunnel

Expand Down
4 changes: 2 additions & 2 deletions jupyter_client/tests/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_write_connection_file():


def test_load_connection_file_session():
"""test load_connection_file() after """
"""test load_connection_file() after"""
session = Session()
app = DummyConsoleApp(session=Session())
app.initialize(argv=[])
Expand All @@ -101,7 +101,7 @@ def test_load_connection_file_session():


def test_load_connection_file_session_with_kn():
"""test load_connection_file() after """
"""test load_connection_file() after"""
session = Session()
app = DummyConsoleApp(session=Session())
app.initialize(argv=[])
Expand Down
17 changes: 12 additions & 5 deletions jupyter_client/tests/test_kernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,17 @@ def test_signal_kernel_subprocesses(self, name, install, expected):
kc.stop_channels()
km.shutdown_kernel()

assert km._shutdown_status == expected
if expected == _ShutdownStatus.ShutdownRequest:
expected = [expected, _ShutdownStatus.SigtermRequest]
else:
expected = [expected]

assert km._shutdown_status in expected

@pytest.mark.asyncio
@pytest.mark.skipif(sys.platform == "win32", reason="Windows doesn't support signals")
@pytest.mark.parametrize(*parameters)
async def test_async_signal_kernel_subprocesses(self, name, install, expected):
# ipykernel doesn't support 3.6 and this test uses async shutdown_request
if expected == _ShutdownStatus.ShutdownRequest and sys.version_info < (3, 7):
pytest.skip()
install()
km, kc = await start_new_async_kernel(kernel_name=name)
assert km._shutdown_status == _ShutdownStatus.Unset
Expand All @@ -181,7 +183,12 @@ async def test_async_signal_kernel_subprocesses(self, name, install, expected):
kc.stop_channels()
await km.shutdown_kernel()

assert km._shutdown_status == expected
if expected == _ShutdownStatus.ShutdownRequest:
expected = [expected, _ShutdownStatus.SigtermRequest]
else:
expected = [expected]

assert km._shutdown_status in expected


class TestKernelManager:
Expand Down
2 changes: 1 addition & 1 deletion jupyter_client/tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


def test_connection_file_real_path():
""" Verify realpath is used when formatting connection file """
"""Verify realpath is used when formatting connection file"""
with mock.patch("os.path.realpath") as patched_realpath:
patched_realpath.return_value = "foobar"
km = KernelManager(
Expand Down
2 changes: 1 addition & 1 deletion jupyter_client/tests/test_provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def test_get_new(self, kpf):

class TestRuntime:
async def akm_test(self, kernel_mgr):
"""Starts a kernel, validates the associated provisioner's config, shuts down kernel """
"""Starts a kernel, validates the associated provisioner's config, shuts down kernel"""

assert kernel_mgr.provisioner is None
if kernel_mgr.kernel_name == 'missing_provisioner':
Expand Down
2 changes: 1 addition & 1 deletion jupyter_client/tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def test_tracking(self):
def test_unique_msg_ids(self):
"""test that messages receive unique ids"""
ids = set()
for i in range(2 ** 12):
for i in range(2**12):
h = self.session.msg_header("test")
msg_id = h["msg_id"]
self.assertTrue(msg_id not in ids)
Expand Down
44 changes: 22 additions & 22 deletions jupyter_client/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,51 +132,51 @@ def wrapped(self, *args, **kwargs):
class KMSubclass(RecordCallMixin):
@subclass_recorder
def start_kernel(self, **kw):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def shutdown_kernel(self, now=False, restart=False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def restart_kernel(self, now=False, **kw):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def interrupt_kernel(self):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def request_shutdown(self, restart=False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def finish_shutdown(self, waittime=None, pollinterval=0.1, restart=False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def _launch_kernel(self, kernel_cmd, **kw):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def _kill_kernel(self):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def cleanup_resources(self, restart=False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def signal_kernel(self, signum: int):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def is_alive(self):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def _send_kernel_sigterm(self, restart: bool = False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""


class SyncKMSubclass(KMSubclass, KernelManager):
Expand All @@ -197,43 +197,43 @@ def _kernel_manager_class_default(self):

@subclass_recorder
def get_kernel(self, kernel_id):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def remove_kernel(self, kernel_id):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def start_kernel(self, kernel_name=None, **kwargs):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def shutdown_kernel(self, kernel_id, now=False, restart=False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def restart_kernel(self, kernel_id, now=False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def interrupt_kernel(self, kernel_id):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def request_shutdown(self, kernel_id, restart=False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def finish_shutdown(self, kernel_id, waittime=None, pollinterval=0.1, restart=False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def cleanup_resources(self, kernel_id, restart=False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""

@subclass_recorder
def shutdown_all(self, now=False):
""" Record call and defer to superclass """
"""Record call and defer to superclass"""


class SyncMKMSubclass(MKMSubclass, MultiKernelManager):
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
line-length = 100
skip-string-normalization = true
target_version = [
"py36",
"py37",
"py38",
"py39",
"py310",
]

[tool.jupyter-releaser]
Expand Down
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
codecov
coverage
ipykernel
ipykernel>=5.5.6
ipython
jedi<0.18; python_version<="3.6"
mock
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
entrypoints
jupyter_core>=4.6.0
nest-asyncio>=1.5
jupyter_core>=4.9.2
nest-asyncio>=1.5.1
python-dateutil>=2.1
pyzmq>=13
tornado>=4.1
pyzmq>=17
tornado>=5.0
traitlets
Loading