Scene recipes
A scene recipe is a versioned JSON document that declares what a DAZ Studio
scene should contain: assets, actors and their placement and poses, lighting,
cameras, shots and render settings. dazpy.recipe offers six operations
over it:
|
check a recipe offline; with a scene, also check its files exist |
|
dry run: the steps, conflicts and warnings an apply would produce |
|
make the scene match the recipe, incrementally and safely |
|
how the scene differs from the recipe now (reads only) |
|
pre-render checks: figures in frame, something lights the render |
|
render the recipe’s shots from an applied scene |
Recipes are meant to be edited again and again: apply, render, look, change the recipe, re-apply. Re-apply only changes what changed, and never silently overwrites something you moved by hand in the viewport.
Note
Scene recipes are unrelated to dazpy.InteractionRecipe (multi-figure
posing). Everything here is sync only: there are no dazpy.aio variants.
Async callers, such as the MCP server, run these functions in a worker thread.
Units are DAZ native: centimetres, Y-up, degrees.
Quick start
import json
from dazpy import DazScene
from dazpy.recipe import validate, plan, apply, observe, render
recipe = json.load(open("docs/examples/recipes/g9-portrait.json"))
scene = DazScene()
report = validate(recipe, scene) # offline checks + files exist in Studio
assert report.ok, report.errors
print(plan(recipe, scene).steps) # dry run
result = apply(recipe, scene) # build the scene
shots = render(recipe, scene) # one PNG per shot
Every function also accepts a dazpy._recipe_model.SceneRecipe
(SceneRecipe.from_dict / from_json / to_dict). Offline-invalid
recipes make plan, apply, observe and render raise
dazpy.exceptions.RecipeValidationError before the scene is touched.
Schema reference
The JSON Schema is schemas/scene-recipe.v1.schema.json at the repository
root (a byte-identical copy ships inside the package; get it with
dazpy.recipe.recipe_schema()). Unknown fields are errors, entity keys match
^[A-Za-z0-9_-]{1,64}$, and recipe_version must be 1 (2 for the
v2 schema, schemas/scene-recipe.v2.schema.json, which adds the fields in
Recipe version 2: asset references, compatibility and fitting). Actors and props
share one key namespace: a prop key that is also an actor key is a
duplicate_key error (the schema cannot express this; validate checks it).
Field |
Meaning |
|---|---|
|
Required. |
|
A content-library path (leading |
|
|
|
|
|
|
|
|
|
HDRI: |
|
Either framing ( |
|
|
|
|
References (asset, facing, target, frame, camera,
look_at) must resolve to keys in the same recipe. Keys reserved for later
versions (shots[].movement, actors[].blocking / interaction,
assets[].ref, checks) are rejected with unsupported_in_version.
Validation errors are model-actionable: each has a dotted path (for example
cameras.close_up.shot_type), a stable code (unknown_reference,
invalid_enum, file_not_found, unsupported_in_version, …), a
message and, where useful, allowed values or a suggestion for a typo.
The iterative loop
Draft a recipe and
validate(recipe, scene).plan(recipe, scene)to preview.planreads the scene and changes nothing; on an empty scene it lists a full build, on an applied scene only the difference.apply(recipe, scene). It re-plans against the scene right then, so what runs is exactly whatplanshowed for that state.render(recipe, scene)and look at the images.Edit the recipe (move a camera, swap a pose, brighten the key) and go to 2.
render refuses with dazpy.exceptions.RecipeNotAppliedError (its
report is the ObserveReport) if the recipe was never
applied, has conflicts or unapplied changes, or a rendered shot’s camera was
changed or deleted in the scene. Pass force=True to render anyway. Each shot
renders through the recipe’s own camera node (found by its ownership record, so
renaming it in Studio is fine; normally labelled "<id>:<camera key>") with
the shot’s render over the top-level render; unset values use the
scene’s defaults.
Pre-render checks
check(recipe, scene, shots=None) (and dazpy.DazScene.check() for any
scene, recipe or not) runs one Studio script and returns a
dazpy.CheckReport: ok (no errors) and findings, each a
dazpy.CheckFinding with severity (error / warning),
code, subject, message, camera, shot and, for crops,
sides.
Code |
Severity |
Meaning |
|---|---|---|
|
warning |
Part of a figure’s bounding box is outside the shot’s
frame. |
|
warning |
A figure is entirely outside the frame. Skipped with
|
|
error |
The scene has figures and the camera sees none of them. |
|
error |
The shot’s camera is not in the scene (apply first). |
|
error |
Nothing lights the render: no light is on, visible and
above zero intensity, the environment is Scene Only or at
intensity 0, and the camera headlamp is off. Not checked
for the |
Figures are the visible top-level figures (clothing and hair fitted to a figure
are skipped). Framing uses each shot’s camera and resolution (the render
settings’ aspect when the recipe sets none). The test is the figure’s world
bounding box, which is loose: an outstretched arm can leave an empty box corner
outside the frame, so treat subject_out_of_frame as a prompt to look.
Emissive surfaces are not seen by no_light.
To enforce the checks, pass require_clean=True:
apply(..., require_clean=True)checks every shot on the applied scene before the manifest is written. Errors roll the apply back like any other failure (applied=False,rolled_back=True);ApplyResult.checkhas the report either way.render(..., require_clean=True)checks the shots it would render and raisesdazpy.exceptions.SceneCheckError(reportattribute) on errors, before rendering anything. It is independent offorce.
Warnings never block.
observe reports applied (the recipe has a manifest in the scene),
in_sync, drift (hand edits kept, hand deletions), pending (what an
apply would change if the recipe won every conflict) and conflicts.
What apply touches
Apply only touches nodes it created. Ownership and the last-applied state live in a record stored on each owned node, plus one manifest per recipe in the scene, so they survive save and reload. Nodes without a record are invisible to the recipe, and one scene can host several recipes with different ids.
Changes are tracked per channel of an entity. Conflict, resolution and
warning paths are <entity path>.<channel>:
Entity path |
Channels |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
For example cameras.cu.transform or lighting.rigs.main.key.transform.
Derived values (framing cameras, rigs, facing) are computed from the
recipe’s actor positions, never the live ones, and compared as computed node
values. Moving an actor in the recipe moves the cameras and lights that
reference it. Dragging her in the viewport is a hand tweak on that actor only.
A different asset or light type for an existing entity is a replace: the old
node goes through the same checks as a removal, then a new node is created. If
that check keeps the old node (scene), it stays in the scene but is
released: the recipe no longer owns it.
Conflict model
For every channel apply compares desired (the recipe now), base (what the last apply recorded) and live (the scene now):
Recipe vs base |
Live vs base |
Outcome |
|---|---|---|
same |
same |
no-op |
changed |
same |
apply the change |
same |
changed |
hand tweak: keep the live value, warning |
changed |
changed |
conflict (no-op if live already equals desired) |
entity removed from recipe |
untouched |
delete the node |
entity removed from recipe |
hand-tweaked |
conflict |
new entity |
n/a |
create |
recorded entity, node deleted by hand |
n/a |
conflict |
A node to be deleted that has children the recipe does not own (clothing or
props you parented to it) is a has_foreign_children conflict. Bones and the
parts the asset loaded with (a Genesis 9 figure’s eyes, mouth, tear, lashes and
eyebrow cards) never count; an item parented to one of them does. If the recipe
wins, those children are unparented to the scene root (keeping their world
transform) and then the node is deleted. Apply never deletes a node it did not
create. A node is deleted the way Studio’s Delete does it, together with
everything under it, so a node of this recipe that you parented under a deleted
one goes too (it is recreated on the next apply if the recipe still lists it).
Keeping a removed node (scene on removed_from_recipe or
has_foreign_children) releases it: apply removes its ownership record
and drops it from the manifest, so the node stays in the scene as an ordinary,
unowned node and later applies no longer report it. It also loses the
"<id>:" prefix of its label ("<id>:ball" becomes "ball") unless you
renamed it, so a node the recipe creates for that entity later is the only one
with the recipe label (shot rendering finds cameras by it). To bring it back
under the recipe, delete it and add the entity again.
Poses are compared by a full pose capture, so a hand-posed figure is a hand tweak, and a pose swap on top of it is a conflict.
If two nodes carry the same recipe record (duplicating a recipe node in Daz
Studio copies its record), the entity is a duplicate_record conflict and
warning naming both nodes and their element ids. Apply never modifies, deletes
or releases either node, whatever the policy: ask blocks, and
recipe_wins / scene_wins / resolutions cannot resolve it (the rest
of the apply proceeds under those policies). Delete the extra node to resolve
it.
Numeric comparisons use a tolerance of 0.05.
Choosing a policy
result = apply(recipe, scene) # on_conflict="ask"
if not result.applied and result.conflicts: # nothing was written
for c in result.conflicts:
print(c.path, c.kind, c.desired, c.base, c.live)
apply(recipe, scene, on_conflict="recipe_wins") # overwrite hand edits
apply(recipe, scene, on_conflict="scene_wins") # keep hand edits
apply(recipe, scene, resolutions={ # per conflict
"lighting.rigs.main.key.transform": "recipe",
"actors.model.pose": "scene",
})
ask(default): any conflict means nothing changes and every conflict is returned (appliedisFalse).recipe_wins/scene_winsresolve every conflict that way and reportoverwrittenandkeptpaths.resolutionsmaps a conflict path to"recipe"or"scene"and wins overon_conflictfor the paths it names; underaskan unnamed conflict still blocks the apply. A key matching no conflict yields anunknown_resolutionwarning.
Keeping a hand tweak with scene adopts the live value as the new base, so it
stops warning. A plain hand tweak keeps warning until then.
Tombstones and warnings
Accepting a hand deletion (resolution scene on deleted_in_scene) records
a tombstone in the manifest, so later applies do not recreate the node and
instead warn hand_deleted_kept. Resolve that path with recipe to bring
it back. Other warning codes: hand_tweak_kept, duplicate_record, removed_entity_kept (an
entity removed or replaced in the recipe whose node was kept and released),
unknown_resolution and
deleted_not_restored (see below).
Selection and a busy Studio
Apply clears the scene selection while it loads assets and deletes nodes: loading a figure while another figure is selected makes Studio ask whether to replace it, and deleting goes through Studio’s Delete on an exact selection. The selection is not restored afterwards.
Studio 6 reports itself busy for a moment after a load or a clear while it
streams in background content. Every dazpy.recipe function waits that out,
up to 120 seconds per call, through
DazClient.waiting_out_busy(); use the
same context manager around your own calls between recipe steps.
Rollback guarantees
Conflict detection runs completely before any change. If execution then fails
midway (a Studio error, a file that passed validation but cannot load, Studio
busy past its retries), apply rolls back by compensation. dazpy’s UndoGroup
cannot do this: it only drops the undo grouping.
Work is journaled. On failure the journal is walked in reverse: created nodes (including everything a load added) are deleted, modified channels are written back to their prior values (a write that fails halfway is restored too), the environment and records are restored (including records removed by a release), unparented children are reparented.
Deletions and unparenting run last, after everything that can still fail, because a deleted node cannot be brought back. A failure in that phase leaves the deletes already done in place;
result.stepslists them and each carries adeleted_not_restoredwarning.The manifest is written last.
The result then has
applied=False,rolled_back=True,failed_stepanderror. A compensation that itself fails is never raised; it is listed inrollback_errors, and is the only way the scene can end up different from before the apply.One known case cannot be restored. If an apply sets an HDRI environment map on a scene that had none and later fails, the map cannot be cleared again: dazpy never calls the map setters with an empty path, since a bad map path can raise a modal dialog and hang Studio. The rollback reports
environment map could not be restored: the scene had no map beforeinrollback_errors.
Recipe version 2: asset references, compatibility and fitting
recipe_version: 2 (schema schemas/scene-recipe.v2.schema.json,
recipe_schema(2)) adds four things to v1:
name content by path, product, SKU or search phrase (asset references);
check every preset and fitted item against its figure before the scene changes;
build actors in layers (base figure, then presets, then fitted items) and take over actors built by hand;
add, replace and remove hair, clothing and accessories fitted to an actor, by Scene-pane label or by content type.
Every loaded node also records where it came from. Each validation, compatibility or wearing error raises before apply changes anything: an ambiguous, missing or incompatible reference leaves the scene exactly as it was, and no modal dialog can appear.
Asset references
Anywhere a recipe takes an asset (assets.<k>, actors.<k>.asset,
props.<k>.asset, presets[] and wearing entries), v2 accepts an
asset reference (shared schema schemas/asset-ref.v1.schema.json, also
emitted by daz-content-browser-mcp). A plain string is a path, so every v1 asset
value is still valid. The object form has these fields:
Field |
Meaning |
|---|---|
|
Content-relative ( |
|
Product name (exact, case-insensitive) |
|
Product SKU |
|
Free-text search phrase |
|
Picks one file of a |
|
Expected content type (friendly name or raw Daz type, see below). It narrows a search and filters a product’s files |
|
A pin: |
At least one of path, product, sku and find is required, even
with a pin, so a reference always says what was meant. When several are given,
path wins over sku (plus file), then product (plus file), then find.
A product with several matching files and no file is ambiguous.
A resolved pin is used as is while its file still exists on the Studio
host (finder pin). If the file is gone, the reference resolves again from its
other fields (warning pin_file_missing). A pin whose SKU or product differs
from the reference’s warns pin_mismatch. dazpy.recipe.pin(recipe, scene)
returns the recipe as a dict with every reference’s resolved filled in, so
you can freeze a recipe against library changes. dazpy never rewrites a recipe on
its own.
Stability: once a reference resolves, the file is stored in the node’s record. Later applies reuse it while the reference is unchanged (no new search), so installing a new product never silently swaps content. A changed reference resolves again.
Finders
find, product and sku are answered by a finder (path
references never use one):
dazpy.StudioFinder, the default: Studio’s own content database (needs the CMS). Studio searches asynchronously; dazpy waits until the result stops growing, at most 5 seconds. When that bound is hit, the partial result is still used and the reference getssearch_incomplete. A search with no hit takes about 3 seconds to come back empty. Studio returns at most 1200 results.dazpy.ContentBrowserFinder: the daz-content-browser REST API, fromDAZ_BROWSER_URL(andDAZ_BROWSER_TOKEN) or constructed explicitly.
Pass finder= to validate / plan / apply / observe /
pin to choose. Otherwise dazpy uses the content browser when
DAZ_BROWSER_URL is set and reachable, and Studio’s database when it is not
(warning finder_fallback). RecipePlan.finder names the finder that
answered.
Choosing a match. A find’s candidates are first filtered by type,
then by the target figure: a candidate whose compatibility metadata says it is
made for another figure is dropped (one with no metadata stays). The figure is
the actor’s live figure, or the figure file of an actor the recipe will create.
A result is then accepted only when it is a clear single winner: one candidate
whose product name equals the phrase (case-insensitive), or exactly one
candidate left. Several left is ambiguous_asset: for a find the
error’s allowed lists up to ten as "<product> (<sku>): <path>"; for a
product / sku with several matching files it lists the file paths.
When every candidate was dropped as incompatible the error is
incompatible_asset, naming the best of them, not asset_not_found. Studio’s text search matches broadly. On a
typical library a phrase such as "Flirty Casual Ponytail" with type:
"hair" returns several ponytail hairs, not just that one. Expect a ``find``
to come back ambiguous: pick one of the listed candidates and pin it, either
with pin() or by writing its path into resolved (or using it as path).
Content types
type in a reference or a selector is a friendly name or a raw Daz type
string, which matches as a prefix (Follower/Wardrobe/Gloves):
Friendly name |
Daz type prefixes |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A wearables (outfit) preset file has the type Preset/Wearables. When
filtering files, it matches only wardrobe (or raw Follower/Wardrobe),
never a narrow name such as hat. Scene nodes are matched by their own type,
so {"type": "hat"} finds the hat inside a hand-loaded outfit. A node with no
type never matches a type selector.
Actors in layers
An actor gains node, presets and wearing. It needs asset,
node or both.
nodeis a Scene-pane label (exact, case-sensitive). If one figure has that label, the actor takes it over. The recipe then manages only what it mentions: its presets, itswearingentries, and transform or pose only if the recipe sets them (a taken-over actor has no implicitposition). The base figure is never replaced. Changingasseton a taken-over actor is atake_over_asset_changederror, and dropping the actor from the recipe releases it (removes its record); it is never deleted. After take-over the actor is found by its record, so renaming it later is fine.With
nodebut no such figure, the actor is created fromassetand labellednode. Without anassetthat isnode_not_found. Two figures with the label areambiguous_node.presetsare applied in order to the figure (shape, materials, …) on create, on take-over and whenever the list changes. Presets cannot be undone, so dropping one leaves its effect on the figure (warningpreset_dropped).
Fitted items
wearing is an ordered list of entries:
[
{"add": {"product": "dForce Detective Outfit for Genesis 9", "type": "wardrobe"},
"key": "outfit"},
{"replace": {"type": "hair"}, "key": "hair", "with": {"sku": "93669"}},
{"replace": "Old Jacket", "key": "jacket", "with": {"product": "Leather Jacket"},
"if_missing": "add"},
{"remove": {"type": "hat"}, "if_missing": "ignore"}
]
add(with akey) is an owned item: like any recipe entity it is created once, compared on every apply and removed when the entry goes. Changing its reference swaps it. The key is unique within the actor.replace(selector,with,key) andremove(selector) act on content the recipe does not own. A selector is a label string or{"type": T}(every matching item fitted to this actor). On the first apply the selector must match at least one item, elsereplace_target_missing/remove_target_missing."if_missing": "add"turns a replace into a plain add, and"if_missing": "ignore"skips a remove. The selector part is one-shot: it runs once, is logged on the actor’s record and is inert after that. Thewithitem is owned underkeylike anadd. Aremoveis logged by its selector (remove.type=hat,remove.label=Old Jacket), so reordering thewearinglist never re-arms it.Only items following this actor’s figure are candidates; never the figure, never another actor’s items, never items this recipe owns. Removing them is not a conflict under
ask(the recipe asked for it), except for an item carrying another node you parented to it, with or without a record (has_foreign_children; only the item’s own bones, fitted sub-parts and outfit helper nodes do not count). Entries are planned in list order, each seeing the scene as the earlier ones leave it.Figures and items the recipe did not create are addressed by Studio’s element ID, not their internal name (a file loaded twice repeats every name), so a plan’s
take_over/unfitsteps name them aselementID:<id>. Each removed item must still follow the actor’s figure when the removal runs.Multi-node items. A hair with a separate cap, or an outfit preset that loads six garments, is one entry: every node the load added belongs to it (records share
group="<actor>.<key>") and is fitted, swapped and removed together. A load that adds anything not fitted to the actor (a light, a stray figure) is removed again and fails.Fitting loads the file with a temporary empty null node selected as the only (primary) selection: some items name the selection in their file, and with nothing selected Studio can pop its modal “Choose Content to Replace” dialog. Each new figure is then made to follow the actor and parented to her, and the null is deleted. Items for another figure are never auto-fitted.
Apply order is: creates, presets, fits, channels, then removals last. A
failure before the removals rolls everything back, so a hand-loaded hair being
replaced is simply still there. The exception is presets: a preset applied to
a figure the recipe did not create in this apply (an existing or taken-over
actor) cannot be undone, and the rollback reports it in rollback_errors. A failure during the removals reloads the
items already removed from their recorded source file and fits them again
(their hand edits are lost). Hand-loaded content has no record, so it cannot
be reloaded. The dry run warns unrestorable_removal for it, and rollback skips it;
after a rollback, every removed item that was not brought back (no source, or
the reload failed) is reported again as unrestorable_removal, and its
unfit step stays in ApplyResult.steps.
Plan steps for v2: take_over, preset, fit and unfit (the
one-shot removal), next to v1’s create / modify / delete / release.
Compatibility
Before any scene change, every preset and fitted item is checked against its
actor’s figure, from asset metadata only (nothing is loaded to find out). The
actor’s base comes from the live figure for a taken-over or existing actor
(getCompatibilityBasePathForNode), and from the figure file’s CMS record
(compatibilityBase) for one the recipe will create. The item’s bases come
from its CMS record. An item is compatible when the actor’s base equals one of
them or lies below it (/Genesis 9/Base is below /Genesis 9). Otherwise it is
incompatible_asset. No metadata (for example your own shape file outside the
CMS) gives the warning compatibility_unknown, so project files keep working.
Provenance
Every node a v2 recipe loads carries source in its record:
{"requested": {"sku": "93714", "file": "Kara Ponytail.duf"},
"path": "X:/Daz Libraries/People/Genesis 9/Hair/Daz Originals/Kara Ponytail/Kara Ponytail.duf",
"sku": "93714", "product": "dForce Kara Ponytail for Genesis 9",
"type": "Follower/Hair", "finder": "studio",
"fitted_to": "abby", "group": "actors.abby.wearing.hair", "primary": true}
finder is path, pin, studio or content_browser. Fitted
nodes also record asset_uri, the node’s data (.dsf) file at fit time.
observe reports an owned item whose live data file differs from it as
source_changed drift (swapped by hand). A taken-over actor’s record has
adopted_from_scene: true. One-shot removals are logged on the actor’s record
with each removed item’s label, type and source file.
Codes
Errors (plan / apply raise RecipeValidationError
before any change). validate with a scene reports the reference and
compatibility errors; ambiguous_node, node_not_found,
take_over_asset_changed, replace_target_missing and
remove_target_missing need the scene’s figures and fitted items, so only
plan / apply report them:
Code |
Meaning |
|---|---|
|
A reference names none of |
|
The path does not exist on the Studio host, the search found nothing, or the product has no matching file. |
|
Several files match. |
|
A |
|
A preset or fitted item is made for another figure; the message
names its bases and the actor’s base. Also when every |
|
Several figures carry the actor’s |
|
No figure has the |
|
The |
|
A |
|
A |
Warnings (never block):
Code |
Meaning |
|---|---|
|
No metadata to check an item against the figure (or the actor’s base is unknown, or a preset’s file has no content type); it is loaded unchecked. |
|
A |
|
The pinned file is gone; the reference was resolved again. |
|
|
|
Studio’s search hit its time bound (5 s); the match was chosen from a possibly partial result. |
|
No figure has the |
|
An item a |
|
A preset was removed from the list; its effect stays on the figure. |
Plus the drift code source_changed from observe (see Provenance).
Worked example: Abby
Load a Genesis 9 figure and name it “Abby”, apply her shape, give her a ponytail:
{
"recipe_version": 2,
"id": "vn-a",
"actors": {
"abby": {
"node": "Abby",
"asset": {"path": "/People/Genesis 9/Genesis 9.duf"},
"presets": ["X:/Development/VisualNovelA/shapes/AbbyYoungShape.duf"],
"wearing": [
{"add": {"find": "Flirty Casual Ponytail", "type": "hair"}, "key": "hair"}
],
"position": [0, 0, 0]
}
}
}
from dazpy import DazScene
from dazpy.exceptions import RecipeValidationError
from dazpy.recipe import apply, pin, plan, validate
scene = DazScene()
report = validate(recipe, scene)
for e in report.errors: # typically: ambiguous_asset on actors.abby.wearing.hair
print(e.path, e.code, e.allowed)
The shape file is the user’s own (not in the CMS), so it warns
compatibility_unknown and is still applied. The find usually lists
several ponytails. Pick the one you mean and pin it:
{"add": {"find": "Flirty Casual Ponytail", "type": "hair",
"resolved": {"path": "/People/Genesis 9/Hair/Out Of Touch/OOT Flirty Casual Ponytail Hair/Flirty Casual Ponytail Hair.duf"}},
"key": "hair"}
Now apply(recipe, scene) creates the figure labelled Abby, applies the
shape, and loads and fits the hair. Re-applying changes nothing.
Later: change her hair, on a scene where Abby was built by hand. A recipe that only names her takes her over and swaps whatever hair she has:
{
"recipe_version": 2,
"id": "vn-a-hair",
"actors": {
"abby": {
"node": "Abby",
"wearing": [
{"replace": {"type": "hair"}, "key": "hair",
"with": {"find": "Bunched Hair Updo", "type": "hair"}}
]
}
}
}
plan shows take_over, fit and unfit steps and warns
unrestorable_removal for her hand-loaded hair. apply fits the new hair,
then removes the old one. Her shape, pose, position and everything else she
wears are left alone. On the next apply the replace is inert; to change the
hair again, edit with. Had the new hair been made for Genesis 8, the plan
would have stopped with incompatible_asset and nothing would have loaded.
v1 to v2
v1 recipes keep working unchanged, with exactly the v1 behaviour: no finder, no compatibility read.
To use any v2 field, set
"recipe_version": 2. String asset values still mean a path andassetskeys still work. Under v2 an inline asset path is resolved (and existence-checked) like any reference, reported at the reference’s own path (actors.<k>.asset) rather than asfile_not_found.pin()on a v1 recipe returns a v2 recipe.The v1 validator rejects v2 fields (
unknown_field), so a recipe that uses them must say2.
Example walkthrough
docs/examples/recipes/g9-portrait.json uses the Genesis 9 base figure, one
of Daz’s stock Genesis 9 base poses (G9 Base Pose 12 Standing), a three-point
rig, a full-body and a close-up camera, two shots and Iray at 640x480 with 50
samples. It has no environment block, so it needs no third-party HDRI.
{
"recipe_version": 1,
"id": "g9-portrait",
"assets": {
"g9": { "path": "/People/Genesis 9/Genesis 9.duf" }
},
"actors": {
"model": {
"asset": "g9",
"position": [0, 0, 0],
"pose": "/People/Genesis 9/Poses/Daz Originals/Base Poses/Base/G9 Base Pose 12 Standing G9B.duf"
}
},
"lighting": {
"rigs": {
"main": { "type": "three_point", "target": "model", "light_type": "spot" }
}
},
"cameras": {
"full_body": { "frame": "model", "shot_type": "full_body", "focal_length": 50 },
"close_up": { "frame": "model", "shot_type": "close_up", "azimuth_deg": 20, "focal_length": 85 }
},
"shots": [
{ "id": "full_body", "camera": "full_body", "output": "C:/temp/recipe_example/full_body.png" },
{ "id": "close_up", "camera": "close_up", "output": "C:/temp/recipe_example/close_up.png" }
],
"render": { "engine": "iray", "resolution": [640, 480], "iray_samples": 50 }
}
File checks run on the Studio host (one script for the whole recipe), so paths
are always as Studio sees them. The one exception is a dazpy pose .json
file: dazpy reads it on the client, so validate checks it there.
A session against a running Studio:
recipe = json.load(open("docs/examples/recipes/g9-portrait.json"))
scene = DazScene()
apply(recipe, scene) # figure, pose, 3 lights, 2 cameras
render(recipe, scene) # C:/temp/recipe_example/*.png
# Move the close-up around the figure. Only cameras.close_up changes.
recipe["cameras"]["close_up"]["azimuth_deg"] = 45
print(plan(recipe, scene).steps) # one modify on cameras.close_up
apply(recipe, scene)
# Nudge the key light by hand in the viewport, then re-apply: the tweak is
# kept and reported as a hand_tweak_kept warning.
result = apply(recipe, scene)
print([w.code for w in result.warnings])
# Change that light in the recipe too: now it is a conflict.
recipe["lighting"]["rigs"]["main"]["key"] = {"azimuth_deg": 60}
apply(recipe, scene) # applied=False
apply(recipe, scene, on_conflict="recipe_wins") # applied=True
If that pose is not installed, validate(recipe, scene) reports
file_not_found with its path; point actors.model.pose at any installed
Genesis 9 pose.
API
Scene recipes: validate, plan, apply and observe a declarative scene description.
A SceneRecipe (or its dict form, see
recipe_schema()) describes the desired scene. This module is the public
facade over the layers below it:
validate()- offline checks, plus (given a scene) that every asset, pose and HDRI file exists;plan()- what an apply would do, without touching the scene;apply()- validate, re-read the live scene, diff, execute with rollback;observe()- how the scene differs from the recipe now;check()- pre-render checks (framing, lighting) for the recipe’s shots;render()- render the recipe’s shots from an applied scene;pin()- the recipe with every asset reference’s resolution filled in.
Recipes using v2 asset features (find / product / sku references,
pins, taken-over actors, presets, wearing) go through the v2 pipeline (spec
section 8): references are resolved (re-using the resolution recorded on the
scene’s nodes while a reference is unchanged), presets and fitted items are
checked against their actor’s figure from asset metadata, and any resolution,
compatibility or wearing error raises RecipeValidationError before the
scene changes. Other recipes run exactly as in v1: no finder, no compatibility
read.
Every result type has a JSON-safe to_dict().
- class dazpy.recipe.ObserveReport(applied, in_sync, drift, pending, conflicts)[source]
Bases:
objectHow the scene stands against a recipe.
applied: the recipe has a manifest in the scene.drift: hand edits kept (hand_tweak_kept), hand deletions (deleted_in_scene) and fitted items whose node now comes from another file than the one recorded (source_changed, e.g. swapped by hand).pending: what an apply would change if the recipe won every conflict (<entity>.<channel>for modified/environment channels, the entity path for creates, releases, unparents and deletes).in_sync: applied, with no pending change, drift or conflict.- drift: tuple[RecipeIssue, ...]
- class dazpy.recipe.ShotRender(shot_id, camera_label, output, result)[source]
Bases:
objectOne rendered shot: its id, the camera label used, the output path, the render result.
- result: RenderResult
- dazpy.recipe.apply(recipe, scene, *, on_conflict='ask', resolutions=None, finder=None, require_clean=False)[source]
Apply recipe to scene, re-planning against the scene’s current state.
Raises
RecipeValidationError(before touching the scene) when the recipe is invalid offline or names a missing file, or (v2) has any resolution, compatibility or wearing error (seeplan()). A conflict underon_conflict="ask"returnsapplied=Falsewith the conflicts and writes nothing; a failure part-way rolls back (seeApplyResult).With require_clean,
check()runs on the applied scene before the manifest is written; errors roll the apply back (applied=False,rolled_back=True) andApplyResult.checkholds the report either way.
- dazpy.recipe.check(recipe, scene, *, shots=None)[source]
Pre-render checks for the recipe’s shots (all, or the ids in shots).
For each shot, from its camera (found like
render()finds it) with the shot’s resolution: are the figures in frame (subject_out_of_frame/subject_not_in_framewarnings, skipped when the shot setsallow_crop;no_subject_in_frameerror;camera_not_founderror when the camera is not in the scene, e.g. beforeapply()). Then, per the shot’s engine, will anything light the render (no_lighterror, reported once withshot=Nonewhen every shot agrees). With no shots, only lighting is checked, for the active engine. Seedazpy.DazScene.check()for the codes. RaisesValueErrorfor unknown shot ids.
- dazpy.recipe.observe(recipe, scene, *, finder=None)[source]
Compare scene with recipe without changing anything.
Diffs as if the recipe won every conflict, except that hand deletions already accepted (tombstoned in the manifest) stay accepted: they are not pending recreates. A recipe-owned fitted item whose node now comes from another file than its recorded source is
source_changeddrift. RaisesRecipeValidationErrorwhen a v2 reference cannot be resolved.
- dazpy.recipe.pin(recipe, scene, *, finder=None)[source]
recipe as a dict with every asset reference’s
resolvedpin filled in.References resolve as in
plan()(recorded resolutions first, then pins, then the finder); string references become objects. Pins are a v2 feature, so a v1 recipe comes back asrecipe_version: 2. RaisesRecipeValidationErrorwhen a reference cannot be resolved.
- dazpy.recipe.plan(recipe, scene, *, on_conflict='ask', resolutions=None, finder=None)[source]
What
apply()would do now. Reads the scene, changes nothing.Raises
RecipeValidationErrorfor an offline-invalid recipe and, for a v2 recipe, for any resolution, compatibility or wearing error (seevalidate()); does not check that pose / HDRI files exist (that isvalidate()/apply()).RecipePlan.findernames the finder that answered ("path"when no reference needed one); resolution and compatibility warnings are inRecipePlan.warnings.
- dazpy.recipe.recipe_schema(version=1)[source]
The JSON Schema for recipe documents of version (shipped as package data).
- dazpy.recipe.render(recipe, scene, *, shots=None, force=False, wait=True, timeout=300.0, require_clean=False, finder=None)[source]
Render the recipe’s shots (all, or the ids in shots) in recipe order.
Each shot renders from the recipe’s camera node, found through its ownership record and passed to Studio by its current label (
"<recipe.id>:<camera key>"unless renamed in Studio; that label too when the camera is missing and force is set), with the top-levelrendersettings overridden by the shot’s own; anything unset is passed as0/""so Studio uses the scene default. The output folders are created on the Studio host first.Unless force, raises
RecipeNotAppliedErrorwhen the recipe is not applied, has conflicts or unapplied changes, or a rendered shot’s camera was changed or deleted in the scene. RaisesValueErrorfor unknown shot ids. With require_clean (independent of force), runscheck()on the chosen shots first and raisesSceneCheckErrorif it finds errors; nothing is rendered.A
recipe_version: 2recipe’s asset references are resolved first (as inobserve(), through finder when given), so this can raiseRecipeValidationErrorwhen one cannot be resolved.
- dazpy.recipe.validate(recipe, scene=None, *, finder=None)[source]
Validate recipe; with scene, also check its files exist (one Studio script).
Adds
file_not_foundatassets.<k>.path,actors.<k>.poseandlighting.environment.image_path. The existence check is skipped while the recipe has offline errors. Files are resolved on the Studio host in one script (content paths through the content manager), except dazpy pose.jsonfiles:poses.apply_posereads those on the client, so they are checked there. RaisesDazErrorif Studio returns no result for the check.For a recipe using v2 asset features, with scene, also resolves every asset reference (through finder, else the content browser named by
DAZ_BROWSER_URLwhen reachable, else Studio’s content database) and checks presets and fitted items against their actor’s figure: resolution errors (asset_not_found,ambiguous_asset,content_database_unavailable),incompatible_asseterrors andcompatibility_unknown/finder_fallback/pin_*warnings. A created actor’s base comes from its asset’s metadata; a taken-over one’s from the live figure. Asset files are reported by the resolution (at the reference’s path, e.g.actors.<k>.asset), not asfile_not_found.
Results
- class dazpy._recipe_validate.ValidationReport(ok: 'bool', errors: 'tuple[RecipeIssue, ...]', warnings: 'tuple[RecipeIssue, ...]')[source]
Bases:
object- errors: tuple[RecipeIssue, ...]
- warnings: tuple[RecipeIssue, ...]
- class dazpy._recipe_validate.RecipeIssue(path: 'str', code: 'str', message: 'str', allowed: 'tuple[str, ...] | None' = None, suggestion: 'str | None' = None)[source]
Bases:
object
- class dazpy._recipe_diff.RecipePlan(steps: 'tuple[Step, ...]', conflicts: 'tuple[Conflict, ...]', warnings: 'tuple[RecipeIssue, ...]', blocked: 'bool', overwritten: 'tuple[str, ...]', kept: 'tuple[str, ...]', tombstones: 'tuple[str, ...]' = (), done_log: 'tuple[tuple[str, dict], ...]' = (), finder: 'str' = 'path')[source]
Bases:
object- warnings: tuple[RecipeIssue, ...]
- class dazpy._recipe_diff.Step(op: 'StepOp', path: 'str', channels: 'dict[str, dict]', prior: 'dict[str, dict] | None', node_name: 'str | None')[source]
Bases:
object- op: Literal['create', 'take_over', 'preset', 'fit', 'modify', 'set_environment', 'adopt', 'release', 'unparent', 'unfit', 'delete']
- class dazpy._recipe_diff.Conflict(path: 'str', kind: 'ConflictKind', desired: 'object', base: 'object', live: 'object')[source]
Bases:
object
- class dazpy._recipe_apply.ApplyResult(applied, steps, conflicts, warnings, overwritten, kept, rolled_back=False, failed_step=None, error=None, rollback_errors=(), check=None)[source]
Bases:
objectOutcome of
execute().stepsare the steps in effect afterwards: every plan step on success; after a rollback, only the deletes that ran (they cannot be undone) and the one-shot unfits whose removed items were not all restored, andoverwritten/keptare empty.failed_stepis None when the failure happened while writing records or the manifest (errorthen says which).check: the scene check run before the manifest is written (apply(..., require_clean=True)); when it has errors the apply rolls back.- warnings: tuple[RecipeIssue, ...]
- check: CheckReport | None = None
- class dazpy._recipe_model.SceneRecipe(recipe_version: 'int', id: 'str', assets: 'Mapping[str, AssetSpec]'=<factory>, actors: 'Mapping[str, ActorSpec]'=<factory>, props: 'Mapping[str, PropSpec]'=<factory>, rigs: 'Mapping[str, RecipeRig]'=<factory>, lights: 'Mapping[str, RecipeLight]'=<factory>, environment: 'RecipeEnvironment | None' = None, cameras: 'Mapping[str, RecipeCamera]'=<factory>, shots: 'tuple[ShotSpec, ...]'=(), render: 'RenderSpec' = <factory>)[source]
Bases:
object- render: RenderSpec
Asset references and finders
AssetRef, AssetFinder, StudioFinder and ContentBrowserFinder
are importable from dazpy. Pass a finder as finder= to validate,
plan, apply, observe, render or pin; without one, dazpy
uses daz-content-browser when DAZ_BROWSER_URL answers and Studio’s
content database otherwise (finder_fallback warning).
- class dazpy._asset_ref.AssetRef(path: 'str | None' = None, product: 'str | None' = None, sku: 'str | None' = None, find: 'str | None' = None, file: 'str | None' = None, type: 'str | None' = None, resolved: 'ResolvedPin | None' = None)[source]
Bases:
object- resolved: ResolvedPin | None = None
- class dazpy._asset_ref.ResolvedPin(path: 'str', sku: 'str | None' = None, product: 'str | None' = None, asset_id: 'str | None' = None)[source]
Bases:
object
- class dazpy._asset_finder.AssetCandidate(path: 'str', product: 'str | None', sku: 'str | None', asset_id: 'str | None', type: 'str | None', score: 'float' = 0.0)[source]
Bases:
object