Fault-Tolerant Functional Programming with Automatic Checkpointing
Never lose your computational progress again.
Quick Start β’ Reference β’ Tutorials β’ Changelog
Long-running computations in R are vulnerable to interruptions:
# Processing 10,000 API calls...
result <- purrr::map(urls, fetch_data)
# β Crashes at item 9,847 after 3 hours
# β All progress lost
# β Must restart from scratchCommon failure scenarios: - R session crashes or runs out of memory - Network timeouts during API calls - System restarts or power failures - Accidental interruption (Ctrl+C)
SafeMapper provides drop-in replacements for purrr and furrr functions
with automatic checkpoint-based recovery:
# Same code, but fault-tolerant
result <- s_map(urls, fetch_data)
# β‘ Crashes at item 9,847...
# Just re-run the same code:
result <- s_map(urls, fetch_data)
# β
"Resuming from checkpoint: 9800/10000 items completed"
# β
Continues from where it left off
# β
No configuration needed# From r-universe (recommended)
install.packages("SafeMapper", repos = "https://zaoqu-liu.r-universe.dev")
# From GitHub
devtools::install_github("Zaoqu-Liu/SafeMapper")library(SafeMapper)
# Replace purrr::map() with s_map() - that's it!
results <- s_map(1:1000, function(x) {
Sys.sleep(0.1) # Simulate slow operation
x^2
})
# If interrupted, just re-run - automatic recovery!π See full tutorial: Quick Start Guide
| Feature | Description | Learn More |
|---|---|---|
| Zero Configuration | Works out of the box - no setup required | Quick Start |
| Automatic Recovery | Detects previous runs and resumes automatically | Core Concepts |
| Drop-in Replacement | Same API as purrr and furrr |
Map Functions |
| Transparent Checkpointing | Progress saved at configurable intervals | Session Management |
| Parallel Support | Full furrr compatibility for parallel processing |
Parallel Processing |
| Robust Error Handling | Built-in retry and error capture | Error Handling |
| SafeMapper | purrr | Returns | Docs |
|---|---|---|---|
s_map() |
map() |
list | π |
s_map_chr() |
map_chr() |
character | π |
s_map_dbl() |
map_dbl() |
numeric | π |
s_map_int() |
map_int() |
integer | π |
s_map_lgl() |
map_lgl() |
logical | π |
s_map_dfr() |
map_dfr() |
data.frame (row-bind) | π |
s_map_dfc() |
map_dfc() |
data.frame (col-bind) | π |
s_map2() |
map2() |
list (two inputs) | π |
s_pmap() |
pmap() |
list (multiple inputs) | π |
s_imap() |
imap() |
list (with index) | π |
s_walk() |
walk() |
side effects | π |
| SafeMapper | furrr | Docs |
|---|---|---|
s_future_map() |
future_map() |
π |
s_future_map2() |
future_map2() |
π |
s_future_pmap() |
future_pmap() |
π |
s_future_walk() |
future_walk() |
π |
s_future_imap() |
future_imap() |
π |
All variants (_chr, _dbl,
_int, _lgl, _dfr,
_dfc) are supported.
| SafeMapper | purrr | Description | Docs |
|---|---|---|---|
s_safely() |
safely() |
Capture errors | π |
s_possibly() |
possibly() |
Return default on error | π |
s_quietly() |
quietly() |
Capture messages/warnings | π |
π Full API Reference: Reference Index
# Optional: customize settings
s_configure(
batch_size = 100, # Items per checkpoint (default: 100)
retry_attempts = 3 # Retry failed batches (default: 3)
)
# Clean old checkpoint files
s_clean_sessions(older_than_days = 7)π Learn more: Session Management Guide
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β First Execution β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Input Data βββΊ Fingerprint βββΊ Process Batches β
β [1:1000] "abc123..." [1-100] β checkpoint β
β [101-200] β checkpoint β
β [201-300] β CRASH! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Re-execution β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Input Data βββΊ Fingerprint βββΊ Find Checkpoint β
β [1:1000] "abc123..." "200 items completed" β
β β
β Resume from 201 βββΊ Complete! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Deep dive: Core Concepts & Architecture
| Use Case | Description | Example |
|---|---|---|
| API Data Collection | Web scraping, REST API calls with rate limits | View Example |
| File Processing | ETL pipelines, batch transformations | View Example |
| Machine Learning | Cross-validation, hyperparameter tuning | View Example |
| Web Scraping | Extracting data from thousands of pages | View Example |
| Bioinformatics | Processing large genomic datasets | View Example |
| Database Migration | Moving data between systems | View Example |
π All examples: Real-World Examples
| Tutorial | Description | Time |
|---|---|---|
| π Quick Start | Get up and running | 5 min |
| π§ Core Concepts | Understand the architecture | 15 min |
| Tutorial | Description | Level |
|---|---|---|
| πΊοΈ Map Functions | Complete guide to all s_map variants | Intermediate |
| β‘ Parallel Processing | Speed up with s_future_map | Intermediate |
| π‘οΈ Error Handling | s_safely, s_possibly, s_quietly | Intermediate |
| π Session Management | Configure and manage checkpoints | Intermediate |
| Tutorial | Description | Level |
|---|---|---|
| π― Real-World Examples | Complete production examples | Advanced |
| π Best Practices | Production patterns & anti-patterns | Advanced |
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue.
Zaoqu Liu
- π§ Email: liuzaoqu@163.com
- π GitHub: @Zaoqu-Liu - π¬
ORCID: 0000-0002-0452-742X
MIT Β© 2026 Zaoqu Liu
Documentation β’ Report Bug β’ Request Feature