Python SDKPipeline API
IngestResult
Fields on IngestResult returned by every PipelineProject.ingest call, and how to use them.
Every call to PipelineProject.ingest returns an IngestResult. It tells you the id of the
node that was created or updated, whether a new node was created, and which graph edges were
resolved.
Fields
Prop
Type
Reading the result
from optixlog_gen import OptixClient, Projects, SimulationNode
opt = OptixClient()
grating = opt.project(Projects.GRATING_COUPLER_LAB)
result = grating.ingest(
data=SimulationNode(config={"mesh": "fine"}, solver="fdtd"),
origin_nodes=["node-setup-abc123"],
forward_nodes=[],
)
print(result.project_id) # "proj_grating_7f3a"
print(result.node_id) # "node-sim-xyz789"
print(result.created) # True (new) or False (updated)
for ref in result.origin_nodes:
print(ref.type, ref.id, ref.name)
# e.g. "workflow_node", "node-setup-abc123", "Coarse Setup"
for ref in result.forward_nodes:
print(ref.type, ref.id, ref.name)EntityRef shape
Each item in origin_nodes and forward_nodes is an EntityRef:
Prop
Type
Using node_id to chain ingests
The most common use of IngestResult is threading node_id into the next ingest call:
step1 = grating.ingest(
data=SimulationNode(config={"mesh": "coarse"}, solver="fdtd"),
origin_nodes=[],
forward_nodes=[],
)
step2 = grating.ingest(
data=SimulationNode(config={"mesh": "fine"}, solver="fdtd"),
origin_nodes=[step1.node_id],
forward_nodes=[],
)
step3 = grating.ingest(
data=SimulationNode(config={"mesh": "ultra"}, solver="fdtd"),
origin_nodes=[step2.node_id],
forward_nodes=[],
)Checking whether a node is new
Use result.created to distinguish a first-time ingest from an update:
result = grating.ingest(
data=SimulationNode(config={}, solver="fdtd"),
prompt="Quick test run.",
)
if result.created:
print(f"Created new node: {result.node_id}")
else:
print(f"Updated existing node: {result.node_id}")For more on building graphs with multiple ingests, see Building the Graph.