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

Add papermill downstream check and fix kernel client replies #925

Merged
merged 4 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ jobs:
package_name: nbclient
env_values: IPYKERNEL_CELL_NAME=\<IPY-INPUT\>

papermill:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v3
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- uses: jupyterlab/maintainer-tools/.github/actions/downstream-test@v1
with:
package_name: papermill

nbconvert:
runs-on: ubuntu-latest
timeout-minutes: 15
Expand Down Expand Up @@ -115,3 +125,20 @@ jobs:
run: |
cd ${GITHUB_WORKSPACE}/../qtconsole
xvfb-run --auto-servernum ${pythonLocation}/bin/python -m pytest -x -vv -s --full-trace --color=yes qtconsole

downstreams_check: # This job does nothing and is only used for the branch protection
if: always()
needs:
- ipykernel
- nbclient
- papermill
- nbconvert
- jupyter_server
- jupyter_kernel_test
- qtconsole
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) }}
5 changes: 1 addition & 4 deletions jupyter_client/asynchronous/client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Implements an async kernel client"""
# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import asyncio

import zmq.asyncio
from traitlets import Instance, Type
Expand All @@ -17,10 +16,8 @@ def _(self, *args, **kwargs):
reply = kwargs.pop("reply", False)
timeout = kwargs.pop("timeout", None)
msg_id = meth(self, *args, **kwargs)
fut: asyncio.Future = asyncio.Future()
fut.set_result(msg_id)
if not reply:
return fut
return msg_id
return self._recv_reply(msg_id, timeout=timeout, channel=channel)

return _
Expand Down
14 changes: 7 additions & 7 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,37 +147,37 @@ def output_hook(msg):
assert called

async def test_history(self, kc):
msg_id = await kc.history(session=0)
msg_id = kc.history(session=0)
assert isinstance(msg_id, str)
reply = await kc.history(session=0, reply=True, timeout=TIMEOUT)
self._check_reply("history", reply)

async def test_inspect(self, kc):
msg_id = await kc.inspect("who cares")
msg_id = kc.inspect("who cares")
assert isinstance(msg_id, str)
reply = await kc.inspect("code", reply=True, timeout=TIMEOUT)
self._check_reply("inspect", reply)

async def test_complete(self, kc):
msg_id = await kc.complete("who cares")
msg_id = kc.complete("who cares")
assert isinstance(msg_id, str)
reply = await kc.complete("code", reply=True, timeout=TIMEOUT)
self._check_reply("complete", reply)

async def test_is_complete(self, kc):
msg_id = await kc.is_complete("who cares")
msg_id = kc.is_complete("who cares")
assert isinstance(msg_id, str)
reply = await kc.is_complete("code", reply=True, timeout=TIMEOUT)
self._check_reply("is_complete", reply)

async def test_kernel_info(self, kc):
msg_id = await kc.kernel_info()
msg_id = kc.kernel_info()
assert isinstance(msg_id, str)
reply = await kc.kernel_info(reply=True, timeout=TIMEOUT)
self._check_reply("kernel_info", reply)

async def test_comm_info(self, kc):
msg_id = await kc.comm_info()
msg_id = kc.comm_info()
assert isinstance(msg_id, str)
reply = await kc.comm_info(reply=True, timeout=TIMEOUT)
self._check_reply("comm_info", reply)
Expand All @@ -187,7 +187,7 @@ async def test_shutdown(self, kc):
self._check_reply("shutdown", reply)

async def test_shutdown_id(self, kc):
msg_id = await kc.shutdown()
msg_id = kc.shutdown()
assert isinstance(msg_id, str)


Expand Down
8 changes: 4 additions & 4 deletions tests/test_kernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async def test_signal_kernel_subprocesses(self, install_kernel, jp_start_kernel)
km, kc = await jp_start_kernel("signaltest")

async def execute(cmd):
request_id = await kc.execute(cmd)
request_id = kc.execute(cmd)
while True:
reply = await kc.get_shell_msg(TIMEOUT)
if reply["parent_header"]["msg_id"] == request_id:
Expand Down Expand Up @@ -241,7 +241,7 @@ async def test_start_new_kernel(self, install_kernel, jp_start_kernel):

async def _env_test_body(self, kc):
async def execute(cmd):
request_id = await kc.execute(cmd)
request_id = kc.execute(cmd)
while True:
reply = await kc.get_shell_msg(TIMEOUT)
if reply["parent_header"]["msg_id"] == request_id:
Expand Down Expand Up @@ -452,7 +452,7 @@ async def test_signal_kernel_subprocesses(self, install_kernel, jp_start_kernel)
km, kc = await jp_start_kernel("signaltest")

async def execute(cmd):
request_id = await kc.execute(cmd)
request_id = kc.execute(cmd)
while True:
reply = await kc.get_shell_msg(TIMEOUT)
if reply["parent_header"]["msg_id"] == request_id:
Expand All @@ -472,7 +472,7 @@ async def execute(cmd):
assert reply["user_expressions"]["poll"] == [None] * N

# start a job on the kernel to be interrupted
request_id = await kc.execute("sleep")
request_id = kc.execute("sleep")
await asyncio.sleep(1) # ensure sleep message has been handled before we interrupt
await km.interrupt_kernel()
while True:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_multikernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def record_activity(msg_list):

stream.on_recv(record_activity)
while True:
await client.kernel_info()
await client.kernel_info(reply=True)
if called:
break
await asyncio.sleep(0.1)
Expand Down