Skip to content

Commit 666eab0

Browse files
authored
Add papermill downstream check and fix kernel client replies (#925)
Fixes #922
1 parent fac9c3a commit 666eab0

File tree

5 files changed

+40
-16
lines changed

5 files changed

+40
-16
lines changed

.github/workflows/downstream.yml

+27
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ jobs:
3131
package_name: nbclient
3232
env_values: IPYKERNEL_CELL_NAME=\<IPY-INPUT\>
3333

34+
papermill:
35+
runs-on: ubuntu-latest
36+
timeout-minutes: 15
37+
steps:
38+
- uses: actions/checkout@v3
39+
- uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
40+
- uses: jupyterlab/maintainer-tools/.github/actions/downstream-test@v1
41+
with:
42+
package_name: papermill
43+
3444
nbconvert:
3545
runs-on: ubuntu-latest
3646
timeout-minutes: 15
@@ -115,3 +125,20 @@ jobs:
115125
run: |
116126
cd ${GITHUB_WORKSPACE}/../qtconsole
117127
xvfb-run --auto-servernum ${pythonLocation}/bin/python -m pytest -x -vv -s --full-trace --color=yes qtconsole
128+
129+
downstreams_check: # This job does nothing and is only used for the branch protection
130+
if: always()
131+
needs:
132+
- ipykernel
133+
- nbclient
134+
- papermill
135+
- nbconvert
136+
- jupyter_server
137+
- jupyter_kernel_test
138+
- qtconsole
139+
runs-on: ubuntu-latest
140+
steps:
141+
- name: Decide whether the needed jobs succeeded or failed
142+
uses: re-actors/alls-green@release/v1
143+
with:
144+
jobs: ${{ toJSON(needs) }}

jupyter_client/asynchronous/client.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Implements an async kernel client"""
22
# Copyright (c) Jupyter Development Team.
33
# Distributed under the terms of the Modified BSD License.
4-
import asyncio
54

65
import zmq.asyncio
76
from traitlets import Instance, Type
@@ -17,10 +16,8 @@ def _(self, *args, **kwargs):
1716
reply = kwargs.pop("reply", False)
1817
timeout = kwargs.pop("timeout", None)
1918
msg_id = meth(self, *args, **kwargs)
20-
fut: asyncio.Future = asyncio.Future()
21-
fut.set_result(msg_id)
2219
if not reply:
23-
return fut
20+
return msg_id
2421
return self._recv_reply(msg_id, timeout=timeout, channel=channel)
2522

2623
return _

tests/test_client.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -147,37 +147,37 @@ def output_hook(msg):
147147
assert called
148148

149149
async def test_history(self, kc):
150-
msg_id = await kc.history(session=0)
150+
msg_id = kc.history(session=0)
151151
assert isinstance(msg_id, str)
152152
reply = await kc.history(session=0, reply=True, timeout=TIMEOUT)
153153
self._check_reply("history", reply)
154154

155155
async def test_inspect(self, kc):
156-
msg_id = await kc.inspect("who cares")
156+
msg_id = kc.inspect("who cares")
157157
assert isinstance(msg_id, str)
158158
reply = await kc.inspect("code", reply=True, timeout=TIMEOUT)
159159
self._check_reply("inspect", reply)
160160

161161
async def test_complete(self, kc):
162-
msg_id = await kc.complete("who cares")
162+
msg_id = kc.complete("who cares")
163163
assert isinstance(msg_id, str)
164164
reply = await kc.complete("code", reply=True, timeout=TIMEOUT)
165165
self._check_reply("complete", reply)
166166

167167
async def test_is_complete(self, kc):
168-
msg_id = await kc.is_complete("who cares")
168+
msg_id = kc.is_complete("who cares")
169169
assert isinstance(msg_id, str)
170170
reply = await kc.is_complete("code", reply=True, timeout=TIMEOUT)
171171
self._check_reply("is_complete", reply)
172172

173173
async def test_kernel_info(self, kc):
174-
msg_id = await kc.kernel_info()
174+
msg_id = kc.kernel_info()
175175
assert isinstance(msg_id, str)
176176
reply = await kc.kernel_info(reply=True, timeout=TIMEOUT)
177177
self._check_reply("kernel_info", reply)
178178

179179
async def test_comm_info(self, kc):
180-
msg_id = await kc.comm_info()
180+
msg_id = kc.comm_info()
181181
assert isinstance(msg_id, str)
182182
reply = await kc.comm_info(reply=True, timeout=TIMEOUT)
183183
self._check_reply("comm_info", reply)
@@ -187,7 +187,7 @@ async def test_shutdown(self, kc):
187187
self._check_reply("shutdown", reply)
188188

189189
async def test_shutdown_id(self, kc):
190-
msg_id = await kc.shutdown()
190+
msg_id = kc.shutdown()
191191
assert isinstance(msg_id, str)
192192

193193

tests/test_kernelmanager.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ async def test_signal_kernel_subprocesses(self, install_kernel, jp_start_kernel)
199199
km, kc = await jp_start_kernel("signaltest")
200200

201201
async def execute(cmd):
202-
request_id = await kc.execute(cmd)
202+
request_id = kc.execute(cmd)
203203
while True:
204204
reply = await kc.get_shell_msg(TIMEOUT)
205205
if reply["parent_header"]["msg_id"] == request_id:
@@ -241,7 +241,7 @@ async def test_start_new_kernel(self, install_kernel, jp_start_kernel):
241241

242242
async def _env_test_body(self, kc):
243243
async def execute(cmd):
244-
request_id = await kc.execute(cmd)
244+
request_id = kc.execute(cmd)
245245
while True:
246246
reply = await kc.get_shell_msg(TIMEOUT)
247247
if reply["parent_header"]["msg_id"] == request_id:
@@ -452,7 +452,7 @@ async def test_signal_kernel_subprocesses(self, install_kernel, jp_start_kernel)
452452
km, kc = await jp_start_kernel("signaltest")
453453

454454
async def execute(cmd):
455-
request_id = await kc.execute(cmd)
455+
request_id = kc.execute(cmd)
456456
while True:
457457
reply = await kc.get_shell_msg(TIMEOUT)
458458
if reply["parent_header"]["msg_id"] == request_id:
@@ -472,7 +472,7 @@ async def execute(cmd):
472472
assert reply["user_expressions"]["poll"] == [None] * N
473473

474474
# start a job on the kernel to be interrupted
475-
request_id = await kc.execute("sleep")
475+
request_id = kc.execute("sleep")
476476
await asyncio.sleep(1) # ensure sleep message has been handled before we interrupt
477477
await km.interrupt_kernel()
478478
while True:

tests/test_multikernelmanager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def record_activity(msg_list):
637637

638638
stream.on_recv(record_activity)
639639
while True:
640-
await client.kernel_info()
640+
await client.kernel_info(reply=True)
641641
if called:
642642
break
643643
await asyncio.sleep(0.1)

0 commit comments

Comments
 (0)