Skip to main content
torch.js has not been released yet.
torch.js logotorch.js logotorch.js
PlaygroundContact
Login
Documentation
IntroductionType SafetyTensor ExpressionsTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformancePyTorch CompatibilityBenchmarksDType Coverage
torch.js· 2026
LegalTerms of UsePrivacy Policy
/
/
  1. docs
  2. Spark
  3. spark
  4. deleteFile

spark.deleteFile

function deleteFile(path: string): Promise<void>

Delete a file from torchjs.org.

Removes a file from the server. Like save, this supports both direct deletion (in authenticated contexts) and RPC-proxied deletion (in sandboxed iframes).

Use this to:

  • Remove outdated checkpoints or intermediate results
  • Clean up unused files to save storage
  • Correct mistakes or remove failed experiments
Deletion is permanent. Consider making a backup or using version numbers in filenames before deleting.

Parameters

pathstring
File path in format "username/project/filename" or "username/project/path/to/file"

Returns

Promise<void>– Promise that resolves when file is deleted

Examples

// Delete outdated checkpoint
await spark.delete('kasumi/mnist/checkpoint-old.pt');

// Delete a temporary file
await spark.delete('kasumi/project/temp-output.txt');

// Conditional deletion (delete old file before saving new one)
if (await spark.exists('kasumi/model/weights-v1.pt')) {
  await spark.delete('kasumi/model/weights-v1.pt');
}
await spark.save('kasumi/model/weights-v2.pt', newWeights);

See Also

  • save - Save files
  • exists - Check if file exists
Previous
dataset
Next
deleteLocal