Skip to content

Platform data

Besides the messages that flow over its ports, a node can reach two platform-side data sources through NodeBase: a key/value store for small JSON records that outlive a single run, and the scene of the current project (frames, robots and authored paths). After reading this page you can persist and read back a record, list the scene objects your node needs, pick a stable namespace, know which endpoints your node service must be given, and know what to expect in unit tests and in the Mock Runner.

Two sources, one prerequisite

Key/value store Scene data
What it holds JSON values keyed by namespace + key Frames, robots and paths authored in the scene editor for one project
Access Read and write Read only
NodeBase methods create_data, read_data, update_data, delete_data get_frames, get_robots, get_paths (plus set_project_id)
Needs in service_config.yaml node_engine_endpoint (and node_engine_use_tls) scene_builder_endpoint, or project_service_v2_endpoint
Errors surface as grpc.RpcError NodeStateError
Available in the Mock Runner No No

Both clients are created empty in the node constructor and connected by the engine's Initialize command, before on_configure() runs. Nothing on this page works inside __init__, and the key/value client is connected only when node_engine_endpoint is not empty. See Lifecycle and states for the order of engine commands.

Endpoints your node service needs

The endpoints live in the node service configuration, not in the node schema. They are platform addresses that the operator who deploys your node service fills in; your code never sees them.

Key Default Effect
scene_builder_endpoint "" Address of the scene backend. Always connected on Initialize (TLS). Leave empty only if no node in the service reads scene data; calls then fail with NodeStateError.
project_service_v2_endpoint "" Address of project-v2. When set, scene calls go there and scene_builder_endpoint is not used. See Scene from project-v2.
project_service_v2_use_tls True Use a TLS channel for project-v2. Set to False for an in-cluster address without TLS.
node_engine_endpoint "" Address of the engine that hosts the key/value store. When empty the key/value client is never connected and every *_data call raises AttributeError.
node_engine_use_tls True Use a TLS channel for the key/value client. Set to False only for an engine reachable over plain TCP on a trusted network.

The full key list is in the service_config.yaml reference; how the file reaches your container is on the Deployment page.

Key/value store

The store is a per-engine repository of JSON documents. Each record is addressed by a namespace string and a key string. Use it for state that must survive a stop and re-configure of the node, or that a second node on the same engine should read: a run counter, the last accepted calibration, a small lookup table.

Methods

Call Does On success
self.create_data(key, value, namespace) Inserts a new record. The engine rejects a key that already exists in that namespace. None
self.read_data(key, namespace) Returns the stored value. The value as Python data (dict, list, str, float, bool or None)
self.update_data(key, value, namespace) Replaces the value of an existing record. The engine rejects an unknown key. None
self.delete_data(key, namespace) Removes the record. The engine rejects an unknown key. None

Notice the argument order: key first, namespace last, value in between for the writers. Pass them as keyword arguments to avoid swapping key and namespace.

Values

A value can be anything that serialises to JSON: None, bool, int, float, str, a list of those or a dict with string keys. The value travels as a protobuf Value, which has a single number type. Every number therefore comes back as a float: store 3, read 3.0. Convert with int() when you need an integer.

Every call has a 10 second deadline. A slow or unreachable engine raises after that, it does not block your node forever.

Errors

The client logs and re-raises grpc.RpcError. Typical causes are an unknown key on read, update or delete, a duplicate key on create, and network trouble. A missing node_engine_endpoint shows up differently: the client is never connected, so the call raises AttributeError instead. No authentication token is attached: the engine's data RPCs are open on the trusted edge network, so a permission error means you are talking to the wrong endpoint.

The data repository is something your node talks to, so inside on_execute() catch the error and raise a NodeDependencyError (see Errors). The Error trigger fires, the node goes to ERROR, and the caller gets a status that says the dependency failed rather than a bare INTERNAL:

import grpc

from neuraverse_sdk.models.errors import NodeDependencyError

try:
    runs = self.read_data(key="runs", namespace=self._ns)
except grpc.RpcError as e:
    raise NodeDependencyError.failure(f"Cannot read run counter: {e.code().name}") from e

A first read of a key that may not exist yet is a normal case, not a failure. Create the record on the NOT_FOUND branch and continue:

try:
    runs = int(self.read_data(key="runs", namespace=self._ns))
except grpc.RpcError as e:
    if e.code() is not grpc.StatusCode.NOT_FOUND:
        raise NodeDependencyError.failure(f"Cannot read run counter: {e}") from e
    runs = 0
    self.create_data(key="runs", value=runs, namespace=self._ns)
self.update_data(key="runs", value=runs + 1, namespace=self._ns)

Choosing a namespace

The namespace is the only isolation between nodes that share an engine, so choose it deliberately.

Do Why
Use your node class name, optionally followed by self.project_id, e.g. f"CounterNode/{self.project_id}" Stable across stop and re-configure, unique per project, readable in the store
Let the user add a suffix through a configuration entry when two instances of the same node must not share records Only the graph author knows whether two instances are "the same" device
Build the namespace once in on_configure() and keep it on self self.project_id is set before on_configure() and does not change afterwards

Do not use self.get_node_id() as a namespace. The engine mints a fresh wire id for the node on every configure cycle, so records written under it become unreachable after the next Configure, and the id is an empty string in the Mock Runner.

Scene data

The scene backend holds what a user authored in the scene editor of a project: the frames (named poses), the robots, and paths made of ordered frames and motion segments. Nodes that move a robot to a taught pose or execute an authored path read this data instead of hard-coding coordinates.

The project id

Every scene call is scoped to self.project_id. The engine passes the project id with its Initialize command and the SDK stores it through set_project_id(), so it is already set when on_configure() runs. You normally never call set_project_id() yourself. The attribute is an empty string in the constructor, in the Mock Runner, and when a node is configured without a preceding Initialize.

Methods

Call Returns Filter
self.get_frames(metadata_filter=None) Frames whose origin is a path, a sensor or a model. Robot frames are excluded. metadata_filter is a dict; only frames whose metadata contains every given key with an equal value are kept. The filtering runs in the node after the server answered.
self.get_robots() Frames whose origin is a robot. None
self.get_paths(target_robot_ids=None) Authored paths of the project. A list of robot ids; when given, only paths whose target_robot_id is one of them are returned by the server.

All three raise NodeStateError when the call fails, with the original exception attached as the cause; an unset scene_builder_endpoint ends there too. Scene builder calls have no client-side deadline (project-v2 calls have 10 seconds), so keep them out of tight loops.

What you get back

Results are plain dictionaries produced from the protobuf messages with snake_case keys. Scalar, list and map fields that were never set are still present with their empty value ("", [], {}, 0.0), so frame["metadata"] is always a dict. Nested messages such as initial_pose are omitted when unset.

A frame:

Key Type Meaning
id str Stable identifier, use it to refer to the frame in stored data
display_name str Name shown in the editor
initial_pose dict Static pose in world space (position and orientation); absent when not set
metadata dict[str, str] Free key/value pairs the author attached
source str Origin as an enum name: FRAME_SOURCE_PATH, FRAME_SOURCE_ROBOT, FRAME_SOURCE_SENSOR or FRAME_SOURCE_MODEL. On project-v2 the prefix is SCENE_FRAME_SOURCE_ and SCENE_FRAME_SOURCE_SCENE is added.

A path:

Key Type Meaning
id, display_name str As for frames
frames list[dict] Ordered frames, same shape as above
segments list[dict] One entry per gap between consecutive frames: id, motion_type (enum name), speed, acceleration, jerk, blend, via_frame_id, tool_frame_id
target_robot_id str Id of the robot that should execute the path
tcp_tip_link str Optional kinematic-chain tip link used as TCP
tcp_flange_name str Optional tool flange used as TCP; overrides tcp_tip_link when set

Example

Resolve a frame chosen by name in the configuration once, in on_configure(), and fail early when it does not exist:

def on_configure(self, config, dynamic_config=None) -> None:
    target = get_config_value("target_frame", config, dynamic_config) or ""
    frames = self.get_frames(metadata_filter={"type": "tcp"})
    matches = [f for f in frames if f["display_name"] == target]
    if not matches:
        raise NodeDataError.invalid(f"No tcp frame named {target!r} in this project")
    self._target_frame = matches[0]
    self.log_info(f"Resolved frame {target!r} to id {self._target_frame['id']}")

get_config_value comes from neuraverse_sdk.utils.config and NodeDataError from neuraverse_sdk.models.errors; see Configuration for the two configuration channels the helper reads and Errors for picking the error.

Scene from project-v2

Since SDK 2.51.0

Python and C++. C++ nodes set the two keys on NodeServiceConfig; see C++ SDK.

With project_service_v2_endpoint set, get_frames(), get_robots() and get_paths() read the project's scene from project-v2 instead of the scene builder. The methods, arguments and NodeStateError behaviour are the same. Your node code needs no change to switch, but the data differs.

Setting Dev cloud In cluster
project_service_v2_endpoint grpc-api.dev.neuraverse.com:443 nv-project-service-v2.neura-app.svc.cluster.local:50051
project_service_v2_use_tls true false

Project-v2 requires authorization. The SDK reuses the token the engine sends with its Initialize, Configure and GetNodeConfiguration commands, so frames fetched in on_get_configuration() already work on the first Initialize. A later command without a token keeps the previous one. You add no secret to the node.

The engine is the only caller that drives the node lifecycle, and every scene call uses the token the engine sent last. A custom gRPC service handler is called directly with the caller's own JWT, which the SDK does not pass on. If such a handler calls get_frames(), get_robots() or get_paths():

  • The call fails with NodeStateError (UNAUTHENTICATED) until the engine has initialized the node.
  • Project-v2 authorizes the engine's identity, not the caller's, so the handler must authorize its caller before it returns scene data. The project id is set by the engine, so a caller cannot point the call at another project.

What differs in the results:

Scene builder project-v2
Project id Scene builder project id The project-v2 UUID
get_frames() Path, sensor and model frames Also SCENE frames, which no path visits
Frame source FRAME_SOURCE_* SCENE_FRAME_SOURCE_*
Segment keys jerk, via_frame_id, tool_frame_id action, action_param instead
Path keys As in the table above Also is_trajectory, disabled, closing_segment
Motion types Include MOVE_C, MOVE_P Not available
Coordinates Floats Doubles
Deadline None 10 seconds per call

Frames and paths come from the project's draft; the SDK passes no version yet.

When to call what

Place Key/value store Scene data
__init__ Never; clients are not connected Never; project_id is empty
on_configure() Read state you need for every run; create records that must exist Resolve frames, robots and paths and cache the result on self
on_execute() Read and update per-run state; wrap a failure in NodeDependencyError.failure() Re-read only when the scene may have changed between runs
on_stop_execution() Avoid; end the run, do not start network calls Avoid
on_cleanup() / on_stop() Never; the client is already closed when either hook runs Avoid; a stopping node should not wait on network calls

The key/value client is closed early in the hard-stop chain, before on_stop() and on_cleanup(), and reopened by the next Initialize. It stays open across a stop execution. A *_data call from either hook therefore fails; write the final state at the end of on_execute() instead.

Unit tests and the Mock Runner

The Mock Runner never runs the Initialize command of the SDK, so neither client is connected and self.project_id stays empty. A node that reads platform data in on_configure() fails to configure there. Guard the call behind a configuration entry (for example a simulate toggle that substitutes a fixed frame) if you want the same node to run in the mock. See Testing for what the Mock Runner exercises.

In pytest, replace the clients on the instance with mocks before configuring the node. Both live on private attributes of NodeBase:

from unittest.mock import MagicMock

node = CounterNode()
node.data_flow = FakeDataFlow()
node._data_repository_client = MagicMock()
node._data_repository_client.get_data.return_value = 4.0
node._scene_builder_client = MagicMock()
node._scene_builder_client.list_frames.return_value = [
    {"id": "f1", "display_name": "pick", "metadata": {"type": "tcp"}, "source": "FRAME_SOURCE_PATH"}
]
node.set_project_id("project-1")
node.on_configure({}, None)

The NodeBase wrappers pass (context, namespace, key[, value]) to the key/value client and (project_id, metadata_filter=..., sources=...) to the scene client, so assert on those mocks to check what your node asked for.