Coral for python libraries
- Python 3.12+
- uv installed
ffmpeginstalled and onPATH(e.g.apt install ffmpeg/brew install ffmpeg) — required for.mp4export from the PhiFlow scripts and thephiflow_plot_and_saveworkflow node, which call matplotlib'sanim.save(..., writer='ffmpeg'). Not needed for.gifexport.
This is a uv project: dependencies are declared in
pyproject.toml and pinned in uv.lock.
# Create .venv and install all dependencies (incl. the dev group) from the lockfile
uv syncThen either activate the environment (source .venv/bin/activate) or prefix commands with uv run
(e.g. uv run python main.py). uv run auto-syncs the environment against uv.lock before running.
# Add a runtime dependency (updates pyproject.toml + uv.lock, then syncs the env)
uv add <package-name>
# Add a dev-only dependency
uv add --dev <package-name>
# Re-resolve / update the lockfile and sync the environment
uv lock
uv sync
requirements.in/requirements.txtare retained for reference only;pyproject.toml+uv.lockare now the source of truth for dependencies.
main.py is a coral-compatible CLI: a global -p/--plugin option naming the definition modules to load
(comma-separated, e.g. "math,string"; empty = all) plus two subcommands — register (emit the node registry)
and run (execute a workflow). -p/--plugin must precede the subcommand. This mirrors the C++ coral binary so
the DealiiX platform can drive this backend via the coral-py launcher.
Run the commands below inside an activated venv, or prefix each with
uv run(e.g.uv run python main.py run).
# Run a simulation and then check the mp4 or gif file produced
python phi_flow/one_obstacle.pyUse the run subcommand. With no graph argument it defaults to network-from-fe.json:
python main.py runRun a specific workflow file:
python main.py run path/to/your/workflow.jsonLoad specific modules with -p/--plugin (before the subcommand):
# Load only math operations
python main.py -p "math" run workflow.json
# Load multiple modules
python main.py -p "math,string,phiflow" run workflow.jsonDefault behavior: When -p/--plugin is omitted, all available modules are loaded. Primitives are always included.
Available modules:
phiflow- PhiFlow physics simulation wrappers (default)math- Mathematical operations (add,multiply,math.sqrt, etc.) andCalculatorclassstring- String processing utilities (StringProcessorclass)
Use the register subcommand. It writes node_types.json into the current directory (the filename the
DealiiX platform probes for):
python main.py registerGenerate the registry for specific modules:
# Math operations only
python main.py -p "math" register
# Multiple modules
python main.py -p "math,string,phiflow" registerCustom output filename:
python main.py register --output="custom_registry.json"coral-py runs main.py inside this repo's uv project while preserving the caller's working directory, so
register writes node_types.json into that directory. Point the platform's coralBinaryPath at it and set
coralPluginPath to the module list:
./coral-py -p "math" register # writes node_types.json into the current directory
./coral-py -p "math" run workflow.jsonSee README.md in the definitions directory for more detailed information about how different module definitions are handled.
python main.py --helpExtending or modifying coral-python? Start with docs/ONBOARDING.md — the onboarding
guide covering goals, architecture, the two contracts with the DealiiX platform, how to add a library or
change internals, design rationale, and an honest account of strengths and weaknesses. An Italian version is
at docs/ONBOARDING.it.md. (This README.md is setup + commands; CLAUDE.md is the
AI-assisted-development mechanics reference.)
Run All Tests:
pytestRun Tests with Coverage:
pytest --cov=. --cov-report=html
open htmlcov/index.html # View coverage reportRun a Specific Test File:
pytest tests/test_executor.py
pytest tests/test_integration.pyRun a Specific Test Class:
pytest tests/test_executor.py::TestPrimitiveNodeExecution
pytest tests/test_integration.py::TestPhiFlowWorkflowsRun a Specific Test Function:
pytest tests/test_executor.py::TestPrimitiveNodeExecution::test_int_primitiveRunning Specific Test Categories:
pytest -m unit # To be marked
pytest -m integration # Integration tests with Json network files
pytest -m math # Math module tests
pytest -m phiflow # PhiFlow tests (requires PhiFlow)
pytest -m string # String module testsVerbose Output:
pytest -v # Verbose
pytest -vv # Extra verbose
pytest -s # Show print statementsFor more info see the README.md in the tests directory.