Skip to main content

Python SDK for NexusFlow model editing and simulation workflows

Project description

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
  • 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))
load = model.add_component("Load", position=(480, 0))

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

model.save()
job = model.run(timeout=120, image="nexusflow")

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

Public API

The package currently exports these main entry points:

  • NexusFlowClient
  • Model
  • Component
  • Connection
  • Job
  • MetaService
  • ResultStream
  • LogMessage
  • PlotMessage
  • TableMessage
  • InspectMessage
  • ContainerMessage
  • NexusFlowError
  • AuthError
  • APIError
  • NotFoundError
  • ValidationError

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.1.2-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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexusflow_sdk-0.3.0.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexusflow_sdk-0.3.0-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

Details for the file nexusflow_sdk-0.3.0.tar.gz.

File metadata

  • Download URL: nexusflow_sdk-0.3.0.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nexusflow_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4a29f3c404f9043cabf5083643808ecbd4f0cbe6a15315297328d6329d5a685b
MD5 c78049d84c5849504c3534c0f63f8626
BLAKE2b-256 cfaafcd9d5084dac656e88056c63eed45c6546e084b0c21c453ea7ed920a5360

See more details on using hashes here.

File details

Details for the file nexusflow_sdk-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: nexusflow_sdk-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for nexusflow_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fc87d396e84d22d30c2f3a3ac5b56ef1836f677420f487ab05201d78e6a60b8d
MD5 332c281d7d663d4221989c17765213b1
BLAKE2b-256 7dab75c0bbcb58f427c661e4d92d4d30d17e7b3ad0d6b9dffbca2b77eb5e9e00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page