Overview
The checkpoint module provides functionality to save and load intermediate computation results. This allows you to cache expensive operations and resume workflows from saved states.Main Functions
from_checkpoint
The path to the checkpoint file (without extension). Files are saved to
out/checkpoints/{path}The function to execute if the checkpoint does not exist
The parameters to pass to the function
Whether to use the checkpoint if it exists. Set to False to force re-execution
The result of the function execution or the checkpoint data
write_checkpoint
The data to write to the checkpoint. Can be a DataFrame, GeoDataFrame, or any picklable object
The path to the checkpoint file (without extension). Files are saved to
out/checkpoints/{path}- GeoDataFrames are saved as
.parquetfiles with geometry preserved - DataFrames are saved as
.parquetfiles - Other objects are saved as
.picklefiles
read_checkpoint
The path to the checkpoint file (without extension). Looks for files in
out/checkpoints/{path}The data read from the checkpoint, which can be a DataFrame, GeoDataFrame, or any object that was pickled
- Reading
.parquetfiles as DataFrames or GeoDataFrames - Converting WKB-encoded geometry columns back to GeoDataFrames
- Attempting to infer EPSG:4326 CRS for geographic data
- Falling back to
.picklefiles if parquet is not found
exists_checkpoint
The path to the checkpoint file (without extension). Checks
out/checkpoints/{path}True if a checkpoint exists (either
.parquet or .pickle), False otherwisedelete_checkpoints
The prefix to match checkpoint files against. All files in
out/checkpoints/ starting with this prefix will be deletedread_pickle
The path to the pickle file (without extension). Reads from
{path}.pickleThe data read from the pickle file
Example Usage
Basic Checkpoint Usage
Manual Checkpoint Management
Working with GeoDataFrames
Storage Location
All checkpoints are stored in theout/checkpoints/ directory. The directory is created automatically if it doesn’t exist.
File Formats
- Parquet (
.parquet): Used for pandas DataFrames and GeoPandas GeoDataFrames. Provides efficient columnar storage. - Pickle (
.pickle): Used for other Python objects that can be serialized.