Skip to main content

nexusflow-sdk

nexusflow-sdk is a Python SDK for NexusFlow model editing, simulation execution, streaming result retrieval, and runtime command control.

Features

  • Token-based authentication against the NexusFlow backend
  • Create models for supported workspace types and open existing models
  • Add, remove, connect, and configure components in the model graph
  • Create and edit two-port linear components represented as component edges
  • Create and manage multiple drawing sheets in one model
  • Save model snapshots and start simulation jobs
  • Poll or stream logs, plots, tables, inspect data, and container messages
  • Send runtime commands to components during online or transient execution

Requirements

  • Python 3.10 or later
  • A reachable NexusFlow service endpoint
  • A NexusFlow account that can obtain access tokens

Install

Install from a built wheel or from PyPI after publication:

pip install nexusflow-sdk

For local development in this repository:

pip install -e .

Quick Start

from nexusflow_sdk import NexusFlowClient

client = NexusFlowClient(
    base_url="http://localhost:8000",
    username="admin",
    password="your-password",
)

model = client.create_model(
    name="sdk-demo-model",
    workspace_type="lps_online",
    description="Created by nexusflow-sdk",
)

source = model.add_component("Source", position=(0, 0))
pipe = model.add_component("Pipe", position=(240, 0), mode="node")
load = model.add_component("Load", position=(480, 0))

model.connect(source, "0", pipe, "0")
model.connect(pipe, "1", load, "0")

model.save()
# run() validates the current snapshot through the backend by default.
job = model.run(timeout=120, image="nexusflow")

for message in job.stream_results(timeout=2):
    print(message.get("type"), message.get("key"))

New node components use the icon SVG's viewBox width and height by default, matching WorkBench. Definitions with graphMetaData.width and height can override these defaults. Missing or invalid dimensions fall back individually to width 120 and height 80. An explicit view_status takes precedence; loading existing models preserves their saved layout.

Parsed log results expose LogMessage.format as "text" or "html"; missing and unknown values safely normalize to "text". Table results retain html columns through update and append merging. The SDK exposes LogFormat, TableColumnType, and TableColumnData for type annotations, but does not render or execute HTML.

model.run(validate=True) is the default and creates no job when shared backend validation reports errors. For trusted large batch workloads, model.run(validate=False) skips only that explicit pre-run business-validation request. The job API still performs required structural, authorization, and runtime-safety checks. The SDK force-refreshes the workspace definition before every run so the submitted runtime definition does not come from a stale local cache.

Multiple Sheets

Every new model contains sheet_0. Sheet IDs are allocated as sheet_1, sheet_2, and so on for the lifetime of the model object.

process = model.default_sheet
control = model.add_sheet("Control")

source = process.add_component("Source", position=(0, 0))
controller = control.add_component("Controller", position=(0, 0))

# Physical edges stay inside one sheet. Matching trimmed, case-sensitive pin
# labels create a logical connection across sheets.
source.set_pin_label("0", "pressure_signal")
controller.set_pin_label("0", "pressure_signal")

copied = model.copy_sheet(control)
print(copied.id)  # sheet_2

Legacy snapshots with top-level nodes and edges are loaded as sheet_0. New saves always use snapshot schema version 2 with a top-level sheets array.

Linear Components

A component definition with exactly two physical ports can use mode="edge". If its definition sets linearization.defaultMode to edge, the SDK uses the linear form by default; pass mode="node" to override it.

source = model.add_component("Source", position=(0, 0))
sink = model.add_component("Sink", position=(480, 0))
pipe = model.add_component("Pipe", position=(240, 40), mode="edge")

# portsDefinition[0] is the source end and portsDefinition[1] is the target end.
pipe.attach("source", source, "0")
pipe.attach("target", sink, "0")

# Either end may be detached at an explicit free canvas point.
pipe.detach("source", point=(120, 40))

# Conversion keeps the component id, label, parameters, and pin labels.
node_pipe = pipe.delinearize()
linear_pipe = node_pipe.linearize()

Attach a LinearComponent source or target endpoint directly to a node port as shown above. model.connect(...) does not enforce this as a local business rule; use backend validation to reject an unsupported graph shape. Linear components remain available through model.components; annotation edges are kept separately in model.annotations and are excluded from physical connections and simulation topology.

Public API

The package currently exports these main entry points:

  • NexusFlowClient
  • Model
  • Component
  • LinearComponent
  • Connection
  • AnnotationEdge
  • Sheet
  • Job
  • MetaService
  • ResultStream
  • LogMessage
  • LogFormat
  • PlotMessage
  • TableMessage
  • TableColumnData
  • TableColumnType
  • InspectMessage
  • ContainerMessage
  • NexusFlowError
  • AuthError
  • APIError
  • NotFoundError
  • ValidationError
  • ValidationIssue
  • ValidationResult

Examples

  • examples/quickstart.py: create, save, run, and fetch results
  • examples/transient_streaming.py: stream transient online results and send commands during execution
  • examples/run_existing_model.py: open an existing model by ID and run it

Release Validation

Build and metadata check:

python -m build
python -m twine check dist/*

Minimal install smoke test with the built wheel:

python -m venv .smoke-venv
.smoke-venv\Scripts\python -m pip install dist\nexusflow_sdk-0.6.0-py3-none-any.whl
.smoke-venv\Scripts\python -c "from nexusflow_sdk import NexusFlowClient, Model, Job, ResultStream; print('smoke ok')"

Release Workflow

If you want to publish a new version yourself, the repository now includes a reusable PowerShell script:

.\scripts\release.ps1 -Repository pypi -Token "pypi-..."

Recommended process:

  1. Update version in pyproject.toml.
  2. Run the release script from the nexusflow-sdk directory.
  3. Wait for PyPI index propagation if the published install smoke test fails on the first try.

The script performs these steps automatically:

  • clean dist/
  • python -m build
  • python -m twine check dist/*
  • python -m unittest tests.test_public_api
  • install the built wheel into a temporary virtual environment for a local smoke test
  • upload to PyPI or TestPyPI
  • create a fresh temporary virtual environment and install the published package for a post-publish smoke test

Examples:

# Full publish to PyPI
.\scripts\release.ps1 -Repository pypi -Token "pypi-..."

# Full publish to TestPyPI
.\scripts\release.ps1 -Repository testpypi -Token "pypi-..."

# Local validation only, without upload
.\scripts\release.ps1 -SkipUpload -SkipSmokeTest

You can also avoid passing tokens on the command line by using environment variables:

$env:PYPI_TOKEN = "pypi-..."
.\scripts\release.ps1 -Repository pypi

License

This package is currently distributed as proprietary software.

Metadata

Release files for nexusflow-sdk 1.1.4

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

Source distribution (sdist)

Source distribution for nexusflow-sdk 1.1.4
File Size Uploaded Provenance Actions
nexusflow_sdk-1.1.4.tar.gz 38.4 kB Without provenance Details for nexusflow_sdk-1.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nexusflow-sdk 1.1.4
File Interpreter ABI Platform Actions
nexusflow_sdk-1.1.4-py3-none-any.whl Python 3 none any Details for nexusflow_sdk-1.1.4-py3-none-any.whl

Total release size: 74.0 kB

Release files / nexusflow_sdk-1.1.4.tar.gz

Download URL nexusflow_sdk-1.1.4.tar.gz
Size 38.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2f51b58a65fe483d224822415adbd6ebde2e145f475bc6d76a97f56645e29cf0
BLAKE2b-256 checksum
How to use checksums
3bf90e83bd007f982c4c8379424a2ee1965d948d93bc440cf6146808d996738b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / nexusflow_sdk-1.1.4-py3-none-any.whl

Download URL nexusflow_sdk-1.1.4-py3-none-any.whl
Size 35.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49cca2c095c0f1523b0af691ae5417ef31c0c8c90927eacfc33a11a42d8a6989
BLAKE2b-256 checksum
How to use checksums
9dabfa2e7f8906859ee3f858a728b18c701983a0b7b680fb9729c1dd53d7a102
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for nexusflow-sdk 1.1.4

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