A tool designed to retrieve messages from the IOPub channel of a Jupyter kernel using jupyter_client, capturing cell outputs and logs.
Project description
Swarmauri Tool Jupyter Get IO PubMessage
A Python tool designed to retrieve messages from the IOPub channel of a Jupyter kernel using jupyter_client, capturing cell outputs, logging information, and errors.
Installation
To install swarmauri_tool_jupytergetiopubmessage, make sure you have Python 3.10 or later. You can install the latest release from PyPI using:
pip install swarmauri_tool_jupytergetiopubmessage
Verify the installation by opening a Python shell and importing the module:
python
import swarmauri_tool_jupytergetiopubmessage print(swarmauri_tool_jupytergetiopubmessage.version) '0.1.0.dev1'
If you see a valid version number, the package is installed and ready to use.
Usage
Below is a brief example of how to use JupyterGetIOPubMessageTool to capture messages from an active Jupyter kernel. In most scenarios, you will have a running Jupyter kernel and a kernel client available.
Example usage:
from jupyter_client import KernelManager from swarmauri_tool_jupytergetiopubmessage import JupyterGetIOPubMessageTool
Initialize a new Jupyter kernel
km = KernelManager() km.start_kernel() kc = km.client() kc.start_channels()
Execute a sample command in the kernel to produce some output
kc.execute("print('Hello from the kernel!')")
Initialize and use the JupyterGetIOPubMessageTool
tool = JupyterGetIOPubMessageTool() result = tool(kernel_client=kc, timeout=3.0)
print("Captured stdout:", result["stdout"]) print("Captured stderr:", result["stderr"]) print("Captured logs:", result["logs"]) print("Execution results:", result["execution_results"]) print("Did timeout occur?:", result["timeout_exceeded"])
Clean up kernel resources
kc.stop_channels() km.shutdown_kernel()
This usage example demonstrates how to retrieve stdout messages, stderr messages, logs (including certain non-stream messages), and results from executed cells. The timeout parameter controls how long the tool waits for IOPub messages before returning. If the time is exceeded, "timeout_exceeded" will be True.
Dependencies
• Python 3.10 to 3.13
• jupyter_client
• swarmauri_core (for component registration)
• swarmauri_base (for the base tool functionality)
Additional development dependencies (e.g., flake8, pytest) are specified in the pyproject.toml file but not required for basic usage.
Building & Testing
This package uses Poetry for its build system. You may use any standard Python tooling to install and test in your environment. See above Installation instructions for installing into your project.
© 2023 Swarmauri. All rights reserved. This project is licensed under the Apache-2.0 License. Use of this tool is governed by the license conditions included in the repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_tool_jupytergetiopubmessage-0.7.1.tar.gz.
File metadata
- Download URL: swarmauri_tool_jupytergetiopubmessage-0.7.1.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb180ddac49d5300e990483d2b4b266d57411c03d55083ca1c9b1ae2eb8aa79a
|
|
| MD5 |
543cebfafacf6f81f7ae6adce581459b
|
|
| BLAKE2b-256 |
7d90775b8e4a7a8b1ed125829411be749e1d888fd5e0b78c932fd0fff270b0dd
|
File details
Details for the file swarmauri_tool_jupytergetiopubmessage-0.7.1-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_jupytergetiopubmessage-0.7.1-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8f2e90be617569490b8d3f7587ad1951aee491200f58fcf7a326d59f53f524a
|
|
| MD5 |
856b9bb8e449b9307a5867c11006f113
|
|
| BLAKE2b-256 |
645c69c7aee3319436b1eac71578cbee49c1ef55ef82adfb88270298d5bbc405
|