Skip to content
SynthGraph

SDK guides

Record a generation

Capture one run of a generator: its parameters, seed and outcome, including when it fails.

A generation is one run of your generator: Blender, Unity, a simulator, a script. Recording it means writing down what defines the run before you know how it ends.

The examples on this page share this setup:

from synthgraph import SynthGraph

sg = SynthGraph()
experiment = sg.project("Docs: generations").experiment("example")

Record a generation#

generation = experiment.generation(
    generator="blender",
    generator_version="4.2",
    parameters={"weather": "rain", "occlusion": 0.3, "camera_distance": 12},
    seed=42,
)
print(generation.status)  # "pending"
ArgumentMeaning
generatorThe generator's name. Required.
generator_versionIts version, for example "4.2".
parametersYour configuration: any JSON object. SynthGraph does not impose a schema.
seedThe random seed, if the run has one.
nameA name for the run. If you leave it out, the generator's name is used.
code_version, environmentOverride what the SDK would otherwise capture. See Code and environment provenance.

A new generation is pending. Nothing has run yet, and nothing has been decided: the definition is on record before the outcome.

Let the with block run the lifecycle#

The usual way is a with block:

with experiment.generation(
    generator="blender",
    generator_version="4.2",
    parameters={"weather": "rain"},
    seed=7,
) as generation:
    pass  # your rendering code goes here
  • Entering the block marks the generation running.
  • Leaving it normally marks it completed.
  • If your code raises, it is marked failed and your exception is raised again, untouched. SynthGraph never swallows it.

A failed generation stays in your history. A failed experiment is still a result, and the parameters that failed are exactly what you will want to find later.

Or call the steps yourself#

If a with block does not fit, for example the work spans several processes, call the steps directly:

generation = experiment.generation(generator="blender", seed=8)
generation.start()
# ... hours of rendering ...
generation.complete()   # or generation.fail()

The order matters. A generation has to be started before it can be completed:

generation = experiment.generation(generator="blender")
generation.complete()
# SynthGraphConflictError: ... Cannot transition generation from pending to completed

Completed and failed are final. Trying to change a finished generation raises SynthGraphConflictError (HTTP 409), and nothing is changed.

Attach what it produced#

Record the data and scenes a generation produced or used, by reference, with generation.dataset(...) and generation.asset(...). You can attach them while the generation runs or after it has finished.

Find and read generations back#

# Every generation in the experiment
experiment.generations()

# Only those whose parameters match
experiment.generations(parameters={"weather": "rain"})

# Re-read one from the backend
generation.refresh()

The parameter filter runs on the backend. The SDK does not filter locally.

Two more calls read derived views of a generation:

generation.manifest()        # the reproduction manifest
generation.documentation()   # generated Markdown documentation