Skip to content

Project layout and build

This page explains the node project you get from the node-template repository: what every file is for, how to name the project, how to add a node so it ships in the image, and what the Dockerfile and docker-compose.yml do. After reading it you can turn a node that works in the Mock Runner into a container image that a Neuraverse engine can run.

The template as shipped

External inputs require this SDK in the built node image. Update the project's SDK pin and wheel set together, then rebuild the image. C++ projects must use matching SDK builder and runtime versions. Changing a project pin alone does not update a running node.

A standalone custom gRPC service can use the same SDK runtime without defining graph nodes. The SDK's native build includes the shared CRUD example proto and, in test images, its C++ example and acceptance host. Install the Python SDK wheel as usual and package your own application proto/bindings with your service. The wheel and SDK image include neuraverse-generate-protos; invoke it in your application build to generate Python and/or C++ bindings. C++ generation uses the builder environment's native toolchain.

Start every node project from the Python template (node-template/ inside the node-template repository). It is a complete, buildable project with four example nodes.

node-template/
├── Dockerfile                 # builds your node image on top of the SDK base image
├── docker-compose.yml         # runs the image; the "mock" profile runs the Mock Runner
├── .gitlab-ci.yml             # CI pipeline (placeholders to replace, see Naming)
├── pyproject.toml             # project name/version, node packages, vendored wheels
├── poetry.lock
├── config/
│   ├── service_config.yaml    # ports, broker, registry, JWT (read by the SDK at start)
│   └── log_config.yaml        # Python logging config (handlers, levels)
├── wheels/                    # the SDK and its libraries as .whl files + SHA256SUMS
├── tests/                     # schema-vs-code test, conftest.py, _testing/fake_dataflow.py
└── src/
    ├── run_nodes.py           # entry point: registers node classes, starts the service
    ├── node_utils.py          # set_env_defaults(), discover_node_classes()
    ├── hello_world_node/
    │   ├── hello_world_node.py
    │   └── hello_world_node_schema.json
    ├── float_publisher_node/  # same pair per node
    ├── float_monitor_node/
    └── republisher_node/

What matters in each part:

Path Purpose You edit it when
src/<node>/<node>.py One module per node with the class extending NodeBase. Every new node.
src/<node>/<node>_schema.json The palette schema. The SDK loads the file named <module>_schema.json next to the module at startup; if it is missing the node registers with only its class name and no ports. Every new node. See Schema file reference.
src/run_nodes.py Registers the node classes and starts the node service. Every new node (unless you use auto-discovery).
src/node_utils.py Helpers: derives runtime environment variables from pyproject.toml, optional class discovery. Rarely.
pyproject.toml Project name and version, the packages list, the SDK wheels, your extra dependencies. Naming the project, every new node, new dependencies.
wheels/ + SHA256SUMS The Python SDK and its six companion libraries, pinned to one SDK release. Never by hand. Bump with the repository's scripts/bump-sdk.sh.
config/service_config.yaml Runtime settings of the node service (gRPC/HTTP ports, MQTT broker, registry, JWT). Deployment. See Deploying on an engine.
config/log_config.yaml Log formatters and levels. Rarely.
Dockerfile, docker-compose.yml, .gitlab-ci.yml Build and run. Naming the project; extra system packages.

Only the files under src/ are node code. Everything else is project plumbing that the template already gets right.

Note

The example nodes are learning material. Delete the four example directories, their entries in run_nodes.py and their packages lines in pyproject.toml before you hand the project over.

Naming the project

One name identifies your node container everywhere: neuraverse-node-<name>, where <name> is kebab-case (image-processor, not image_processor). The template ships with the placeholder neuraverse-node-__YOUR_NODE_CONTAINER_NAME__. Replace it in all of these:

File Field
pyproject.toml name
.gitlab-ci.yml APPLICATION_NAME and IMAGE_FILE_PATH
docker-compose.yml the commented image: line of the neuraverse-node service (uncomment it)
config/service_config.yaml mqtt.client_id and container_name

Set version in pyproject.toml as well and bump it with every release. You do not set SERVICE_NAME and SERVICE_TAG by hand: the entry point calls set_env_defaults(), which reads name and version from pyproject.toml and exports them as SERVICE_NAME and SERVICE_TAG unless the environment already defines them. The same helper supplies defaults for the config path, the log config path and two deprecated AUTH_* variables (see below).

Adding a node

Three steps make a node part of the project.

1. Create the file pair. A directory src/<node>/ with <node>.py (the class) and <node>_schema.json (the schema). The class name in the file must equal executionContext.className in the schema. The Quickstart walks through writing both files.

2. Register the class. run_nodes.py must call set_node_classes() with every class before run(); starting without any class raises RuntimeError inside the service bootstrap.

from neuraverse_sdk.node_manager_service import run, set_node_classes
from node_utils import set_env_defaults


def main() -> None:
    from hello_world_node.hello_world_node import HelloWorldNode
    from my_node.my_node import MyNode

    set_node_classes([HelloWorldNode, MyNode])
    run()


if __name__ == "__main__":
    set_env_defaults()
    main()

Call set_env_defaults() first, as the template does: it fills in SERVICE_NAME, SERVICE_TAG and the config paths that the service reads when run() starts.

3. List the package. Add the directory to packages in pyproject.toml, so the project installs it into the image's virtual environment:

packages = [
    {include = "hello_world_node", from = "src"},
    {include = "my_node", from = "src"},
]

Then rebuild the image (docker compose build neuraverse-node). The Mock Runner does not need steps 2 and 3: it mounts src/ and imports every module it finds.

Auto-discovery instead of an explicit list

node_utils.discover_node_classes(src_dir) imports every .py file under src/ and returns every subclass of NodeBase it finds. It saves editing run_nodes.py, at the price of executing every module in src/ at startup, tests included. Keep the explicit list for projects that ship.

If your project needs service-level hooks shared by all its nodes (for example loading a model once), pass a NodeServiceBase subclass to set_node_service_class() before run(). The Cloud upload tutorial shows one.

The Dockerfile

The template's Dockerfile is short and every line has a job (abridged, comments removed):

ARG BASE_IMAGE=registry.gitlab.neura-robotics.com/neuraverse/neuraverse-node-sdk:v2.46.2
FROM ${BASE_IMAGE}

RUN apt-get update && apt-get install -y ros-humble-vision-msgs   # extra apt packages go here

WORKDIR /neuraverse-node
COPY pyproject.toml ./
COPY src/ ./src/
COPY config/ ./config/
COPY wheels/ ./wheels/
RUN cd wheels && sha256sum -c SHA256SUMS

RUN poetry lock && poetry install
RUN poetry run pip install --quiet "grpcio>=1.80.0" "grpcio-tools>=1.80.0" "grpcio-reflection>=1.80.0"

HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
    CMD curl -f http://localhost:8089/health || exit 1

CMD ["poetry", "run", "python", "src/run_nodes.py"]

The base image. FROM registry.gitlab.neura-robotics.com/neuraverse/neuraverse-node-sdk:vX.Y.Z, where X.Y.Z is the SDK release. The tag comes in through the BASE_IMAGE build argument, and docker-compose.yml passes the same value, so the pin lives in one place per file. The image is built for amd64 and arm64. It contains:

  • ROS 2 Humble with rclpy and the common message packages (std_msgs, geometry_msgs, sensor_msgs, vision_msgs, audio_common_msgs, cv_bridge) plus the NEURA message packages
  • a DDS configuration that works inside Docker, and ROS_DOMAIN_ID=0 as the default
  • pip and poetry
  • the C++ SDK libraries (irrelevant for Python nodes)

The base image does not contain the Python SDK

The image gives you ROS 2, the message types and Poetry. The SDK package itself (lib-python-neuraverse-node-sdk) and its six companion libraries are installed by poetry install from the wheels/ directory (or from the package registry, see below). A Dockerfile that skips poetry install produces an image where import neuraverse_sdk fails.

The wheels. pyproject.toml points each SDK library at a file in wheels/:

[tool.poetry.dependencies]
neuraverse_entities_apis_messages = {path = "wheels/neuraverse_entities_apis_messages-2.69.0-py3-none-any.whl"}
neuraverse-project-v2-apis = {path = "wheels/neuraverse_project_v2_apis-19.0.0-py3-none-any.whl"}
neuraverse-asset-v2-apis = {path = "wheels/neuraverse_asset_v2_apis-27.2.0-py3-none-any.whl"}
lib-python-neuraverse-node-sdk = {path = "wheels/lib_python_neuraverse_node_sdk-2.51.0-py3-none-any.whl"}
lib-python-neuraverse-common = {path = "wheels/lib_python_neuraverse_common-2.9.0-py3-none-any.whl"}
lib-python-neuraverse-service-http = {path = "wheels/lib_python_neuraverse_service_http-2.3.0-py3-none-any.whl"}
lib-python-neuraverse-service-grpc = {path = "wheels/lib_python_neuraverse_service_grpc-2.6.0-py3-none-any.whl"}

The build verifies them against wheels/SHA256SUMS before installing, so a wheel that was swapped or truncated fails the build instead of producing a broken image. The wheel versions, the base image tag and the Mock Runner image tags are one set that belongs to one SDK release. The repository's scripts/bump-sdk.sh rewrites all of them together; do not edit them one by one.

Dependencies. poetry lock && poetry install resolves and installs your project, the wheels and any packages you add under [tool.poetry.dependencies]. Add your own dependencies there (requests, pillow in the template). The SDK already brings numpy and opencv-python-headless.

The gRPC upgrade line. The vendored libraries pin grpcio to 1.74.0. The template then upgrades grpcio, grpcio-tools and grpcio-reflection with pip because the generated gRPC stubs need a newer release. Keep this line as it is.

Healthcheck. The probe port must equal http.port in config/service_config.yaml (8089 in the template). If you change the port in one place, change it in the other, otherwise the container never reports healthy. The SDK's HTTP server answers on / with a small status page and returns 400 for every other path, /health included, so a probe of /health never reports healthy. Point the probe at / (curl -f http://localhost:8089/).

Entry point. CMD ["poetry", "run", "python", "src/run_nodes.py"] runs your registration script inside the Poetry environment. The working directory is /neuraverse-node, which is why the default config path config/service_config.yaml resolves.

Alternative: the SDK from the package registry

If your build environment can reach the NEURA package registry, you can depend on the SDK by version instead of vendoring wheels:

[[tool.poetry.source]]
name = "gitlab-hrg"
url = "https://gitlab.neura-robotics.com/api/v4/groups/2997/-/packages/pypi/simple"
priority = "supplemental"

[tool.poetry.dependencies]
lib-python-neuraverse-node-sdk = { source = "gitlab-hrg", version = "2.40.0" }

Pin an exact version and keep it equal to the base image tag. Poetry needs credentials for the source (poetry config http-basic.gitlab-hrg __token__ <token>), both on your machine and in the Docker build. The vendored wheels exist so that a partner build needs no registry access; prefer them unless you have a reason not to.

docker-compose.yml

The compose file serves two purposes.

Developing in the Mock Runner. The services mock-backend, mock-frontend and docs carry profiles: ["mock"], so a plain docker compose up ignores them. Start them by name:

docker compose up -d mock-backend mock-frontend docs

The backend mounts your src/ directory read-write and re-imports it on Reload Code, so nothing is built. A bare docker compose up would instead build and start the deployable neuraverse-node image, which is slow and not what you want while iterating.

Running the built image. The neuraverse-node service builds the Dockerfile with the same BASE_IMAGE tag and starts it with network_mode: host. Host networking is required: service_config.yaml addresses the MQTT broker, the registry and the engine on loopback.

The service passes these variables from your shell into the container (a bare name in environment: forwards the value only when it is set):

Variable Read by Default in the template Meaning
SERVICE_NAME SDK service info name from pyproject.toml Service name in log and metrics labels
SERVICE_TAG SDK service info version from pyproject.toml Service version in log and metrics labels
ENVVAR_CFG_PATH SDK configuration loader config/service_config.yaml Path of the YAML config
ENVVAR_LOG_CFG_PATH SDK logging config/log_config.yaml Path of the logging config
AUTH_ISSUER, AUTH_JWKS_URL two deprecated fields of the jwt block development identity provider Kept for compatibility only. Token validation uses jwt.domain and jwt.applications from service_config.yaml, see service_config.yaml reference
ROS_DOMAIN_ID ROS 2 0 (base image) Must equal the domain of the engine and the other nodes on the host
SERVICE_CONFIG nothing in the SDK same as ENVVAR_CFG_PATH Template-only alias. The SDK reads ENVVAR_CFG_PATH; set that one to override the config path

All defaults come from set_env_defaults() in node_utils.py, which only fills variables that are not already set. An operator therefore overrides any of them from the shell or from a deployment manifest without touching your code.

Local build checklist

Before you hand the project over or push it to CI:

  1. Placeholder replaced everywhere (grep -r __YOUR_NODE_CONTAINER_NAME__ . prints nothing).
  2. Every node has its file pair and is listed in run_nodes.py and in packages.
  3. docker compose build neuraverse-node succeeds.
  4. docker compose up neuraverse-node starts and an early log line reads Node classes set to [...] with your classes. A complete start also needs the broker and registry described in Deploying on an engine; stop with Ctrl+C.
  5. Your unit tests pass, see Testing.

Next steps

  • Deploying on an engine: namespaces, registry, what to send your NEURA contact.
  • Testing: pytest with a fake data flow, schema consistency, the Mock Runner.
  • A C++ node uses the same base image and the node-template-cpp/ directory of the same repository.