test_subfolder_scanning.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. # Test script for subfolder model scanning
  3. # This script creates a test directory structure and verifies that subfolder models are detected
  4. set -e
  5. TEST_BASE="/tmp/sd_test_models"
  6. TEST_CHECKPOINTS="$TEST_BASE/checkpoints"
  7. echo "Setting up test environment..."
  8. # Clean up previous test
  9. rm -rf "$TEST_BASE"
  10. # Create test directory structure
  11. mkdir -p "$TEST_CHECKPOINTS/subfolder1"
  12. mkdir -p "$TEST_CHECKPOINTS/subfolder2/deep"
  13. mkdir -p "$TEST_CHECKPOINTS/subfolder2/nested"
  14. # Create dummy model files
  15. touch "$TEST_CHECKPOINTS/model1.safetensors"
  16. touch "$TEST_CHECKPOINTS/subfolder1/model2.safetensors"
  17. touch "$TEST_CHECKPOINTS/subfolder2/model3.safetensors"
  18. touch "$TEST_CHECKPOINTS/subfolder2/deep/model4.safetensors"
  19. touch "$TEST_CHECKPOINTS/subfolder2/nested/model5.safetensors"
  20. # Create other model types
  21. mkdir -p "$TEST_BASE/loras"
  22. touch "$TEST_BASE/loras/lora1.safetensors"
  23. mkdir -p "$TEST_BASE/loras/subfolder"
  24. touch "$TEST_BASE/loras/subfolder/lora2.safetensors"
  25. echo "Test directory structure created:"
  26. echo "- $TEST_CHECKPOINTS/model1.safetensors"
  27. echo "- $TEST_CHECKPOINTS/subfolder1/model2.safetensors"
  28. echo "- $TEST_CHECKPOINTS/subfolder2/model3.safetensors"
  29. echo "- $TEST_CHECKPOINTS/subfolder2/deep/model4.safetensors"
  30. echo "- $TEST_CHECKPOINTS/subfolder2/nested/model5.safetensors"
  31. echo "- $TEST_BASE/loras/lora1.safetensors"
  32. echo "- $TEST_BASE/loras/subfolder/lora2.safetensors"
  33. echo ""
  34. echo "Running model scanning test..."
  35. # Run the server with test directory
  36. cd /data/stable-diffusion.cpp-rest/build
  37. timeout 10s ./stable-diffusion-rest-server \
  38. --models-dir "$TEST_BASE" \
  39. --checkpoints "$TEST_CHECKPOINTS" \
  40. --lora-dir "$TEST_BASE/loras" \
  41. --host 127.0.0.1 \
  42. --port 0 \
  43. --verbose || true
  44. echo ""
  45. echo "Test completed. Check the output above to verify that subfolder models were detected."
  46. echo ""
  47. echo "Expected models to be found:"
  48. echo "- model1.safetensors"
  49. echo "- subfolder1/model2.safetensors"
  50. echo "- subfolder2/model3.safetensors"
  51. echo "- subfolder2/deep/model4.safetensors"
  52. echo "- subfolder2/nested/model5.safetensors"
  53. echo "- loras/lora1.safetensors"
  54. echo "- loras/subfolder/lora2.safetensors"
  55. # Cleanup
  56. rm -rf "$TEST_BASE"