Skip to main content

NeXosim-py

NeXosim-py is a python interface for the NeXosim simulation server.

The library provides:

  • an interface to control and monitor simulations over HTTP/2 or unix domain sockets,
  • an API for the (de)serialization of Rust types,
  • asyncio support.

Compatibility

NeXosim-Py NeXosim
0.1.0 >=0.3.2 <0.4.0
0.2.x 1.0.0

Supported python versions: 3.11, 3.12, 3.13, 3.14

Installation

To install the package, use pip:

pip install nexosim-py

Documentation

The latest documentation and the user guide can be found here.

Example

Given a server implementation:

use std::error::Error;

use nexosim::model::Model;
use nexosim::ports::{EventSource, Output, SinkState, event_queue_endpoint};
use nexosim::server;
use nexosim::simulation::{Mailbox, SimInit};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Default)]
pub(crate) struct AddOne {
    pub(crate) output: Output<u16>,
}

#[Model]
impl AddOne {
    pub async fn input(&mut self, value: u16) {
        self.output.send(value + 1).await;
    }
}

fn bench(_cfg: ()) -> Result<SimInit, Box<dyn Error>> {
    let mut model = AddOne::default();
    let model_mbox = Mailbox::new();

    let mut bench = SimInit::new();

    let output = event_queue_endpoint(&mut bench, SinkState::Enabled, "add_1_output")?;
    model.output.connect_sink(output);

    EventSource::new()
        .connect(AddOne::input, &model_mbox)
        .bind_endpoint(&mut bench, "add_1_input")?;

    Ok(bench.add_model(model, model_mbox, "Adder"))
}

fn main() {
    server::run(bench, "0.0.0.0:41633".parse().unwrap()).unwrap();
}

You can interact with the simulation using this library like this:

from nexosim import Simulation

with Simulation("0.0.0.0:41633") as sim:
    sim.build()
    sim.init()
    sim.process_event("add_1_input", 5)

    print(sim.try_read_events("add_1_output"))

# Prints out:
# [6]

Metadata

Release files for NeXosim-py 0.2.1

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

Source distribution (sdist)

Source distribution for NeXosim-py 0.2.1
File Size Uploaded Provenance
nexosim_py-0.2.1.tar.gz 76.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for NeXosim-py 0.2.1
File Interpreter ABI Platform
nexosim_py-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 121.3 kB

Release files / nexosim_py-0.2.1.tar.gz

Download URL nexosim_py-0.2.1.tar.gz
Size 76.8 kB
Tags Source
SHA-256 checksum
How to use checksums
57b61953e993b33f85100530da19b430c470067e7cb1fe912a0aff3c17b29519
BLAKE2b-256 checksum
How to use checksums
20eb005cc097cdadb27bf926955b3610201bcf2cfbbd9755c5a90be5f8540b7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / nexosim_py-0.2.1-py3-none-any.whl

Download URL nexosim_py-0.2.1-py3-none-any.whl
Size 44.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
08825d64fbbca842eb735af867946569709b87ab85eeee4aa1e6da6619eed4ae
BLAKE2b-256 checksum
How to use checksums
e1abb5af451ae398609c96066795fbbdcdfd05c963555907736ace9ade7e3323
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Security for NeXosim-py 0.2.1

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