Squashed 'core/' content from commit 4957443

git-subtree-dir: core
git-subtree-split: 4957443184ae0eb6323635a90a19acffb3e01d07
This commit is contained in:
giles
2026-02-24 23:09:39 +00:00
commit cc2dcbddd4
80 changed files with 25711 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
# Simple sequence recipe - concatenates segments from a single input video
name: simple_sequence
version: "1.0"
description: "Split input into segments and concatenate them"
owner: test@local
dag:
nodes:
# Input source - variable (provided at runtime)
- id: video
type: SOURCE
config:
input: true
name: "Input Video"
description: "The video to process"
# Extract first 2 seconds
- id: seg1
type: SEGMENT
config:
start: 0.0
end: 2.0
inputs:
- video
# Extract seconds 5-7
- id: seg2
type: SEGMENT
config:
start: 5.0
end: 7.0
inputs:
- video
# Concatenate the segments
- id: output
type: SEQUENCE
inputs:
- seg1
- seg2
output: output

54
examples/test_local.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
# Local testing script for artdag
# Tests the 3-phase execution without Redis/IPFS
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
ARTDAG_DIR="$(dirname "$SCRIPT_DIR")"
CACHE_DIR="${ARTDAG_DIR}/test_cache"
RECIPE="${SCRIPT_DIR}/simple_sequence.yaml"
# Check for input video
if [ -z "$1" ]; then
echo "Usage: $0 <video_file>"
echo ""
echo "Example:"
echo " $0 /path/to/test_video.mp4"
exit 1
fi
VIDEO_PATH="$1"
if [ ! -f "$VIDEO_PATH" ]; then
echo "Error: Video file not found: $VIDEO_PATH"
exit 1
fi
# Compute content hash of input
echo "=== Computing input hash ==="
VIDEO_HASH=$(python3 -c "
import hashlib
with open('$VIDEO_PATH', 'rb') as f:
print(hashlib.sha3_256(f.read()).hexdigest())
")
echo "Input hash: ${VIDEO_HASH:0:16}..."
# Change to artdag directory
cd "$ARTDAG_DIR"
# Run the full pipeline
echo ""
echo "=== Running artdag run-recipe ==="
echo "Recipe: $RECIPE"
echo "Input: video:${VIDEO_HASH:0:16}...@$VIDEO_PATH"
echo "Cache: $CACHE_DIR"
echo ""
python3 -m artdag.cli run-recipe "$RECIPE" \
-i "video:${VIDEO_HASH}@${VIDEO_PATH}" \
--cache-dir "$CACHE_DIR"
echo ""
echo "=== Done ==="
echo "Cache directory: $CACHE_DIR"
echo "Use 'ls -la $CACHE_DIR' to see cached outputs"

93
examples/test_plan.py Executable file
View File

@@ -0,0 +1,93 @@
#!/usr/bin/env python3
"""
Test the planning phase locally.
This tests the new human-readable names and multi-output support
without requiring actual video files or execution.
"""
import hashlib
import json
import sys
from pathlib import Path
# Add artdag to path
sys.path.insert(0, str(Path(__file__).parent.parent))
from artdag.planning import RecipePlanner, Recipe, ExecutionPlan
def main():
# Load recipe
recipe_path = Path(__file__).parent / "simple_sequence.yaml"
if not recipe_path.exists():
print(f"Recipe not found: {recipe_path}")
return 1
recipe = Recipe.from_file(recipe_path)
print(f"Recipe: {recipe.name} v{recipe.version}")
print(f"Nodes: {len(recipe.nodes)}")
print()
# Fake input hash (would be real content hash in production)
fake_input_hash = hashlib.sha3_256(b"fake video content").hexdigest()
input_hashes = {"video": fake_input_hash}
print(f"Input: video -> {fake_input_hash[:16]}...")
print()
# Generate plan
planner = RecipePlanner(use_tree_reduction=True)
plan = planner.plan(
recipe=recipe,
input_hashes=input_hashes,
seed=42, # Optional seed for reproducibility
)
print("=== Generated Plan ===")
print(f"Plan ID: {plan.plan_id[:24]}...")
print(f"Plan Name: {plan.name}")
print(f"Recipe Name: {plan.recipe_name}")
print(f"Output: {plan.output_name}")
print(f"Steps: {len(plan.steps)}")
print()
# Show steps by level
steps_by_level = plan.get_steps_by_level()
for level in sorted(steps_by_level.keys()):
steps = steps_by_level[level]
print(f"Level {level}: {len(steps)} step(s)")
for step in steps:
# Show human-readable name
name = step.name or step.step_id[:20]
print(f" - {name}")
print(f" Type: {step.node_type}")
print(f" Cache ID: {step.cache_id[:16]}...")
if step.outputs:
print(f" Outputs: {len(step.outputs)}")
for out in step.outputs:
print(f" - {out.name} ({out.media_type})")
if step.inputs:
print(f" Inputs: {[inp.name for inp in step.inputs]}")
print()
# Save plan for inspection
plan_path = Path(__file__).parent.parent / "test_plan_output.json"
with open(plan_path, "w") as f:
f.write(plan.to_json())
print(f"Plan saved to: {plan_path}")
# Show plan JSON structure
print()
print("=== Plan JSON Preview ===")
plan_dict = json.loads(plan.to_json())
# Show first step as example
if plan_dict.get("steps"):
first_step = plan_dict["steps"][0]
print(json.dumps(first_step, indent=2)[:500] + "...")
return 0
if __name__ == "__main__":
sys.exit(main())