pyBiocFileCache 0.8.0.dev0__tar.gz → 0.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pybiocfilecache-0.8.1/.github/workflows/publish-pypi.yml +91 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/.github/workflows/r-interop-tests.yml +2 -3
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/.github/workflows/run-tests.yml +12 -14
- pybiocfilecache-0.8.1/AUTHORS.md +5 -0
- pybiocfilecache-0.8.1/CHANGELOG.md +57 -0
- pybiocfilecache-0.8.1/PKG-INFO +154 -0
- pybiocfilecache-0.8.1/README.md +99 -0
- pybiocfilecache-0.8.1/docs/license.md +5 -0
- pybiocfilecache-0.8.1/pyproject.toml +88 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/src/pybiocfilecache/cache.py +93 -45
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/src/pybiocfilecache/config.py +1 -2
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/src/pybiocfilecache/utils.py +7 -7
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/tests/test_cache.py +66 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/tox.ini +15 -11
- pybiocfilecache-0.8.0.dev0/.gitattributes +0 -10
- pybiocfilecache-0.8.0.dev0/.github/workflows/publish-pypi.yml +0 -53
- pybiocfilecache-0.8.0.dev0/.python-version +0 -1
- pybiocfilecache-0.8.0.dev0/.readthedocs.yml +0 -21
- pybiocfilecache-0.8.0.dev0/.zenodo.json +0 -14
- pybiocfilecache-0.8.0.dev0/AUTHORS.md +0 -4
- pybiocfilecache-0.8.0.dev0/CHANGELOG.md +0 -4
- pybiocfilecache-0.8.0.dev0/CITATION.cff +0 -10
- pybiocfilecache-0.8.0.dev0/CONTRIBUTING.rst +0 -353
- pybiocfilecache-0.8.0.dev0/PKG-INFO +0 -21
- pybiocfilecache-0.8.0.dev0/README.md +0 -4
- pybiocfilecache-0.8.0.dev0/docs/contributing.rst +0 -1
- pybiocfilecache-0.8.0.dev0/docs/license.md +0 -5
- pybiocfilecache-0.8.0.dev0/docs/license.rst +0 -7
- pybiocfilecache-0.8.0.dev0/pyproject.toml +0 -66
- pybiocfilecache-0.8.0.dev0/uv.lock +0 -1993
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/.coveragerc +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/.github/dependabot.yml +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/.github/workflows/pre-commit.yml +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/.gitignore +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/.pre-commit-config.yaml +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/CONTRIBUTING.md +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/LICENSE.txt +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/docs/Makefile +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/docs/_static/.gitignore +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/docs/authors.md +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/docs/best_practices.md +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/docs/changelog.md +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/docs/conf.py +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/docs/contributing.md +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/docs/index.md +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/docs/readme.md +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/docs/requirements.txt +2 -2
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/src/pybiocfilecache/__init__.py +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/src/pybiocfilecache/const.py +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/src/pybiocfilecache/models.py +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/src/pybiocfilecache/py.typed +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/tests/conftest.py +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/tests/data/test1.txt +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/tests/data/test2.txt +0 -0
- {pybiocfilecache-0.8.0.dev0 → pybiocfilecache-0.8.1}/tests/test_r_interop.py +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
name: Publish to PyPI and GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: "*"
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build-and-test:
|
|
9
|
+
name: Build and Test
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v7
|
|
13
|
+
|
|
14
|
+
- name: Set up Python 3.12
|
|
15
|
+
uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: 3.12
|
|
18
|
+
|
|
19
|
+
- name: Install tox
|
|
20
|
+
run: python -m pip install tox
|
|
21
|
+
|
|
22
|
+
- name: Test
|
|
23
|
+
run: tox -e default
|
|
24
|
+
|
|
25
|
+
- name: Build Project
|
|
26
|
+
run: tox -e build
|
|
27
|
+
|
|
28
|
+
- name: Store the distribution packages
|
|
29
|
+
uses: actions/upload-artifact@v4
|
|
30
|
+
with:
|
|
31
|
+
name: python-package-distributions
|
|
32
|
+
path: dist/
|
|
33
|
+
|
|
34
|
+
build-docs:
|
|
35
|
+
name: Build Documentation
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
steps:
|
|
38
|
+
- uses: actions/checkout@v7
|
|
39
|
+
|
|
40
|
+
- name: Set up Python 3.12
|
|
41
|
+
uses: actions/setup-python@v5
|
|
42
|
+
with:
|
|
43
|
+
python-version: 3.12
|
|
44
|
+
|
|
45
|
+
- name: Install tox
|
|
46
|
+
run: python -m pip install tox
|
|
47
|
+
|
|
48
|
+
- name: Build docs
|
|
49
|
+
run: tox -e docs
|
|
50
|
+
|
|
51
|
+
- name: Add .nojekyll
|
|
52
|
+
run: touch ./docs/_build/html/.nojekyll
|
|
53
|
+
|
|
54
|
+
- name: Upload Pages artifact
|
|
55
|
+
uses: actions/upload-pages-artifact@v5
|
|
56
|
+
with:
|
|
57
|
+
path: ./docs/_build/html
|
|
58
|
+
|
|
59
|
+
publish-pypi:
|
|
60
|
+
name: Publish to PyPI
|
|
61
|
+
needs: build-and-test
|
|
62
|
+
runs-on: ubuntu-latest
|
|
63
|
+
environment:
|
|
64
|
+
name: pypi
|
|
65
|
+
url: https://pypi.org/p/biocframe
|
|
66
|
+
permissions:
|
|
67
|
+
id-token: write # IMPORTANT: mandatory for trusted publishing
|
|
68
|
+
steps:
|
|
69
|
+
- name: Download all the dists
|
|
70
|
+
uses: actions/download-artifact@v8
|
|
71
|
+
with:
|
|
72
|
+
name: python-package-distributions
|
|
73
|
+
path: dist/
|
|
74
|
+
|
|
75
|
+
- name: Publish package to PyPI
|
|
76
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
77
|
+
|
|
78
|
+
deploy-pages:
|
|
79
|
+
name: Deploy GitHub Pages
|
|
80
|
+
needs: build-docs
|
|
81
|
+
runs-on: ubuntu-latest
|
|
82
|
+
permissions:
|
|
83
|
+
pages: write
|
|
84
|
+
id-token: write
|
|
85
|
+
environment:
|
|
86
|
+
name: github-pages
|
|
87
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
88
|
+
steps:
|
|
89
|
+
- name: Deploy to GitHub Pages
|
|
90
|
+
id: deployment
|
|
91
|
+
uses: actions/deploy-pages@v5
|
|
@@ -34,8 +34,7 @@ jobs:
|
|
|
34
34
|
- name: Install Python dependencies
|
|
35
35
|
run: |
|
|
36
36
|
python -m pip install --upgrade pip
|
|
37
|
-
pip install
|
|
38
|
-
uv sync
|
|
37
|
+
pip install -e ".[testing]"
|
|
39
38
|
|
|
40
39
|
- uses: r-lib/actions/setup-r@v2
|
|
41
40
|
with:
|
|
@@ -53,4 +52,4 @@ jobs:
|
|
|
53
52
|
run: Rscript -e "library(BiocFileCache)"
|
|
54
53
|
|
|
55
54
|
- name: Run R/Python roundtrip tests
|
|
56
|
-
run:
|
|
55
|
+
run: pytest tests/test_r_interop.py -v
|
|
@@ -32,26 +32,24 @@ jobs:
|
|
|
32
32
|
platform:
|
|
33
33
|
- ubuntu-latest
|
|
34
34
|
- macos-latest
|
|
35
|
-
- windows-latest
|
|
35
|
+
# - windows-latest
|
|
36
36
|
runs-on: ${{ matrix.platform }}
|
|
37
37
|
name: Python ${{ matrix.python }}, ${{ matrix.platform }}
|
|
38
38
|
steps:
|
|
39
|
-
- uses: actions/checkout@
|
|
39
|
+
- uses: actions/checkout@v7
|
|
40
40
|
|
|
41
|
-
-
|
|
42
|
-
|
|
41
|
+
- name: Set up Python
|
|
42
|
+
uses: actions/setup-python@v5
|
|
43
43
|
with:
|
|
44
44
|
python-version: ${{ matrix.python }}
|
|
45
45
|
|
|
46
|
-
- name: Install
|
|
47
|
-
run:
|
|
48
|
-
python -m pip install --upgrade pip
|
|
49
|
-
pip install uv tox
|
|
50
|
-
uv sync
|
|
46
|
+
- name: Install tox
|
|
47
|
+
run: python -m pip install tox coverage
|
|
51
48
|
|
|
52
49
|
- name: Run tests
|
|
53
|
-
run:
|
|
54
|
-
tox
|
|
50
|
+
run: >-
|
|
51
|
+
tox
|
|
52
|
+
-- -rFEx --durations 10 --color yes --cov --cov-branch --cov-report=xml # pytest args
|
|
55
53
|
|
|
56
54
|
- name: Check for codecov token availability
|
|
57
55
|
id: codecov-check
|
|
@@ -64,9 +62,9 @@ jobs:
|
|
|
64
62
|
fi
|
|
65
63
|
|
|
66
64
|
- name: Upload coverage reports to Codecov with GitHub Action
|
|
67
|
-
uses: codecov/codecov-action@
|
|
65
|
+
uses: codecov/codecov-action@v7
|
|
68
66
|
if: ${{ steps.codecov-check.outputs.codecov == 'true' }}
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
with:
|
|
68
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
71
69
|
slug: ${{ github.repository }}
|
|
72
70
|
flags: ${{ matrix.platform }} - py${{ matrix.python }}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## Version 0.8.0 - 0.8.1
|
|
4
|
+
|
|
5
|
+
- Upgrade to hatchit template
|
|
6
|
+
- Fix issues with shared caches with R and Python interfaces. Added actions to test shared cache usage.
|
|
7
|
+
|
|
8
|
+
## Version 0.7.0
|
|
9
|
+
|
|
10
|
+
- Fixing issues with using R and Python interfaces to the same cache directory.
|
|
11
|
+
- List resources now returns a `BiocFrame` object.
|
|
12
|
+
|
|
13
|
+
## Version 0.6.1 - 0.6.2
|
|
14
|
+
|
|
15
|
+
- Generate rid's that match with R's cache.
|
|
16
|
+
- Remove rname pattern checks.
|
|
17
|
+
- Add functions to access metadata table.
|
|
18
|
+
- Add function to add web urls and download them if needed.
|
|
19
|
+
- Rename GitHub actions for consistency with the rest of the packages.
|
|
20
|
+
|
|
21
|
+
## Version 0.6.0
|
|
22
|
+
|
|
23
|
+
- Reverting schema changes that break compatibility with the R/BiocFileCache implementation.
|
|
24
|
+
- Added support for Python 3.13
|
|
25
|
+
|
|
26
|
+
## Version 0.5.5
|
|
27
|
+
|
|
28
|
+
- chore: Remove Python 3.8 (EOL).
|
|
29
|
+
- precommit: Replace docformatter with ruff's formatter.
|
|
30
|
+
|
|
31
|
+
## Version 0.5.0
|
|
32
|
+
|
|
33
|
+
- SQLAlchemy session management
|
|
34
|
+
* Implemented proper session handling
|
|
35
|
+
* Fixed `DetachedInstanceError` issues and added helper method `_get_detached_resource` for consistent session management
|
|
36
|
+
* Improved transaction handling with commits and rollbacks
|
|
37
|
+
|
|
38
|
+
- New features
|
|
39
|
+
* Added cache statistics with `get_stats()` method
|
|
40
|
+
* Implemented resource tagging
|
|
41
|
+
* Added cache size management
|
|
42
|
+
* Added support for file compression
|
|
43
|
+
* Added resource validation with checksums
|
|
44
|
+
* Improved search
|
|
45
|
+
* Added metadata export/import functionality
|
|
46
|
+
|
|
47
|
+
## Version 0.4.1
|
|
48
|
+
|
|
49
|
+
- Method to list all resources.
|
|
50
|
+
|
|
51
|
+
## Version 0.4
|
|
52
|
+
|
|
53
|
+
- Migrate the schema to match R/Bioconductor's BiocFileCache (Check out [this issue](https://github.com/BiocPy/pyBiocFileCache/issues/11)). Thanks to [@khoroshevskyi ](https://github.com/khoroshevskyi) for the PR.
|
|
54
|
+
|
|
55
|
+
## Version 0.1
|
|
56
|
+
|
|
57
|
+
- Initial release of the package, Setting up all the actions.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pybiocfilecache
|
|
3
|
+
Version: 0.8.1
|
|
4
|
+
Summary: File based cache for resources and metadata
|
|
5
|
+
Project-URL: Homepage, https://github.com/BiocPy/pybiocfilecache
|
|
6
|
+
Project-URL: Documentation, https://biocpy.github.io/pybiocfilecache
|
|
7
|
+
Project-URL: Repository, https://github.com/BiocPy/pybiocfilecache
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/BiocPy/pybiocfilecache/issues
|
|
9
|
+
Author-email: Jayaram Kancherla <jayaram.kancherla@gmail.com>
|
|
10
|
+
License: The MIT License (MIT)
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2021 Genentech, Inc.
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: AUTHORS.md
|
|
32
|
+
License-File: LICENSE.txt
|
|
33
|
+
Keywords: biocfilecache,cache,file-cache,resource-management,sqlite
|
|
34
|
+
Classifier: Development Status :: 4 - Beta
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: Intended Audience :: Science/Research
|
|
37
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
38
|
+
Classifier: Operating System :: OS Independent
|
|
39
|
+
Classifier: Programming Language :: Python :: 3
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
44
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
45
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
46
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
47
|
+
Requires-Python: >=3.9
|
|
48
|
+
Requires-Dist: biocframe
|
|
49
|
+
Requires-Dist: sqlalchemy
|
|
50
|
+
Provides-Extra: testing
|
|
51
|
+
Requires-Dist: pytest; extra == 'testing'
|
|
52
|
+
Requires-Dist: pytest-cov; extra == 'testing'
|
|
53
|
+
Requires-Dist: setuptools; extra == 'testing'
|
|
54
|
+
Description-Content-Type: text/markdown
|
|
55
|
+
|
|
56
|
+
[](https://pypi.org/project/pyBiocFileCache/)
|
|
57
|
+

|
|
58
|
+

|
|
59
|
+
|
|
60
|
+
# pyBiocFileCache
|
|
61
|
+
|
|
62
|
+
`pyBiocFileCache` is a Python package that provides a file caching system with resource validation, expiration management, and SQLite-backed metadata. Compatible with the [BiocFileCache R package](https://github.com/Bioconductor/BiocFileCache).
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
Install from [PyPI](https://pypi.org/project/pyBiocFileCache/):
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install pybiocfilecache
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Quick Start
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from pybiocfilecache import BiocFileCache
|
|
76
|
+
|
|
77
|
+
# Initialize cache
|
|
78
|
+
cache = BiocFileCache("path/to/cache/directory")
|
|
79
|
+
|
|
80
|
+
# Add a file to cache
|
|
81
|
+
resource = cache.add("myfile", "path/to/file.txt")
|
|
82
|
+
|
|
83
|
+
# Retrieve a file from cache
|
|
84
|
+
resource = cache.get("myfile")
|
|
85
|
+
|
|
86
|
+
# Use the cached file
|
|
87
|
+
print(resource["rpath"]) # Path to cached file
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Advanced Usage
|
|
91
|
+
|
|
92
|
+
### Configuration
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from datetime import timedelta
|
|
96
|
+
from pathlib import Path
|
|
97
|
+
|
|
98
|
+
from pybiocfilecache import BiocFileCache, CacheConfig
|
|
99
|
+
|
|
100
|
+
# Create custom configuration
|
|
101
|
+
config = CacheConfig(
|
|
102
|
+
cache_dir=Path("cache_directory"),
|
|
103
|
+
cleanup_interval=timedelta(days=7),
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Initialize cache with configuration
|
|
107
|
+
cache = BiocFileCache(config=config)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Resource Management
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from datetime import datetime, timedelta, timezone
|
|
114
|
+
|
|
115
|
+
# Add file with expiration
|
|
116
|
+
resource = cache.add(
|
|
117
|
+
"myfile",
|
|
118
|
+
"path/to/file.txt",
|
|
119
|
+
expires=datetime.now(timezone.utc) + timedelta(days=30),
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# Immediate lookup without waiting on missing files
|
|
123
|
+
record = cache.get(rid="BFC1", wait=False)
|
|
124
|
+
|
|
125
|
+
# List resources
|
|
126
|
+
resources = cache.list_resources()
|
|
127
|
+
|
|
128
|
+
# Search resources (exact or substring match)
|
|
129
|
+
results = cache.search("myfile", field="rname")
|
|
130
|
+
|
|
131
|
+
# Update resource by name or rid
|
|
132
|
+
cache.update("myfile", "path/to/new_file.txt")
|
|
133
|
+
cache.update(rid="BFC1", fpath="path/to/new_file.txt")
|
|
134
|
+
|
|
135
|
+
# Remove resource by name or rid
|
|
136
|
+
cache.remove("myfile")
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Cache Statistics and Maintenance
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
# Get cache statistics
|
|
143
|
+
stats = cache.get_stats()
|
|
144
|
+
print(stats)
|
|
145
|
+
|
|
146
|
+
# Clean up expired resources
|
|
147
|
+
removed_count = cache.cleanup()
|
|
148
|
+
|
|
149
|
+
# Verify integrity of cached files
|
|
150
|
+
valid, invalid = cache.verify_cache()
|
|
151
|
+
|
|
152
|
+
# Purge entire cache
|
|
153
|
+
cache.purge()
|
|
154
|
+
```
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
[](https://pypi.org/project/pyBiocFileCache/)
|
|
2
|
+

|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
# pyBiocFileCache
|
|
6
|
+
|
|
7
|
+
`pyBiocFileCache` is a Python package that provides a file caching system with resource validation, expiration management, and SQLite-backed metadata. Compatible with the [BiocFileCache R package](https://github.com/Bioconductor/BiocFileCache).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Install from [PyPI](https://pypi.org/project/pyBiocFileCache/):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install pybiocfilecache
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from pybiocfilecache import BiocFileCache
|
|
21
|
+
|
|
22
|
+
# Initialize cache
|
|
23
|
+
cache = BiocFileCache("path/to/cache/directory")
|
|
24
|
+
|
|
25
|
+
# Add a file to cache
|
|
26
|
+
resource = cache.add("myfile", "path/to/file.txt")
|
|
27
|
+
|
|
28
|
+
# Retrieve a file from cache
|
|
29
|
+
resource = cache.get("myfile")
|
|
30
|
+
|
|
31
|
+
# Use the cached file
|
|
32
|
+
print(resource["rpath"]) # Path to cached file
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Advanced Usage
|
|
36
|
+
|
|
37
|
+
### Configuration
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from datetime import timedelta
|
|
41
|
+
from pathlib import Path
|
|
42
|
+
|
|
43
|
+
from pybiocfilecache import BiocFileCache, CacheConfig
|
|
44
|
+
|
|
45
|
+
# Create custom configuration
|
|
46
|
+
config = CacheConfig(
|
|
47
|
+
cache_dir=Path("cache_directory"),
|
|
48
|
+
cleanup_interval=timedelta(days=7),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Initialize cache with configuration
|
|
52
|
+
cache = BiocFileCache(config=config)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Resource Management
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from datetime import datetime, timedelta, timezone
|
|
59
|
+
|
|
60
|
+
# Add file with expiration
|
|
61
|
+
resource = cache.add(
|
|
62
|
+
"myfile",
|
|
63
|
+
"path/to/file.txt",
|
|
64
|
+
expires=datetime.now(timezone.utc) + timedelta(days=30),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# Immediate lookup without waiting on missing files
|
|
68
|
+
record = cache.get(rid="BFC1", wait=False)
|
|
69
|
+
|
|
70
|
+
# List resources
|
|
71
|
+
resources = cache.list_resources()
|
|
72
|
+
|
|
73
|
+
# Search resources (exact or substring match)
|
|
74
|
+
results = cache.search("myfile", field="rname")
|
|
75
|
+
|
|
76
|
+
# Update resource by name or rid
|
|
77
|
+
cache.update("myfile", "path/to/new_file.txt")
|
|
78
|
+
cache.update(rid="BFC1", fpath="path/to/new_file.txt")
|
|
79
|
+
|
|
80
|
+
# Remove resource by name or rid
|
|
81
|
+
cache.remove("myfile")
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Cache Statistics and Maintenance
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
# Get cache statistics
|
|
88
|
+
stats = cache.get_stats()
|
|
89
|
+
print(stats)
|
|
90
|
+
|
|
91
|
+
# Clean up expired resources
|
|
92
|
+
removed_count = cache.cleanup()
|
|
93
|
+
|
|
94
|
+
# Verify integrity of cached files
|
|
95
|
+
valid, invalid = cache.verify_cache()
|
|
96
|
+
|
|
97
|
+
# Purge entire cache
|
|
98
|
+
cache.purge()
|
|
99
|
+
```
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pybiocfilecache"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "File based cache for resources and metadata"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Jayaram Kancherla", email = "jayaram.kancherla@gmail.com" },
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"biocframe",
|
|
12
|
+
"sqlalchemy",
|
|
13
|
+
]
|
|
14
|
+
keywords = [
|
|
15
|
+
"biocfilecache",
|
|
16
|
+
"cache",
|
|
17
|
+
"file-cache",
|
|
18
|
+
"sqlite",
|
|
19
|
+
"resource-management",
|
|
20
|
+
]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 4 - Beta",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"Intended Audience :: Science/Research",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
"Operating System :: OS Independent",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.10",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
"Programming Language :: Python :: 3.13",
|
|
32
|
+
"Programming Language :: Python :: 3.14",
|
|
33
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
34
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.license]
|
|
38
|
+
file = "LICENSE.txt"
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/BiocPy/pybiocfilecache"
|
|
42
|
+
Documentation = "https://biocpy.github.io/pybiocfilecache"
|
|
43
|
+
Repository = "https://github.com/BiocPy/pybiocfilecache"
|
|
44
|
+
"Bug Tracker" = "https://github.com/BiocPy/pybiocfilecache/issues"
|
|
45
|
+
|
|
46
|
+
[project.optional-dependencies]
|
|
47
|
+
testing = [
|
|
48
|
+
"pytest",
|
|
49
|
+
"pytest-cov",
|
|
50
|
+
"setuptools",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[build-system]
|
|
54
|
+
requires = ["hatchling", "hatch-vcs"]
|
|
55
|
+
build-backend = "hatchling.build"
|
|
56
|
+
|
|
57
|
+
[tool.hatch.version]
|
|
58
|
+
source = "vcs"
|
|
59
|
+
fallback-version = "0.1.0"
|
|
60
|
+
|
|
61
|
+
[tool.ruff]
|
|
62
|
+
line-length = 120
|
|
63
|
+
src = ["src"]
|
|
64
|
+
exclude = ["tests", "docs"]
|
|
65
|
+
|
|
66
|
+
[tool.ruff.lint]
|
|
67
|
+
extend-ignore = ["F821"]
|
|
68
|
+
|
|
69
|
+
[tool.ruff.lint.pydocstyle]
|
|
70
|
+
convention = "google"
|
|
71
|
+
|
|
72
|
+
[tool.ruff.lint.per-file-ignores]
|
|
73
|
+
"__init__.py" = ["E402", "F401"]
|
|
74
|
+
|
|
75
|
+
[tool.ruff.format]
|
|
76
|
+
docstring-code-format = true
|
|
77
|
+
docstring-code-line-length = 20
|
|
78
|
+
|
|
79
|
+
[tool.mypy]
|
|
80
|
+
strict = true
|
|
81
|
+
|
|
82
|
+
[tool.pytest.ini_options]
|
|
83
|
+
addopts = "--cov=pybiocfilecache --cov-report term-missing"
|
|
84
|
+
testpaths = ["tests"]
|
|
85
|
+
|
|
86
|
+
[tool.bandit]
|
|
87
|
+
exclude_dirs = ["tests"]
|
|
88
|
+
skips = ["B110"]
|