Skip to main content

jupywire

jupywire provides shared Jupyter protocol code for kernmini, jupygate, jupyasyncclient, and conkernelclient. It handles wire-format messages, connection files, and common kernel-client operations.

What's here

The package has four modules:

  • jupywire.session provides Session for constructing and HMAC-signing Jupyter messages. It serializes and deserializes frames and provides replay protection. to_frame and from_frame convert a message to and from a websocket frame: JSON text, or binary when the message carries buffers. They build on the module's JSON helpers, dumps and loads. The module also includes validate_string_dict.
  • jupywire.connect provides write_connection_file. It selects random free ports and writes a kernel connection file with permissions 0600.
  • jupywire.route provides RouterOps for routing kernel-client messages and JmsgQueues for queue-based access to them.
  • jupywire.ops provides EvalOps, a mixin for evaluation and variable operations on kernel clients.

Install

pip install jupywire

Client messages

RouterOps provides these ways to receive execution results:

  • reply() awaits one execute_reply.
  • run() sends the execution request when called. It returns an async generator of every message caused by that execution.
  • exec_outs collects the results from run and returns a list of rendered results.

run uses each return value from on_stdin to send an input_reply with the correct parent. allow_stdin defaults to whether an on_stdin hook is present. Pass allow_stdin=True without a hook to handle prompts through the application's on_jmsg callback.

Gateway restarting and execution_lost notifications end pending replies and runs with ConnectionError. They do not call on_dead. Actual kernel death ends them with DeadKernelError and calls on_dead.

Every inbound message also goes once to the application's on_jmsg callback, in receive order, after request routing. This includes collected run messages and stdin handled by a run callback. Receiving a notification does not transfer ownership of that stdin exchange. Keep the handler a cheap dispatcher; an awaitable return blocks the transport reader until it completes. Use JmsgQueues to pull the same messages from queues.

request sends any named protocol request. shell and control provide channel-specific helpers. Named methods include complete, inspect, check, history, and comm_msg.

The transport must supply execute, send, and a session. Its read loop passes incoming messages to route. DESIGN.md specifies the full contract. Both clients inherit the conformance suite in tests/test_route.py.

Evaluation and variables

EvalOps provides eval, ipy, the ipyfuncs service methods, retr, eval_expr, and user_exprs. It also provides xpush and xenv for synchronous fire-and-forget calls.

These operations use the client's reply or execute method. reply waits for a shell reply. execute sends without awaiting a reply.

Pass sidecar_=True to evaluate in the persistent sidecar. kernmini creates a missing named subshell on first use. Variable operations use this serial sidecar by default. Ordinary eval calls use the main shell by default.

Credits

jupywire.session and jupywire.connect are adapted from jupyter_client, specifically jupyter_client.session, jupyter_client.connect, and jupyter_client.client. Copyright (c) Jupyter Development Team. The source is distributed under the Modified BSD License (BSD-3-Clause). See that project's COPYING.md.

The adaptations remove traitlets and retain wire compatibility. Each module's docstring records its differences from the original.

Metadata

Release files for jupywire 0.1.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupywire 0.1.15
File Size Uploaded Provenance Actions
jupywire-0.1.15.tar.gz 24.3 kB Without provenance Details for jupywire-0.1.15.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jupywire 0.1.15
File Interpreter ABI Platform Actions
jupywire-0.1.15-py3-none-any.whl Python 3 none any Details for jupywire-0.1.15-py3-none-any.whl

Total release size: 44.2 kB

Release files / jupywire-0.1.15.tar.gz

Download URL jupywire-0.1.15.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b08dddc9c4f4329d8a90745b94603ffaa0e7e0860f28643ef09ce9cd38a73524
BLAKE2b-256 checksum
How to use checksums
001e1ec682b84bfc7ce927e54726c56a56bcea50582a95c87875d91795e2dcd1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / jupywire-0.1.15-py3-none-any.whl

Download URL jupywire-0.1.15-py3-none-any.whl
Size 19.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1414bcda746de696c71ca04116033d7824c28ff2326b6d6f14def30096f5e9a7
BLAKE2b-256 checksum
How to use checksums
608673fa66692304f74c11f82c3ac9b201d85aee954ffa221bcd83ba8cfba652
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Security for jupywire 0.1.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page