mcp4rdf / TESTING_GUIDE.md
RDF Validation Deployment
optimization...
b1f11a7

A newer version of the Gradio SDK is available: 6.1.0

Upgrade

Testing the Speed Optimizations

Quick Test

  1. Start the app:

    python app.py
    
  2. Load the sample invalid RDF (click "Load Invalid Sample")

  3. Click "Validate RDF" with default settings

  4. Expected behavior:

    • ⏱️ Should complete in < 5 seconds (was 2 minutes)
    • πŸ“ Steps will show: "Attempting rapid fix..." β†’ "βœ… Rapid fix successful!"
    • βœ… Corrected RDF should pass validation
    • πŸ” Should add missing: language, content, adminMetadata

Detailed Testing Scenarios

Test 1: Simple Missing Properties (Rapid Fix)

Input: Work with missing title, language, content Expected: < 5 seconds, rapid fix success Check: Steps show "βœ… Rapid fix successful!"

Test 2: Complex Errors (Minimal AI)

Input: Work with structural issues, wrong data types Expected: 15-25 seconds, minimal AI correction Check: Steps show "Attempting minimal AI correction..."

Test 3: Very Complex (Full AI)

Input: Multiple nested errors, invalid URIs, missing relationships Expected: 30-45 seconds, full AI correction Check: Steps show progression through all tiers

Test 4: Repeated Errors (Cache Hit)

Input: Same invalid RDF tested twice Expected: Second run < 1 second Check: Steps show "Using cached correction for repeated validation errors"

Performance Benchmarks

Record times for each test:

Test Case Expected Actual Status
Simple (Rapid) < 5s ___s [ ]
Complex (Minimal AI) 15-25s ___s [ ]
Very Complex (Full AI) 30-45s ___s [ ]
Cached Repeat < 1s ___s [ ]

Verification Checklist

  • Sample invalid RDF fixes in < 5 seconds
  • Steps logging shows rapid fix attempt
  • Re-validation occurs after correction
  • Cache stores successful corrections
  • Max attempts defaults to 2 (not 5)
  • Timeout prevents hanging (45s max)
  • All corrections maintain re-validation
  • UI shows updated max attempts (1-3 range)

Troubleshooting

If rapid fix fails:

  • Check console for: "Attempting rapid fix..."
  • Verify pattern matching in rapid_fix_missing_properties()
  • Ensure VALIDATOR_AVAILABLE is True

If still slow (> 45s):

  • Check HF_API_KEY is set (for AI fallback)
  • Verify timeouts are applied (20s per call, 45s total)
  • Look for network issues in API calls

If cache not working:

  • Check: "Using cached correction..." in steps
  • Verify _make_fix_cache_key() generates consistent keys
  • Ensure OrderedDict import is present

Debug Mode

Enable step-by-step logging:

  1. Check "Show steps" in UI
  2. Watch console output
  3. Verify tier progression: Rapid β†’ Minimal β†’ Full

Success Criteria

βœ… Sample invalid RDF: < 5 seconds βœ… Complex errors: < 30 seconds βœ… No hangs: 45 second timeout enforced βœ… Cache hits: < 1 second βœ… Re-validation: Always occurs

Rollback

If issues occur, revert these functions to original:

  • rapid_fix_missing_properties()
  • get_ai_correction_minimal()
  • get_ai_correction_targeted()
  • Configuration: MAX_CORRECTION_ATTEMPTS, timeouts