Skip to content

Commit 822b723

Browse files
authored
Merge pull request #898 from minrk/kernel7
ipykernel 7 support
2 parents 9a1f4dd + 87ec808 commit 822b723

File tree

13 files changed

+239
-272
lines changed

13 files changed

+239
-272
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ jobs:
4848
- python: "3.9"
4949
runs_on: macos-14
5050
- python: "3.11"
51+
- python: "3.12"
52+
pre: pre
5153

5254
steps:
5355
- uses: actions/checkout@v4
@@ -122,7 +124,12 @@ jobs:
122124
123125
- name: Install Python dependencies
124126
run: |
125-
pip install --pre --upgrade ipyparallel[test]
127+
pip install --upgrade ipyparallel[test]
128+
129+
- name: Install pre-release dependencies
130+
if: ${{ matrix.pre }}
131+
run: |
132+
pip install --pre --upgrade ipyparallel[test] 'https://github.com/ipython/ipykernel/archive/main.tar.gz#egg=ipykernel'
126133
127134
- name: Install extra Python packages
128135
if: ${{ ! startsWith(matrix.python, '3.11') }}
@@ -161,8 +168,8 @@ jobs:
161168
run: |
162169
set -x
163170
docker ps -a
164-
docker logs slurmctld
165171
docker exec -i slurmctld squeue --states=all
166172
docker exec -i slurmctld sinfo
173+
docker logs slurmctld
167174
docker logs c1
168175
docker logs c2

ipyparallel/apps/baseapp.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import re
88
import sys
99

10-
import traitlets
1110
from IPython.core.application import BaseIPythonApplication
1211
from IPython.core.application import base_aliases as base_ip_aliases
1312
from IPython.core.application import base_flags as base_ip_flags
@@ -21,15 +20,6 @@
2120

2221
from .._version import __version__
2322

24-
# FIXME: CUnicode is needed for cli parsing
25-
# with traitlets 4
26-
# bump when we require traitlets 5, which requires Python 3.7
27-
if int(traitlets.__version__.split(".", 1)[0]) < 5:
28-
from traitlets import CUnicode
29-
else:
30-
# don't need CUnicode with traitlets 4
31-
CUnicode = Unicode
32-
3323
# -----------------------------------------------------------------------------
3424
# Module errors
3525
# -----------------------------------------------------------------------------
@@ -107,7 +97,7 @@ def _work_dir_changed(self, change):
10797
'', config=True, help="The ZMQ URL of the iplogger to aggregate logging."
10898
)
10999

110-
cluster_id = CUnicode(
100+
cluster_id = Unicode(
111101
'',
112102
config=True,
113103
help="""String id to add to runtime files, to prevent name collisions when

ipyparallel/cluster/launcher.py

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,10 @@ async def join(self, timeout=None):
563563
"""Wait for the process to exit"""
564564
if self._wait_thread is not None:
565565
self._wait_thread.join(timeout=timeout)
566+
if self._wait_thread.is_alive():
567+
raise TimeoutError(
568+
f"Process {self.process.pid} did not exit in {timeout} seconds."
569+
)
566570

567571
def _stream_file(self, path):
568572
"""Stream one file"""
@@ -1886,6 +1890,17 @@ def __init__(self, work_dir='.', config=None, **kwargs):
18861890
# trigger program_changed to populate default context arguments
18871891
self._program_changed()
18881892

1893+
def _run_command(self, command, **kwargs):
1894+
joined_command = shlex_join(command)
1895+
self.log.debug("Running command: %s", joined_command)
1896+
output = check_output(
1897+
command,
1898+
stdin=None,
1899+
**kwargs,
1900+
).decode("utf8", "replace")
1901+
self.log.debug("Command %s output: %s", command[0], output)
1902+
return output
1903+
18891904
def parse_job_id(self, output):
18901905
"""Take the output of the submit command and return the job id."""
18911906
m = self.job_id_regexp.search(output)
@@ -1960,42 +1975,24 @@ def start(self, n=1):
19601975

19611976
env = os.environ.copy()
19621977
env.update(self.get_env())
1963-
output = check_output(self.args, env=env)
1964-
output = output.decode("utf8", 'replace')
1965-
self.log.debug(f"Submitted {shlex_join(self.args)}. Output: {output}")
1978+
output = self._run_command(self.args, env=env)
19661979

19671980
job_id = self.parse_job_id(output)
19681981
self.notify_start(job_id)
19691982
return job_id
19701983

19711984
def stop(self):
1972-
try:
1973-
output = check_output(
1974-
self.delete_command + [self.job_id],
1975-
stdin=None,
1976-
).decode("utf8", 'replace')
1977-
except Exception:
1978-
self.log.exception(
1979-
"Problem stopping cluster with command: %s"
1980-
% (self.delete_command + [self.job_id])
1981-
)
1982-
output = ""
1985+
command = self.delete_command + [self.job_id]
1986+
output = self._run_command(command)
19831987

19841988
self.notify_stop(
19851989
dict(job_id=self.job_id, output=output)
19861990
) # Pass the output of the kill cmd
19871991
return output
19881992

19891993
def signal(self, sig):
1990-
cmd = self.signal_command + [str(sig), self.job_id]
1991-
try:
1992-
output = check_output(
1993-
cmd,
1994-
stdin=None,
1995-
).decode("utf8", 'replace')
1996-
except Exception:
1997-
self.log.exception("Problem sending signal with: {shlex_join(cmd)}")
1998-
output = ""
1994+
command = self.signal_command + [str(sig), self.job_id]
1995+
self._run_command(command)
19991996

20001997
# same local-file implementation as LocalProcess
20011998
# should this be on the base class?

0 commit comments

Comments
 (0)