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/-Hand--port/-poverride bind address and port.INVARIANT_HOSTandINVARIANT_PORTset defaults when flags are omitted.--reloadenables 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/SOLUsolve).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@idchat mentions (e.g.@ansys).GET /integrations/{id}/context— JSON snapshot for the IDE agent. Foransys, 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) sopipand theinvariantscript stay isolated. - Binding to
127.0.0.1(default) is appropriate for a local CAD companion; use0.0.0.0only 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
- Create accounts on PyPI and TestPyPI if you do not have them.
- Configure trusted publishing (recommended) or store credentials with a tool such as keyring; avoid committing tokens.
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f001fbffec5a4f5efe6473a88601754234d9cec398c5a1faeae63b7a5bb28a1
|
|
| MD5 |
7517fdf708621b329bb1c09baec137c7
|
|
| BLAKE2b-256 |
2b887c75c6196a7c2ef8727e881be17c02234491cd954bd81bf12f00df52057c
|
Provenance
The following attestation bundles were made for invariant_daemon-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on in-variant/invariantd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
invariant_daemon-0.1.0.tar.gz -
Subject digest:
0f001fbffec5a4f5efe6473a88601754234d9cec398c5a1faeae63b7a5bb28a1 - Sigstore transparency entry: 1261733206
- Sigstore integration time:
-
Permalink:
in-variant/invariantd@27f2a75e7a7fb5ae24725ac535c0ed82d6b955ba -
Branch / Tag:
refs/heads/main - Owner: https://github.com/in-variant
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@27f2a75e7a7fb5ae24725ac535c0ed82d6b955ba -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file invariant_daemon-0.1.0-py3-none-any.whl.
File metadata
- Download URL: invariant_daemon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7832d1c9932f41478ad9bbd614a0814569f9260a36319f41c450a79d4fe6e38
|
|
| MD5 |
8ccf109a4c548d28fc1bc1a9a06d487d
|
|
| BLAKE2b-256 |
a89e0e673a1eaf5d10908ce9ea060bdf295648800c7ad5c85bfa5a0f04590c49
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
invariant_daemon-0.1.0-py3-none-any.whl -
Subject digest:
c7832d1c9932f41478ad9bbd614a0814569f9260a36319f41c450a79d4fe6e38 - Sigstore transparency entry: 1261733453
- Sigstore integration time:
-
Permalink:
in-variant/invariantd@27f2a75e7a7fb5ae24725ac535c0ed82d6b955ba -
Branch / Tag:
refs/heads/main - Owner: https://github.com/in-variant
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@27f2a75e7a7fb5ae24725ac535c0ed82d6b955ba -
Trigger Event:
workflow_dispatch
-
Statement type: