Support multiple input name formats for recipe run

Variable inputs can now be referenced by:
- Node ID (e.g., source_4)
- Config name (e.g., "Second Video")
- Snake case (e.g., second_video, second-video)
- Node name from def binding

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-11 23:42:52 +00:00
parent fe8e65881d
commit 0a82158622

View File

@@ -370,14 +370,43 @@ async def run_recipe(
nodes = nodes_dict
dag_copy["nodes"] = nodes
# Build lookup for variable inputs: map input names to node IDs
# Variable inputs can be referenced by: node_id, config.name, config.input (if string)
input_name_to_node = {}
for node_id, node in nodes.items():
if node.get("node_type") == "SOURCE":
config = node.get("config", {})
# Only variable inputs (those with 'input' in config, not fixed assets)
if config.get("input"):
input_name_to_node[node_id] = node_id
# Map by config.name (e.g., "Second Video")
if config.get("name"):
name = config["name"]
input_name_to_node[name] = node_id
# Also allow snake_case version
input_name_to_node[name.lower().replace(" ", "_")] = node_id
input_name_to_node[name.lower().replace(" ", "-")] = node_id
# Map by node.name if available (def binding)
if node.get("name"):
input_name_to_node[node["name"]] = node_id
input_name_to_node[node["name"].replace("-", "_")] = node_id
# Map user-provided input names to content hashes (for variable inputs)
for input_name, content_hash in req.inputs.items():
# Try direct node ID match first
if input_name in nodes:
node = nodes[input_name]
if node.get("node_type") == "SOURCE":
if "config" not in node:
node["config"] = {}
node["config"]["content_hash"] = content_hash
# Try input name lookup
elif input_name in input_name_to_node:
node_id = input_name_to_node[input_name]
node = nodes[node_id]
if "config" not in node:
node["config"] = {}
node["config"]["content_hash"] = content_hash
# Transform output to output_id
if "output" in dag_copy: