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

[pre-commit.ci] pre-commit autoupdate #916

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
rev: v0.8.1
hooks:
- id: ruff
args:
Expand All @@ -24,7 +24,7 @@ repos:
# than ruff itself
# but has trouble with isort rules
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.0
rev: 1.9.1
hooks:
- id: nbqa-ruff-format
- id: nbqa-ruff-check
Expand All @@ -44,7 +44,7 @@ repos:
- id: check-executables-have-shebangs
- id: requirements-txt-fixer
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.14.0
rev: v9.16.0
hooks:
- id: eslint
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
from datetime import date

project = 'ipyparallel'
copyright = '%04d, The IPython Development Team' % date.today().year
copyright = f'{date.today().year}, The IPython Development Team'
author = 'The IPython Development Team'

# The version info for the project you're documenting, acts as replacement for
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/Futures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
],
"source": [
"f = rc[-1].apply(os.getpid)\n",
"f.add_done_callback(lambda _: print(\"I got PID: %i\" % _.result()))\n",
"f.add_done_callback(lambda _: print(f\"I got PID: {_.result()}\"))\n",
"f.result()"
]
},
Expand Down Expand Up @@ -602,7 +602,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.11.10"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
6 changes: 3 additions & 3 deletions docs/source/examples/Monitoring an MPI Simulation - 1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
"bcast = mpi.bcast\n",
"barrier = mpi.barrier\n",
"rank = mpi.rank\n",
"print(\"MPI rank: %i/%i\" % (mpi.rank, mpi.size))"
"print(f\"MPI rank: {mpi.rank}/{mpi.size}\")"
]
},
{
Expand Down Expand Up @@ -300,7 +300,7 @@
" nx, nyt, j, nsteps = view.pull(['nx', 'nyt', 'j', 'nsteps'], targets=0, block=True)\n",
" fig, ax = plt.subplots()\n",
" ax.contourf(Z)\n",
" ax.set_title('Mesh: %i x %i, step %i/%i' % (nx, nyt, j + 1, nsteps))\n",
" ax.set_title(f\"Mesh: {nx} x {nyt}, step {j + 1}/{nsteps}\")\n",
" plt.axis('off')\n",
" # We clear the notebook output before plotting this if in-place plot updating is requested\n",
" if in_place:\n",
Expand Down Expand Up @@ -566,7 +566,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.11.10"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
6 changes: 3 additions & 3 deletions docs/source/examples/Monitoring an MPI Simulation - 2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"bcast = mpi.bcast\n",
"barrier = mpi.barrier\n",
"rank = mpi.rank\n",
"print(\"MPI rank: %i/%i\" % (mpi.rank, mpi.size))"
"print(f\"MPI rank: {mpi.rank}/{mpi.size}\")"
]
},
{
Expand Down Expand Up @@ -270,7 +270,7 @@
" else:\n",
" fig, ax = plt.subplots()\n",
" ax.contourf(Z)\n",
" ax.set_title(\"Mesh: %i x %i, step %i/%i\" % (nx, nyt, j + 1, nsteps))\n",
" ax.set_title(f\"Mesh: {nx} x {nyt}, step {j + 1}/{nsteps}\")\n",
" plt.axis(\"off\")\n",
" # We clear the notebook output before plotting this if in-place\n",
" # plot updating is requested\n",
Expand Down Expand Up @@ -420,7 +420,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.11.10"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
Expand Down
104 changes: 3 additions & 101 deletions docs/source/examples/Using Dill.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"\n",
" def has_closure(b):\n",
" product = a * b\n",
" f.write(\"%i: %g\\n\" % (os.getpid(), product))\n",
" f.write(f\"{os.getpid()}: {product:g}\\n\")\n",
" f.flush()\n",
" return product\n",
"\n",
Expand Down Expand Up @@ -596,109 +596,11 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.11.10"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {
"1086f7640c6148b7bb5cd4202d114ba3": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLStyleModel",
"state": {
"description_width": "",
"font_size": null,
"text_color": null
}
},
"37585be691034dba9d04f0c82d2d8a51": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"610913dc61674fd5ac61f9f8fa714f47": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"61aff84b5838480c92987db3608a698d": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLStyleModel",
"state": {
"description_width": "",
"font_size": null,
"text_color": null
}
},
"86f27c1b3bf840c8b0b5c0323f0d6264": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "FloatProgressModel",
"state": {
"bar_style": "success",
"layout": "IPY_MODEL_b2ded84395ea4d53891f184694793eff",
"max": 2,
"style": "IPY_MODEL_f458c2a21bc24550b2a0dd2b7f014046",
"value": 2
}
},
"8bdc6187bd964e89acfe57c818fccec6": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLModel",
"state": {
"layout": "IPY_MODEL_e2955a27d1a3468582d3cd1466737ba7",
"style": "IPY_MODEL_61aff84b5838480c92987db3608a698d",
"value": "100%"
}
},
"a6d41c9031314b94851b72e499e8afbe": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLModel",
"state": {
"layout": "IPY_MODEL_37585be691034dba9d04f0c82d2d8a51",
"style": "IPY_MODEL_1086f7640c6148b7bb5cd4202d114ba3",
"value": " 2/2 [00:00<00:00,  1.18engine/s]"
}
},
"b2ded84395ea4d53891f184694793eff": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"d2ece3d105ca4c488a76246625ef8962": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HBoxModel",
"state": {
"children": [
"IPY_MODEL_8bdc6187bd964e89acfe57c818fccec6",
"IPY_MODEL_86f27c1b3bf840c8b0b5c0323f0d6264",
"IPY_MODEL_a6d41c9031314b94851b72e499e8afbe"
],
"layout": "IPY_MODEL_610913dc61674fd5ac61f9f8fa714f47"
}
},
"e2955a27d1a3468582d3cd1466737ba7": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"f458c2a21bc24550b2a0dd2b7f014046": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "ProgressStyleModel",
"state": {
"description_width": ""
}
}
},
"state": {},
"version_major": 2,
"version_minor": 0
}
Expand Down
6 changes: 3 additions & 3 deletions docs/source/examples/customresults.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def sleep_here(count, t):
import sys
import time

print("hi from engine %i" % id)
print(f"hi from engine {id}")
sys.stdout.flush()
time.sleep(t)
return count, t
Expand All @@ -52,12 +52,12 @@ def sleep_here(count, t):
for msg_id in finished:
# we know these are done, so don't worry about blocking
ar = rc.get_result(msg_id)
print("job id %s finished on engine %i" % (msg_id, ar.engine_id))
print(f"job id {msg_id} finished on engine {ar.engine_id}")
print("with stdout:")
print(' ' + ar.stdout.replace('\n', '\n ').rstrip())
print("and results:")

# note that each job in a map always returns a list of length chunksize
# even if chunksize == 1
for count, t in ar.get():
print(" item %i: slept for %.2fs" % (count, t))
print(f" item {count}: slept for {t:.2f}s")
6 changes: 3 additions & 3 deletions docs/source/examples/daVinci Word Count/pwordfreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@ def pwordfreq(view, fnames):
block = nlines // n
for i in range(n):
chunk = lines[i * block : i * (block + 1)]
with open('davinci%i.txt' % i, 'w', encoding='utf8') as f:
with open(f'davinci{i}.txt', 'w', encoding='utf8') as f:
f.write('\n'.join(chunk))

try: # python2
cwd = os.path.abspath(os.getcwdu())
except AttributeError: # python3
cwd = os.path.abspath(os.getcwd())
fnames = [os.path.join(cwd, 'davinci%i.txt' % i) for i in range(n)]
fnames = [os.path.join(cwd, f'davinci{i}.txt') for i in range(n)]
tic = time.time()
pfreqs = pwordfreq(view, fnames)
toc = time.time()
print_wordfreq(freqs)
print("Took %.3f s to calculate on %i engines" % (toc - tic, len(view.targets)))
print(f"Took {toc - tic:.3f}s to calculate on {len(view.targets)} engines")
# cleanup split files
map(os.remove, fnames)
2 changes: 1 addition & 1 deletion docs/source/examples/dagdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def main(nodes, edges):

client = parallel.Client()
view = client.load_balanced_view()
print("submitting %i tasks with %i dependencies" % (nodes, edges))
print(f"submitting {nodes} tasks with {edges} dependencies")
results = submit_jobs(view, G, jobs)
print("waiting for results")
client.wait_interactive()
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/interengine/communicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def __init__(self, interface='tcp://*', identity=None):
# bind to ports
port = self.socket.bind_to_random_port(interface)
pub_port = self.pub.bind_to_random_port(interface)
self.url = interface + ":%i" % port
self.pub_url = interface + ":%i" % pub_port
self.url = f"{interface}:{port}"
self.pub_url = f"{interface}:{pub_port}"
# guess first public IP from socket
self.location = socket.gethostbyname_ex(socket.gethostname())[-1][0]
self.peers = {}
Expand Down
16 changes: 8 additions & 8 deletions docs/source/examples/itermapresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
# create a Reference to `id`. This will be a different value on each engine
ref = ipp.Reference('id')
print("sleeping for `id` seconds on each engine")
tic = time.time()
tic = time.perf_counter()
ar = dv.apply(time.sleep, ref)
for i, r in enumerate(ar):
print("%i: %.3f" % (i, time.time() - tic))
print(f"{i}: {time.perf_counter() - tic:.3f}")


def sleep_here(t):
Expand All @@ -50,22 +50,22 @@ def sleep_here(t):
# one call per task
print("running with one call per task")
amr = v.map(sleep_here, [0.01 * t for t in range(100)])
tic = time.time()
tic = time.perf_counter()
for i, r in enumerate(amr):
print("task %i on engine %i: %.3f" % (i, r[0], time.time() - tic))
print(f"task {i} on engine {r[0]}: {time.perf_counter() - tic:.3f}")

print("running with four calls per task")
# with chunksize, we can have four calls per task
amr = v.map(sleep_here, [0.01 * t for t in range(100)], chunksize=4)
tic = time.time()
tic = time.perf_counter()
for i, r in enumerate(amr):
print("task %i on engine %i: %.3f" % (i, r[0], time.time() - tic))
print(f"task {i} on engine {r[0]}: {time.perf_counter() - tic:.3f}")

print("running with two calls per task, with unordered results")
# We can even iterate through faster results first, with ordered=False
amr = v.map(
sleep_here, [0.01 * t for t in range(100, 0, -1)], ordered=False, chunksize=2
)
tic = time.time()
tic = time.perf_counter()
for i, r in enumerate(amr):
print("slept %.2fs on engine %i: %.3f" % (r[1], r[0], time.time() - tic))
print(f"slept {r[1]:.2f}s on engine {r[0]}: {time.perf_counter() - tic:.3f}")
10 changes: 5 additions & 5 deletions docs/source/examples/pi/parallelpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import ipyparallel as ipp

# Files with digits of pi (10m digits each)
filestring = 'pi200m.ascii.%(i)02dof20'
files = [filestring % {'i': i} for i in range(1, 21)]
filestring = 'pi200m.ascii.{}of20'
files = [filestring.format(i) for i in range(1, 21)]

# Connect to the IPython cluster
c = ipp.Client()
Expand All @@ -42,7 +42,7 @@
v = c[:]
v.block = True
# fetch the pi-files
print("downloading %i files of pi" % n)
print(f"downloading {n} files of pi")
v.map(fetch_pi_file, files[:n]) # noqa: F821
print("done")

Expand All @@ -60,10 +60,10 @@
freqs150m = reduce_freqs(freqs_all)
t2 = clock()
digits_per_second8 = n * 10.0e6 / (t2 - t1)
print("Digits per second (%i engines, %i0m digits): " % (n, n), digits_per_second8)
print(f"Digits per second ({n} engines, {n}0m digits): ", digits_per_second8)

print("Speedup: ", digits_per_second8 / digits_per_second1)

plot_two_digit_freqs(freqs150m)
plt.title("2 digit sequences in %i0m digits of pi" % n)
plt.title(f"2 digit sequences in {n}0m digits of pi")
plt.show()
9 changes: 3 additions & 6 deletions docs/source/examples/task_profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ def main():
]
stime = sum(times)

print(
"executing %i tasks, totalling %.1f secs on %i engines"
% (opts.n, stime, nengines)
)
print(f"executing {opts.n} tasks, totalling {stime:.1f} secs on {nengines} engines")
time.sleep(1)
start = time.perf_counter()
amr = view.map(time.sleep, times)
Expand All @@ -74,8 +71,8 @@ def main():
scale = stime / ptime

print(f"executed {stime:.1f} secs in {ptime:.1f} secs")
print("%.3fx parallel performance on %i engines" % (scale, nengines))
print("%.1f%% of theoretical max" % (100 * scale / nengines))
print(f"{scale:.3f}x parallel performance on {nengines} engines")
print(f"{scale / nengines:.1%} of theoretical max")


if __name__ == '__main__':
Expand Down
Loading
Loading