Crates.io | runtimelib |
lib.rs | runtimelib |
version | 0.16.1 |
source | src |
created_at | 2024-03-06 00:29:51.179275 |
updated_at | 2024-10-31 23:24:55.292756 |
description | Jupyter runtime library |
homepage | |
repository | https://github.com/runtimed/runtimed |
max_upload_size | |
id | 1164217 |
size | 90,024 |
runtimelib
is a Rust library for interacting with Jupyter kernels and managing interactive computing environments. It provides a set of tools and abstractions to simplify the process of working with various programming language runtimes, enabling developers to build powerful applications that leverage the capabilities of Jupyter kernels.
runtimelib serves as the foundation for building interactive computing applications, REPLs, and notebook-like interfaces. It abstracts away the complexities of communicating with Jupyter kernels, allowing developers to focus on creating rich, interactive experiences for users.
Key features of runtimelib include:
Whether you're building a new notebook application, creating a specialized REPL, or integrating interactive computing capabilities into your existing projects, runtimelib provides the tools and flexibility you need to get started quickly and efficiently.
Add this to your Cargo.toml
:
[dependencies]
runtimelib = "0.15.1"
By default, RuntimeLib uses Tokio as its async runtime. If you want to use the async-dispatcher runtime instead, you can enable it with the following feature flag:
[dependencies]
runtimelib = { version = "0.15.1", features = ["async-dispatcher-runtime"] }
Here's a simple example of how to use RuntimeLib to start a Jupyter kernel and execute some code:
use runtimelib::jupyter::{client::JupyterRuntime, KernelspecDir};
use runtimelib::messaging::{ExecuteRequest, JupyterMessage};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Find and start a Python kernel
let kernelspec = KernelspecDir::new(&"python3".to_string()).await?;
let runtime = JupyterRuntime::new(kernelspec).await?;
// Attach to the runtime
let mut client = runtime.attach().await?;
// Execute some Python code
let execute_request = ExecuteRequest::new("print('Hello, World!')".to_string());
let message: JupyterMessage = execute_request.into();
let response = client.send(message).await?;
println!("Execution response: {:?}", response);
Ok(())
}
This example demonstrates how to start a Python kernel, attach to it, and execute a simple Python command.
For more detailed information about the API and its usage, please refer to the API documentation.
We welcome contributions to RuntimeLib! If you'd like to contribute, please:
Please make sure to update tests as appropriate and adhere to the existing coding style.
RuntimeLib is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE-APACHE and LICENSE-MIT for details.