Are you sure you want to delete this access key?
This document provides comprehensive test instructions for the model audit persistent storage feature implemented in PR #5168.
git checkout feat/model-audit-persistent-storage
npm install
npm run build
npm run dev
Note: All CLI commands use npm run local --
to run the local development version instead of the globally installed version.
Note: ModelAudit scans serialized model files (e.g., .pkl
, .h5
, .pt
, .onnx
, .safetensors
), not Python source files. The test instructions use .pkl
files as examples.
Verify the database migration creates the new table:
# Check if migration runs successfully
npm run db:migrate
# Verify table exists (optional - requires sqlite3)
sqlite3 ~/.promptfoo/promptfoo.db "SELECT name FROM sqlite_master WHERE type='table' AND name='model_audit_scans';"
# Create a test model file (pickle format)
python -c "
import pickle
import numpy as np
# Create a simple model (sklearn-like)
class SimpleModel:
def __init__(self):
self.weights = np.random.rand(10, 10)
def predict(self, X):
return X @ self.weights
model = SimpleModel()
with open('test_model.pkl', 'wb') as f:
pickle.dump(model, f)
"
# Run a basic scan (saves to database by default)
npm run local -- scan-model test_model.pkl
# Run a scan without saving to database
npm run local -- scan-model test_model.py --no-write
# Scan with description (saves by default)
npm run local -- scan-model test_model.pkl --description "Test scan of pickled model"
# Scan multiple files with description
npm run local -- scan-model test_model.pkl examples/ --description "Multi-path scan test"
# List all scans
npm run local -- list scans
# List with limit
npm run local -- list scans -n 5
# List IDs only
npm run local -- list scans --ids-only
# Get the scan ID from the list command above, then:
# Replace <scan-id> with actual ID like scan-ABC-2025-01-04T12:00:00
npm run local -- show scan <scan-id>
# Or use the shorthand
npm run local -- show <scan-id>
# Show the most recent scan
npm run local -- show scan latest
# Export to file
npm run local -- export <scan-id> -o exported_scan.json
# Export to stdout
npm run local -- export <scan-id>
# Export the most recent scan
npm run local -- export latest -o latest_scan.json
# Import the exported scan
npm run local -- import exported_scan.json
# Import with force (overwrites existing)
npm run local -- import exported_scan.json --force
# Delete specific scan
npm run local -- delete scan <scan-id>
# Delete all scans (will prompt for confirmation)
npm run local -- delete scan --all
Keep the dev server running (npm run dev
) and open http://localhost:3000/model-audit
Add a path to scan:
test_model.pkl
)Add a description:
Run the scan:
Check notification:
Test the API endpoints directly:
# List scans with pagination
curl http://localhost:15500/api/model-audit/scans?limit=10&offset=0
# Test pagination validation
curl http://localhost:15500/api/model-audit/scans?limit=150&offset=-5
# Should clamp limit to 100 and offset to 0
# Get scan details (replace with actual scan ID)
curl http://localhost:15500/api/model-audit/scans/<scan-id>
# Test invalid scan ID
curl http://localhost:15500/api/model-audit/scans/invalid-id
# Should return 400 error
# Delete a scan (replace with actual scan ID)
curl -X DELETE http://localhost:15500/api/model-audit/scans/<scan-id>
# Non-existent file
npm run local -- scan-model /path/that/does/not/exist.py
# Empty path
npm run local -- scan-model ""
# Create a malformed JSON file
echo '{"invalid": "json"' > bad.json
npm run local -- import bad.json
# Import eval instead of scan
npm run local -- export eval-123 -o eval.json
npm run local -- import eval.json
# Should handle eval import correctly
# Try to import duplicate scan ID
npm run local -- export <scan-id> -o scan1.json
npm run local -- import scan1.json
# Should fail with duplicate ID error
# Import with force
npm run local -- import scan1.json --force
# Should overwrite existing scan
# Scan a large directory
npm run local -- scan-model /path/to/large/ml/project --description "Performance test"
# List many scans
# First create multiple scans
for i in {1..20}; do
python -c "import pickle; pickle.dump({'model': $i}, open('model_$i.pkl', 'wb'))"
npm run local -- scan-model model_$i.pkl --description "Test $i"
done
# Then list with pagination
npm run local -- list scans -n 10
# Remove test files
rm -f test_model.pkl model_*.pkl exported_scan.json eval.json bad.json
# Delete all test scans (optional)
npm run local -- delete scan --all
scan-XXX-YYYY-MM-DDTHH:mm:ss
--no-write
flag prevents saving to databaselatest
alias works for show and export commandspip install modelaudit
)If you encounter issues:
ModelAudit not installed:
pip install modelaudit
Database issues:
# Reset database (WARNING: deletes all data)
rm ~/.promptfoo/promptfoo.db
npm run db:migrate
Build issues:
npm run build:clean
npm run build
Check logs:
Press p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?