spark.loadLocal
function loadLocal(key: string): Promise<ArrayBuffer | null>Load data from local browser storage (IndexedDB).
Retrieves data previously saved with saveLocal. Returns null if the key doesn't exist, allowing for graceful fallbacks.
Parameters
keystring- Unique identifier for the data
Returns
Promise<ArrayBuffer | null>– Promise resolving to ArrayBuffer if found, null if not foundExamples
// Load and restore checkpoint
const weights = await spark.loadLocal('model-v1-best');
if (weights) {
model.load_state_dict(torch.deserialize(weights));
console.log('Restored from local cache');
} else {
console.log('No local checkpoint found');
}
// Conditional loading with fallback
let modelWeights = await spark.loadLocal('latest-checkpoint');
if (!modelWeights) {
// Fall back to loading from server
modelWeights = await spark.load('kasumi/project/weights.pt');
}See Also
- saveLocal - Save to local storage
- existsLocal - Check if key exists