Resolve registry asset/effect references when running recipes
SOURCE nodes with config.asset now get content_hash from registry. EFFECT nodes with config.effect now get effect_hash from registry. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -273,17 +273,36 @@ async def run_recipe(
|
|||||||
dag_copy = json.loads(json.dumps(recipe_dag)) # Deep copy
|
dag_copy = json.loads(json.dumps(recipe_dag)) # Deep copy
|
||||||
nodes = dag_copy.get("nodes", {})
|
nodes = dag_copy.get("nodes", {})
|
||||||
|
|
||||||
|
# Get registry for resolving asset/effect references
|
||||||
|
registry = recipe.get("registry", {})
|
||||||
|
assets = registry.get("assets", {})
|
||||||
|
effects = registry.get("effects", {})
|
||||||
|
|
||||||
# Convert nodes from list to dict if needed, and transform to artdag format
|
# Convert nodes from list to dict if needed, and transform to artdag format
|
||||||
if isinstance(nodes, list):
|
if isinstance(nodes, list):
|
||||||
nodes_dict = {}
|
nodes_dict = {}
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
node_id = node.get("id")
|
node_id = node.get("id")
|
||||||
if node_id:
|
if node_id:
|
||||||
|
config = node.get("config", {})
|
||||||
|
|
||||||
|
# Resolve asset references for SOURCE nodes
|
||||||
|
if node.get("type") == "SOURCE" and "asset" in config:
|
||||||
|
asset_name = config["asset"]
|
||||||
|
if asset_name in assets:
|
||||||
|
config["content_hash"] = assets[asset_name].get("hash")
|
||||||
|
|
||||||
|
# Resolve effect references for EFFECT nodes
|
||||||
|
if node.get("type") == "EFFECT" and "effect" in config:
|
||||||
|
effect_name = config["effect"]
|
||||||
|
if effect_name in effects:
|
||||||
|
config["effect_hash"] = effects[effect_name].get("hash")
|
||||||
|
|
||||||
# Transform to artdag format: type->node_type, id->node_id
|
# Transform to artdag format: type->node_type, id->node_id
|
||||||
transformed = {
|
transformed = {
|
||||||
"node_id": node_id,
|
"node_id": node_id,
|
||||||
"node_type": node.get("type", "EFFECT"),
|
"node_type": node.get("type", "EFFECT"),
|
||||||
"config": node.get("config", {}),
|
"config": config,
|
||||||
"inputs": node.get("inputs", []),
|
"inputs": node.get("inputs", []),
|
||||||
"name": node.get("name"),
|
"name": node.get("name"),
|
||||||
}
|
}
|
||||||
@@ -291,7 +310,7 @@ async def run_recipe(
|
|||||||
nodes = nodes_dict
|
nodes = nodes_dict
|
||||||
dag_copy["nodes"] = nodes
|
dag_copy["nodes"] = nodes
|
||||||
|
|
||||||
# Map input names to content hashes
|
# Map user-provided input names to content hashes (for variable inputs)
|
||||||
for input_name, content_hash in req.inputs.items():
|
for input_name, content_hash in req.inputs.items():
|
||||||
if input_name in nodes:
|
if input_name in nodes:
|
||||||
node = nodes[input_name]
|
node = nodes[input_name]
|
||||||
|
|||||||
Reference in New Issue
Block a user