Skip to main content

Invariant local daemon for CAD integrations

Project description

Invariant

Local daemon for CAD and simulation integrations: FastAPI (HTTP + WebSocket), uvicorn, Typer CLI.

Install (development)

From the repository root:

pip install -e .
# optional: live Ansys MAPDL (PyMAPDL)
pip install -e ".[ansys]"

Run

invariant run

Optional flags and environment variables:

  • --host / -H and --port / -p override bind address and port.
  • INVARIANT_HOST and INVARIANT_PORT set defaults when flags are omitted.
  • --reload enables auto-reload (development only; uses an import string so it works on Windows, Linux, and macOS).

Examples:

invariant run --port 8080
set INVARIANT_PORT=8080
invariant run

On Windows (cmd):

set INVARIANT_PORT=8080
invariant run

On Windows (PowerShell):

$env:INVARIANT_PORT = 8080
invariant run

API

  • POST /models — JSON body; returns { "modelId": "m-1" }.
  • POST /models/{model_id}/run — background job: mock solve if MAPDL is not connected; if live, records a MAPDL snapshot (does not start a new /SOLU solve).
  • GET /jobs/{job_id}/result{ "status": "running" } until complete, then the result payload.
  • GET /health{ "status": "ok" }.
  • GET /integrations{ "integrations": [ { "id", "status", "label" } ] } for the Invariant IDE sidebar and @id chat mentions (e.g. @ansys).
  • GET /integrations/{id}/context — JSON snapshot for the IDE agent. For ansys, see Ansys (MAPDL) below.
  • GET /integrations/ansys/status — live vs mock mode, PyMAPDL version, gRPC target.
  • WebSocket /ws — sends a hello message; echoes text frames as JSON.

Interactive docs: http://127.0.0.1:5000/docs (default).

Ansys (MAPDL via PyMAPDL)

Install the optional dependency, then start a Mechanical APDL session with gRPC on the expected port (default 50052):

pip install "invariant-daemon[ansys]"
# or: pip install ansys-mapdl-core
Environment variable Purpose
INVARIANT_ANSYS_MODE auto (default) try live MAPDL then mock, or mock to force synthetic data
INVARIANT_MAPDL_HOST gRPC host (default 127.0.0.1; falls back to PYMAPDL_IP)
INVARIANT_MAPDL_PORT gRPC port (default 50052; falls back to PYMAPDL_PORT)
INVARIANT_MAPDL_TRANSPORT PyMAPDL transport_mode: default insecure (TCP gRPC). Use if your environment forces UDS.
INVARIANT_MAPDL_CONNECT_TIMEOUT Seconds to wait for gRPC (default 15)

At startup, the daemon logs either a live connection line or a MOCK mode warning. GET /integrations/ansys/context returns source: "mapdl_grpc" with /STATUS excerpts, mesh and geometry counts, parameters, optional POST1 summaries, and an llm_digest string when MAPDL is connected; otherwise source: "mock".

Cross-platform notes

  • Use Python 3.9+ from python.org on Windows; enable “Add Python to PATH” in the installer.
  • Prefer a virtual environment (python -m venv .venv) so pip and the invariant script stay isolated.
  • Binding to 127.0.0.1 (default) is appropriate for a local CAD companion; use 0.0.0.0 only if you need other machines on the LAN to reach the daemon (mind firewall rules).

Install from PyPI

pip install invariant-daemon
# with Ansys support:
pip install "invariant-daemon[ansys]"

Publishing to PyPI

The package is published as invariant-daemon on PyPI.

One-time setup

  1. Create accounts on PyPI and TestPyPI if you do not have them.
  2. Configure trusted publishing (recommended) or store credentials with a tool such as keyring; avoid committing tokens.
  3. Install build tools: python -m pip install --upgrade build twine.

Build

From the project root:

python -m build

This produces dist/invariant_daemon-0.1.0-py3-none-any.whl and dist/invariant_daemon-0.1.0.tar.gz (names follow your version in pyproject.toml).

Test upload (recommended)

Upload to TestPyPI first:

python -m twine upload --repository testpypi dist/*

Install from TestPyPI in a clean venv:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ invariant-daemon

(--extra-index-url pulls dependencies like FastAPI from the real PyPI.)

Production upload

python -m twine upload dist/*

Version bumps

Increase version in pyproject.toml (and keep invariant/__init__.py in sync if you expose __version__) for every new release; PyPI rejects duplicate versions.

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

invariant_daemon-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

invariant_daemon-0.1.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file invariant_daemon-0.1.0.tar.gz.

File metadata

  • Download URL: invariant_daemon-0.1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for invariant_daemon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0f001fbffec5a4f5efe6473a88601754234d9cec398c5a1faeae63b7a5bb28a1
MD5 7517fdf708621b329bb1c09baec137c7
BLAKE2b-256 2b887c75c6196a7c2ef8727e881be17c02234491cd954bd81bf12f00df52057c

See more details on using hashes here.

Provenance

The following attestation bundles were made for invariant_daemon-0.1.0.tar.gz:

Publisher: publish-pypi.yml on in-variant/invariantd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file invariant_daemon-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for invariant_daemon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7832d1c9932f41478ad9bbd614a0814569f9260a36319f41c450a79d4fe6e38
MD5 8ccf109a4c548d28fc1bc1a9a06d487d
BLAKE2b-256 a89e0e673a1eaf5d10908ce9ea060bdf295648800c7ad5c85bfa5a0f04590c49

See more details on using hashes here.

Provenance

The following attestation bundles were made for invariant_daemon-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on in-variant/invariantd

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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