#!/usr/bin/env bash
# Copyright (c) 2025 Tylt LLC. All rights reserved.
# Derivative works may be released by researchers,
# but original files may not be redistributed or used beyond research purposes.
#
# DO NOT EDIT THIS FILE - Generated by cudag framework

# Generate a small test dataset locally for quick validation (no preprocessing)
#
# Usage:
#   ./scripts/test.sh

set -euo pipefail

echo "========================================"
echo "TEST MODE: Local Dataset Generation"
echo "========================================"
echo ""
echo "Using config: config/dataset.test.yaml"
echo ""

# Set env var so generator.py knows it was called from script
export CUDAG_FROM_SCRIPT=1

# Run with test config
uv run python generator.py --config config/dataset.test.yaml

if [[ $? -ne 0 ]]; then
    echo ""
    echo "Test generation failed"
    exit 1
fi

# Find the most recently created dataset directory
LATEST_DATASET=$(ls -td datasets/*/ 2>/dev/null | head -1)

if [[ -z "$LATEST_DATASET" ]]; then
    echo ""
    echo "No dataset directory found"
    exit 1
fi

DATASET_NAME=$(basename "$LATEST_DATASET")

echo ""
echo "========================================"
echo "Test dataset generated successfully!"
echo "========================================"
echo ""
echo "Dataset: $DATASET_NAME"
echo "Location: datasets/$DATASET_NAME"
echo ""
echo "Next steps:"
echo "  # Verify the dataset quality"
echo "  ls -lh datasets/$DATASET_NAME/"
echo ""
echo "  # Check sample counts"
echo "  wc -l datasets/$DATASET_NAME/*.jsonl"
echo ""
