<p align="center">
<img src="https://github.com/gloaguen-evan/resnap/blob/main/art/logo.png?raw=true" alt="resnap logo" style="width:100%; max-width:600px;"/>
</p>
<h1 align="center">resnap</h1>
<p align="center">
<em>Smart function output snapshots and caching for Python</em><br>
<strong>resnap</strong> snapshots and reuses function outputs based on their inputs, saving time with smart caching and metadata tracking.
</p>
---


## π Features
- Snapshot and cache function/method outputs on disk
- Avoid re-executing code when inputs havenβt changed
- Supports multiple formats:
- For pd.DataFrame objects: `parquet` (default) and `csv`
- For other objects: `pkl` (default), `json`, and `txt`.
(Note that for the "json" format, the object type must be compatible with the json.dump method.)
- Stores metadata automatically
- Add custom metadata
- Minimal setup, flexible usage
---
## π¦ Installation
To test in local mode
```bash
pip install resnap
```
If you want to use a S3 solution
```bash
pip install resnap[boto]
```
## π οΈ Configuration
To use this library, you need to configure it using a pyproject.toml file.
Add the following section under [tool.resnap]:
```toml
[tool.resnap]
enabled = true # Enable or disable the library functionality
save_to = "local" # Choose the storage backend (e.g., 'local')
output_base_path = "results" # Directory where output files will be saved
secrets_file_name = "" # Optional: path to a secrets file (leave empty if unused (e.g, 'local'))
enable_remove_old_files = true # Automatically delete old files based on retention policy
max_history_files_length = 3 # Duration value for file retention, used with max_history_files_time_unit
max_history_files_time_unit = "day" # Time unit used for history retention (e.g., 'second', 'minute', 'hour', 'day')
```
## π§ͺ Quick Example
```python
from resnap import resnap
@resnap
def expensive_computation(x, y):
print("Running the actual computation...")
return x * y + 42
result = expensive_computation(10, 2)
```
Second call with same arguments:
```python
# Output is retrieved from cache β no print, no computation
result = expensive_computation(10, 2)
```
## π Output Structure
Each snapshot includes:
- A result file (in the format of your choice)
- A metadata file (e.g., timestamp, arguments, execution time, etc.)
## π Documentation
The documentation is available on [ReadTheDocs](https://resnap.readthedocs.io/en/latest/).
## π‘οΈ License
This project is licensed under the MIT License. See the LICENSE file for details.
## π€ Contributing
Contributions, issues and feature requests are welcome!
Feel free to open a PR or start a discussion.
βοΈ Show your support
If you find this project useful, give it a βοΈ on GitHub!
Raw data
{
"_id": null,
"home_page": null,
"name": "resnap",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.13,>=3.10",
"maintainer_email": null,
"keywords": "cache, checkpoint, function, method, python, results, save, snapshot",
"author": null,
"author_email": "Evan Gloaguen <evan.gloaguen@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/11/4f/585b69b9de88e00948b320c638ec739c4cdf83cc88e1d1df3a1f5a76d4bf/resnap-0.4.0.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <img src=\"https://github.com/gloaguen-evan/resnap/blob/main/art/logo.png?raw=true\" alt=\"resnap logo\" style=\"width:100%; max-width:600px;\"/>\n</p>\n\n<h1 align=\"center\">resnap</h1>\n\n<p align=\"center\">\n <em>Smart function output snapshots and caching for Python</em><br>\n <strong>resnap</strong> snapshots and reuses function outputs based on their inputs, saving time with smart caching and metadata tracking.\n</p>\n\n---\n\n\n\n\n## \ud83d\ude80 Features\n\n- Snapshot and cache function/method outputs on disk\n- Avoid re-executing code when inputs haven\u2019t changed\n- Supports multiple formats: \n - For pd.DataFrame objects: `parquet` (default) and `csv`\n - For other objects: `pkl` (default), `json`, and `txt`. \n (Note that for the \"json\" format, the object type must be compatible with the json.dump method.)\n- Stores metadata automatically\n- Add custom metadata\n- Minimal setup, flexible usage\n\n---\n\n## \ud83d\udce6 Installation\n\nTo test in local mode\n```bash\npip install resnap\n```\n\nIf you want to use a S3 solution\n```bash\npip install resnap[boto]\n```\n\n## \ud83d\udee0\ufe0f Configuration\nTo use this library, you need to configure it using a pyproject.toml file.\nAdd the following section under [tool.resnap]:\n```toml\n[tool.resnap]\nenabled = true # Enable or disable the library functionality\nsave_to = \"local\" # Choose the storage backend (e.g., 'local')\noutput_base_path = \"results\" # Directory where output files will be saved\nsecrets_file_name = \"\" # Optional: path to a secrets file (leave empty if unused (e.g, 'local'))\nenable_remove_old_files = true # Automatically delete old files based on retention policy\nmax_history_files_length = 3 # Duration value for file retention, used with max_history_files_time_unit\nmax_history_files_time_unit = \"day\" # Time unit used for history retention (e.g., 'second', 'minute', 'hour', 'day')\n```\n\n## \ud83e\uddea Quick Example\n\n```python\nfrom resnap import resnap\n\n@resnap\ndef expensive_computation(x, y):\n print(\"Running the actual computation...\")\n return x * y + 42\n\nresult = expensive_computation(10, 2)\n```\n\nSecond call with same arguments:\n```python\n# Output is retrieved from cache \u2014 no print, no computation\nresult = expensive_computation(10, 2)\n```\n\n## \ud83d\udcc1 Output Structure\nEach snapshot includes:\n- A result file (in the format of your choice)\n- A metadata file (e.g., timestamp, arguments, execution time, etc.)\n\n## \ud83d\udcda Documentation\nThe documentation is available on [ReadTheDocs](https://resnap.readthedocs.io/en/latest/).\n\n## \ud83d\udee1\ufe0f License\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## \ud83e\udd1d Contributing\nContributions, issues and feature requests are welcome!\nFeel free to open a PR or start a discussion.\n\n\u2b50\ufe0f Show your support\nIf you find this project useful, give it a \u2b50\ufe0f on GitHub!\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python library that captures and replays function results to save time, boost performance.",
"version": "0.4.0",
"project_urls": {
"Changelog": "https://github.com/gloaguen-evan/resnap/releases",
"Issues": "https://github.com/gloaguen-evan/resnap/issues",
"Repository": "https://github.com/gloaguen-evan/resnap"
},
"split_keywords": [
"cache",
" checkpoint",
" function",
" method",
" python",
" results",
" save",
" snapshot"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "b3ec1a467edb483bbe98d1ee4df7dcfe7b7b44ca9cf2f09f4a21a4976220bd34",
"md5": "308d8be7e83ad0fa50c2d0435d0b22fa",
"sha256": "11d294d910ae9ded3765242c04523bfe20586e59f55a64706fb6f84595e24fe6"
},
"downloads": -1,
"filename": "resnap-0.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "308d8be7e83ad0fa50c2d0435d0b22fa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.10",
"size": 29282,
"upload_time": "2025-07-29T07:49:26",
"upload_time_iso_8601": "2025-07-29T07:49:26.009851Z",
"url": "https://files.pythonhosted.org/packages/b3/ec/1a467edb483bbe98d1ee4df7dcfe7b7b44ca9cf2f09f4a21a4976220bd34/resnap-0.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "114f585b69b9de88e00948b320c638ec739c4cdf83cc88e1d1df3a1f5a76d4bf",
"md5": "4edadc203b4f462f6ef2e8bb821b782c",
"sha256": "1398e544c4389e2320f5f867c6ba811f1a2606fcb8897cc052d256288ae1aea7"
},
"downloads": -1,
"filename": "resnap-0.4.0.tar.gz",
"has_sig": false,
"md5_digest": "4edadc203b4f462f6ef2e8bb821b782c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.10",
"size": 641563,
"upload_time": "2025-07-29T07:49:27",
"upload_time_iso_8601": "2025-07-29T07:49:27.203965Z",
"url": "https://files.pythonhosted.org/packages/11/4f/585b69b9de88e00948b320c638ec739c4cdf83cc88e1d1df3a1f5a76d4bf/resnap-0.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-29 07:49:27",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "gloaguen-evan",
"github_project": "resnap",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "resnap"
}