pyBiocFileCache 0.4.0__tar.gz → 0.5.0__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.
Files changed (55) hide show
  1. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/.github/workflows/pypi-test.yml +2 -2
  2. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/.pre-commit-config.yaml +14 -13
  3. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/AUTHORS.md +1 -1
  4. pybiocfilecache-0.5.0/CHANGELOG.md +29 -0
  5. pybiocfilecache-0.5.0/PKG-INFO +116 -0
  6. pybiocfilecache-0.5.0/README.md +94 -0
  7. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/docs/authors.md +1 -1
  8. pybiocfilecache-0.5.0/docs/best_practices.md +28 -0
  9. pybiocfilecache-0.5.0/docs/changelog.md +29 -0
  10. pybiocfilecache-0.5.0/docs/readme.md +94 -0
  11. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/setup.cfg +1 -1
  12. pybiocfilecache-0.5.0/src/pyBiocFileCache.egg-info/PKG-INFO +116 -0
  13. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/src/pyBiocFileCache.egg-info/SOURCES.txt +5 -4
  14. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/src/pyBiocFileCache.egg-info/requires.txt +1 -1
  15. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/src/pybiocfilecache/__init__.py +1 -8
  16. pybiocfilecache-0.5.0/src/pybiocfilecache/cache.py +633 -0
  17. pybiocfilecache-0.5.0/src/pybiocfilecache/config.py +42 -0
  18. pybiocfilecache-0.5.0/src/pybiocfilecache/exceptions.py +31 -0
  19. pybiocfilecache-0.5.0/src/pybiocfilecache/models.py +84 -0
  20. pybiocfilecache-0.5.0/src/pybiocfilecache/utils.py +83 -0
  21. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/tests/conftest.py +3 -3
  22. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/tests/test_cache.py +11 -4
  23. pybiocfilecache-0.4.0/CHANGELOG.md +0 -9
  24. pybiocfilecache-0.4.0/PKG-INFO +0 -99
  25. pybiocfilecache-0.4.0/README.md +0 -77
  26. pybiocfilecache-0.4.0/docs/changelog.md +0 -9
  27. pybiocfilecache-0.4.0/docs/readme.md +0 -77
  28. pybiocfilecache-0.4.0/src/pyBiocFileCache.egg-info/PKG-INFO +0 -99
  29. pybiocfilecache-0.4.0/src/pybiocfilecache/BiocFileCache.py +0 -276
  30. pybiocfilecache-0.4.0/src/pybiocfilecache/_exceptions.py +0 -15
  31. pybiocfilecache-0.4.0/src/pybiocfilecache/db/__init__.py +0 -5
  32. pybiocfilecache-0.4.0/src/pybiocfilecache/db/db_config.py +0 -84
  33. pybiocfilecache-0.4.0/src/pybiocfilecache/utils.py +0 -89
  34. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/.coveragerc +0 -0
  35. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/.github/workflows/pypi-publish.yml +0 -0
  36. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/.gitignore +0 -0
  37. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/.readthedocs.yml +0 -0
  38. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/CONTRIBUTING.rst +0 -0
  39. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/LICENSE.txt +0 -0
  40. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/docs/Makefile +0 -0
  41. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/docs/_static/.gitignore +0 -0
  42. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/docs/conf.py +0 -0
  43. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/docs/contributing.rst +0 -0
  44. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/docs/index.md +0 -0
  45. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/docs/license.rst +0 -0
  46. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/docs/requirements.txt +0 -0
  47. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/pyproject.toml +0 -0
  48. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/setup.py +0 -0
  49. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/src/pyBiocFileCache.egg-info/dependency_links.txt +0 -0
  50. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/src/pyBiocFileCache.egg-info/not-zip-safe +0 -0
  51. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/src/pyBiocFileCache.egg-info/top_level.txt +0 -0
  52. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/src/pybiocfilecache/const.py +0 -0
  53. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/tests/data/test1.txt +0 -0
  54. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/tests/data/test2.txt +0 -0
  55. {pybiocfilecache-0.4.0 → pybiocfilecache-0.5.0}/tox.ini +0 -0
@@ -5,9 +5,9 @@ name: Test the library
5
5
 
6
6
  on:
7
7
  push:
8
- branches: [ main ]
8
+ branches: [ master ]
9
9
  pull_request:
10
- branches: [ main ]
10
+ branches: [ master ]
11
11
 
12
12
  jobs:
13
13
  build:
@@ -17,26 +17,27 @@ repos:
17
17
  - id: mixed-line-ending
18
18
  args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows
19
19
 
20
- - repo: https://github.com/PyCQA/docformatter
21
- rev: v1.7.5
22
- hooks:
23
- - id: docformatter
24
- additional_dependencies: [tomli]
25
- args: [--in-place, --wrap-descriptions=120, --wrap-summaries=120]
26
- # --config, ./pyproject.toml
20
+ # - repo: https://github.com/PyCQA/docformatter
21
+ # rev: master
22
+ # hooks:
23
+ # - id: docformatter
24
+ # additional_dependencies: [tomli]
25
+ # args: [--in-place, --wrap-descriptions=120, --wrap-summaries=120]
26
+ # # --config, ./pyproject.toml
27
27
 
28
- - repo: https://github.com/psf/black
29
- rev: 24.4.0
30
- hooks:
31
- - id: black
32
- language_version: python3
28
+ # - repo: https://github.com/psf/black
29
+ # rev: 24.8.0
30
+ # hooks:
31
+ # - id: black
32
+ # language_version: python3
33
33
 
34
34
  - repo: https://github.com/astral-sh/ruff-pre-commit
35
35
  # Ruff version.
36
- rev: v0.3.7
36
+ rev: v0.6.8
37
37
  hooks:
38
38
  - id: ruff
39
39
  args: [--fix, --exit-non-zero-on-fix]
40
+ - id: ruff-format
40
41
 
41
42
  ## If like to embrace black styles even in the docs:
42
43
  # - repo: https://github.com/asottile/blacken-docs
@@ -2,4 +2,4 @@
2
2
 
3
3
  * Jayaram Kancherla <jayaram.kancherla@gmail.com>
4
4
  * Max Hargreaves <max_hargreaves@outlook.com>
5
- * Oleksandr Khoroshevskyi <khorosh@virginia.edu>
5
+ * Oleksandr Khoroshevskyi <khorosh@virginia.edu>
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## Version 0.5.0
4
+
5
+ - SQLAlchemy session management
6
+ * Implemented proper session handling
7
+ * Fixed `DetachedInstanceError` issues and added helper method `_get_detached_resource` for consistent session management
8
+ * Improved transaction handling with commits and rollbacks
9
+
10
+ - New features
11
+ * Added cache statistics with `get_stats()` method
12
+ * Implemented resource tagging
13
+ * Added cache size management
14
+ * Added support for file compression
15
+ * Added resource validation with checksums
16
+ * Improved search
17
+ * Added metadata export/import functionality
18
+
19
+ ## Version 0.4.1
20
+
21
+ - Method to list all resources.
22
+
23
+ ## Version 0.4
24
+
25
+ - 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.
26
+
27
+ ## Version 0.1
28
+
29
+ - Initial release of the package, Setting up all the actions.
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyBiocFileCache
3
+ Version: 0.5.0
4
+ Summary: File based cache for resources and metadata
5
+ Home-page: https://github.com/epiviz/pyBiocFileCache
6
+ Author: jkanche
7
+ Author-email: jayaram.kancherla@gmail.com
8
+ License: MIT
9
+ Project-URL: Documentation, https://pyscaffold.org/
10
+ Platform: any
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Programming Language :: Python
13
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
14
+ License-File: LICENSE.txt
15
+ License-File: AUTHORS.md
16
+ Requires-Dist: importlib-metadata; python_version < "3.8"
17
+ Requires-Dist: sqlalchemy
18
+ Provides-Extra: testing
19
+ Requires-Dist: setuptools; extra == "testing"
20
+ Requires-Dist: pytest; extra == "testing"
21
+ Requires-Dist: pytest-cov; extra == "testing"
22
+
23
+ [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
24
+ [![PyPI-Server](https://img.shields.io/pypi/v/pyBiocFileCache.svg)](https://pypi.org/project/pyBiocFileCache/)
25
+ ![Unit tests](https://github.com/BiocPy/pyBiocFileCache/actions/workflows/pypi-test.yml/badge.svg)
26
+
27
+ # pyBiocFileCache
28
+
29
+ `pyBiocFileCache` is a Python package that provides a robust file caching system with resource validation, cache size management, file compression, and resource tagging. Compatible with [BiocFileCache R package](https://github.com/Bioconductor/BiocFileCache).
30
+
31
+ ## Installation
32
+
33
+ Install from [PyPI](https://pypi.org/project/pyBiocFileCache/),
34
+
35
+ ```bash
36
+ pip install pybiocfilecache
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ```python
42
+ from biocfilecache import BiocFileCache
43
+
44
+ # Initialize cache
45
+ cache = BiocFileCache("path/to/cache/directory")
46
+
47
+ # Add a file to cache
48
+ resource = cache.add("myfile", "path/to/file.txt")
49
+
50
+ # Retrieve a file from cache
51
+ resource = cache.get("myfile")
52
+
53
+ # Use the cached file
54
+ print(resource.rpath) # Path to cached file
55
+ ```
56
+
57
+ ## Advanced Usage
58
+
59
+ ### Configuration
60
+
61
+ ```python
62
+ from biocfilecache import BiocFileCache, CacheConfig
63
+ from datetime import timedelta
64
+ from pathlib import Path
65
+
66
+ # Create custom configuration
67
+ config = CacheConfig(
68
+ cache_dir=Path("cache_directory"),
69
+ max_size_bytes=1024 * 1024 * 1024, # 1GB
70
+ cleanup_interval=timedelta(days=7),
71
+ compression=True
72
+ )
73
+
74
+ # Initialize cache with configuration
75
+ cache = BiocFileCache(config=config)
76
+ ```
77
+
78
+ ### Resource Management
79
+
80
+ ```python
81
+ # Add file with tags and expiration
82
+ from datetime import datetime, timedelta
83
+
84
+ resource = cache.add(
85
+ "myfile",
86
+ "path/to/file.txt",
87
+ tags=["data", "raw"],
88
+ expires=datetime.now() + timedelta(days=30)
89
+ )
90
+
91
+ # List resources by tag
92
+ resources = cache.list_resources(tag="data")
93
+
94
+ # Search resources
95
+ results = cache.search("myfile", field="rname")
96
+
97
+ # Update resource
98
+ cache.update("myfile", "path/to/new_file.txt")
99
+
100
+ # Remove resource
101
+ cache.remove("myfile")
102
+ ```
103
+
104
+ ### Cache Statistics and Maintenance
105
+
106
+ ```python
107
+ # Get cache statistics
108
+ stats = cache.get_stats()
109
+ print(stats)
110
+
111
+ # Clean up expired resources
112
+ removed_count = cache.cleanup()
113
+
114
+ # Purge entire cache
115
+ cache.purge()
116
+ ```
@@ -0,0 +1,94 @@
1
+ [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
2
+ [![PyPI-Server](https://img.shields.io/pypi/v/pyBiocFileCache.svg)](https://pypi.org/project/pyBiocFileCache/)
3
+ ![Unit tests](https://github.com/BiocPy/pyBiocFileCache/actions/workflows/pypi-test.yml/badge.svg)
4
+
5
+ # pyBiocFileCache
6
+
7
+ `pyBiocFileCache` is a Python package that provides a robust file caching system with resource validation, cache size management, file compression, and resource tagging. Compatible with [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 biocfilecache 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 biocfilecache import BiocFileCache, CacheConfig
41
+ from datetime import timedelta
42
+ from pathlib import Path
43
+
44
+ # Create custom configuration
45
+ config = CacheConfig(
46
+ cache_dir=Path("cache_directory"),
47
+ max_size_bytes=1024 * 1024 * 1024, # 1GB
48
+ cleanup_interval=timedelta(days=7),
49
+ compression=True
50
+ )
51
+
52
+ # Initialize cache with configuration
53
+ cache = BiocFileCache(config=config)
54
+ ```
55
+
56
+ ### Resource Management
57
+
58
+ ```python
59
+ # Add file with tags and expiration
60
+ from datetime import datetime, timedelta
61
+
62
+ resource = cache.add(
63
+ "myfile",
64
+ "path/to/file.txt",
65
+ tags=["data", "raw"],
66
+ expires=datetime.now() + timedelta(days=30)
67
+ )
68
+
69
+ # List resources by tag
70
+ resources = cache.list_resources(tag="data")
71
+
72
+ # Search resources
73
+ results = cache.search("myfile", field="rname")
74
+
75
+ # Update resource
76
+ cache.update("myfile", "path/to/new_file.txt")
77
+
78
+ # Remove resource
79
+ cache.remove("myfile")
80
+ ```
81
+
82
+ ### Cache Statistics and Maintenance
83
+
84
+ ```python
85
+ # Get cache statistics
86
+ stats = cache.get_stats()
87
+ print(stats)
88
+
89
+ # Clean up expired resources
90
+ removed_count = cache.cleanup()
91
+
92
+ # Purge entire cache
93
+ cache.purge()
94
+ ```
@@ -2,4 +2,4 @@
2
2
 
3
3
  * Jayaram Kancherla <jayaram.kancherla@gmail.com>
4
4
  * Max Hargreaves <max_hargreaves@outlook.com>
5
- * Oleksandr Khoroshevskyi <khorosh@virginia.edu>
5
+ * Oleksandr Khoroshevskyi <khorosh@virginia.edu>
@@ -0,0 +1,28 @@
1
+ # Best Practices
2
+
3
+ 1. Use context managers for cleanup:
4
+ ```python
5
+ with BiocFileCache("cache_directory") as cache:
6
+ cache.add("myfile", "path/to/file.txt")
7
+ ```
8
+
9
+ 2. Add tags for better organization:
10
+ ```python
11
+ cache.add("data.csv", "data.csv", tags=["raw", "csv", "2024"])
12
+ ```
13
+
14
+ 3. Set expiration dates for temporary files:
15
+ ```python
16
+ cache.add("temp.txt", "temp.txt", expires=datetime.now() + timedelta(hours=1))
17
+ ```
18
+
19
+ 4. Regular maintenance:
20
+ ```python
21
+ # Periodically clean up expired resources
22
+ cache.cleanup()
23
+
24
+ # Monitor cache size
25
+ stats = cache.get_stats()
26
+ if stats["cache_size_bytes"] > threshold:
27
+ # Take action
28
+ ```
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## Version 0.5.0
4
+
5
+ - SQLAlchemy session management
6
+ * Implemented proper session handling
7
+ * Fixed `DetachedInstanceError` issues and added helper method `_get_detached_resource` for consistent session management
8
+ * Improved transaction handling with commits and rollbacks
9
+
10
+ - New features
11
+ * Added cache statistics with `get_stats()` method
12
+ * Implemented resource tagging
13
+ * Added cache size management
14
+ * Added support for file compression
15
+ * Added resource validation with checksums
16
+ * Improved search
17
+ * Added metadata export/import functionality
18
+
19
+ ## Version 0.4.1
20
+
21
+ - Method to list all resources.
22
+
23
+ ## Version 0.4
24
+
25
+ - 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.
26
+
27
+ ## Version 0.1
28
+
29
+ - Initial release of the package, Setting up all the actions.
@@ -0,0 +1,94 @@
1
+ [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
2
+ [![PyPI-Server](https://img.shields.io/pypi/v/pyBiocFileCache.svg)](https://pypi.org/project/pyBiocFileCache/)
3
+ ![Unit tests](https://github.com/BiocPy/pyBiocFileCache/actions/workflows/pypi-test.yml/badge.svg)
4
+
5
+ # pyBiocFileCache
6
+
7
+ `pyBiocFileCache` is a Python package that provides a robust file caching system with resource validation, cache size management, file compression, and resource tagging. Compatible with [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 biocfilecache 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 biocfilecache import BiocFileCache, CacheConfig
41
+ from datetime import timedelta
42
+ from pathlib import Path
43
+
44
+ # Create custom configuration
45
+ config = CacheConfig(
46
+ cache_dir=Path("cache_directory"),
47
+ max_size_bytes=1024 * 1024 * 1024, # 1GB
48
+ cleanup_interval=timedelta(days=7),
49
+ compression=True
50
+ )
51
+
52
+ # Initialize cache with configuration
53
+ cache = BiocFileCache(config=config)
54
+ ```
55
+
56
+ ### Resource Management
57
+
58
+ ```python
59
+ # Add file with tags and expiration
60
+ from datetime import datetime, timedelta
61
+
62
+ resource = cache.add(
63
+ "myfile",
64
+ "path/to/file.txt",
65
+ tags=["data", "raw"],
66
+ expires=datetime.now() + timedelta(days=30)
67
+ )
68
+
69
+ # List resources by tag
70
+ resources = cache.list_resources(tag="data")
71
+
72
+ # Search resources
73
+ results = cache.search("myfile", field="rname")
74
+
75
+ # Update resource
76
+ cache.update("myfile", "path/to/new_file.txt")
77
+
78
+ # Remove resource
79
+ cache.remove("myfile")
80
+ ```
81
+
82
+ ### Cache Statistics and Maintenance
83
+
84
+ ```python
85
+ # Get cache statistics
86
+ stats = cache.get_stats()
87
+ print(stats)
88
+
89
+ # Clean up expired resources
90
+ removed_count = cache.cleanup()
91
+
92
+ # Purge entire cache
93
+ cache.purge()
94
+ ```
@@ -22,7 +22,7 @@ package_dir =
22
22
  =src
23
23
  install_requires =
24
24
  importlib-metadata; python_version<"3.8"
25
- sqlalchemy>=2,<2.1
25
+ sqlalchemy
26
26
 
27
27
  [options.packages.find]
28
28
  where = src
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.1
2
+ Name: pyBiocFileCache
3
+ Version: 0.5.0
4
+ Summary: File based cache for resources and metadata
5
+ Home-page: https://github.com/epiviz/pyBiocFileCache
6
+ Author: jkanche
7
+ Author-email: jayaram.kancherla@gmail.com
8
+ License: MIT
9
+ Project-URL: Documentation, https://pyscaffold.org/
10
+ Platform: any
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Programming Language :: Python
13
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
14
+ License-File: LICENSE.txt
15
+ License-File: AUTHORS.md
16
+ Requires-Dist: importlib-metadata; python_version < "3.8"
17
+ Requires-Dist: sqlalchemy
18
+ Provides-Extra: testing
19
+ Requires-Dist: setuptools; extra == "testing"
20
+ Requires-Dist: pytest; extra == "testing"
21
+ Requires-Dist: pytest-cov; extra == "testing"
22
+
23
+ [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
24
+ [![PyPI-Server](https://img.shields.io/pypi/v/pyBiocFileCache.svg)](https://pypi.org/project/pyBiocFileCache/)
25
+ ![Unit tests](https://github.com/BiocPy/pyBiocFileCache/actions/workflows/pypi-test.yml/badge.svg)
26
+
27
+ # pyBiocFileCache
28
+
29
+ `pyBiocFileCache` is a Python package that provides a robust file caching system with resource validation, cache size management, file compression, and resource tagging. Compatible with [BiocFileCache R package](https://github.com/Bioconductor/BiocFileCache).
30
+
31
+ ## Installation
32
+
33
+ Install from [PyPI](https://pypi.org/project/pyBiocFileCache/),
34
+
35
+ ```bash
36
+ pip install pybiocfilecache
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ```python
42
+ from biocfilecache import BiocFileCache
43
+
44
+ # Initialize cache
45
+ cache = BiocFileCache("path/to/cache/directory")
46
+
47
+ # Add a file to cache
48
+ resource = cache.add("myfile", "path/to/file.txt")
49
+
50
+ # Retrieve a file from cache
51
+ resource = cache.get("myfile")
52
+
53
+ # Use the cached file
54
+ print(resource.rpath) # Path to cached file
55
+ ```
56
+
57
+ ## Advanced Usage
58
+
59
+ ### Configuration
60
+
61
+ ```python
62
+ from biocfilecache import BiocFileCache, CacheConfig
63
+ from datetime import timedelta
64
+ from pathlib import Path
65
+
66
+ # Create custom configuration
67
+ config = CacheConfig(
68
+ cache_dir=Path("cache_directory"),
69
+ max_size_bytes=1024 * 1024 * 1024, # 1GB
70
+ cleanup_interval=timedelta(days=7),
71
+ compression=True
72
+ )
73
+
74
+ # Initialize cache with configuration
75
+ cache = BiocFileCache(config=config)
76
+ ```
77
+
78
+ ### Resource Management
79
+
80
+ ```python
81
+ # Add file with tags and expiration
82
+ from datetime import datetime, timedelta
83
+
84
+ resource = cache.add(
85
+ "myfile",
86
+ "path/to/file.txt",
87
+ tags=["data", "raw"],
88
+ expires=datetime.now() + timedelta(days=30)
89
+ )
90
+
91
+ # List resources by tag
92
+ resources = cache.list_resources(tag="data")
93
+
94
+ # Search resources
95
+ results = cache.search("myfile", field="rname")
96
+
97
+ # Update resource
98
+ cache.update("myfile", "path/to/new_file.txt")
99
+
100
+ # Remove resource
101
+ cache.remove("myfile")
102
+ ```
103
+
104
+ ### Cache Statistics and Maintenance
105
+
106
+ ```python
107
+ # Get cache statistics
108
+ stats = cache.get_stats()
109
+ print(stats)
110
+
111
+ # Clean up expired resources
112
+ removed_count = cache.cleanup()
113
+
114
+ # Purge entire cache
115
+ cache.purge()
116
+ ```
@@ -15,6 +15,7 @@ tox.ini
15
15
  .github/workflows/pypi-test.yml
16
16
  docs/Makefile
17
17
  docs/authors.md
18
+ docs/best_practices.md
18
19
  docs/changelog.md
19
20
  docs/conf.py
20
21
  docs/contributing.rst
@@ -29,13 +30,13 @@ src/pyBiocFileCache.egg-info/dependency_links.txt
29
30
  src/pyBiocFileCache.egg-info/not-zip-safe
30
31
  src/pyBiocFileCache.egg-info/requires.txt
31
32
  src/pyBiocFileCache.egg-info/top_level.txt
32
- src/pybiocfilecache/BiocFileCache.py
33
33
  src/pybiocfilecache/__init__.py
34
- src/pybiocfilecache/_exceptions.py
34
+ src/pybiocfilecache/cache.py
35
+ src/pybiocfilecache/config.py
35
36
  src/pybiocfilecache/const.py
37
+ src/pybiocfilecache/exceptions.py
38
+ src/pybiocfilecache/models.py
36
39
  src/pybiocfilecache/utils.py
37
- src/pybiocfilecache/db/__init__.py
38
- src/pybiocfilecache/db/db_config.py
39
40
  tests/conftest.py
40
41
  tests/test_cache.py
41
42
  tests/data/test1.txt
@@ -1,4 +1,4 @@
1
- sqlalchemy<2.1,>=2
1
+ sqlalchemy
2
2
 
3
3
  [:python_version < "3.8"]
4
4
  importlib-metadata
@@ -15,11 +15,4 @@ except PackageNotFoundError: # pragma: no cover
15
15
  finally:
16
16
  del version, PackageNotFoundError
17
17
 
18
- from .BiocFileCache import BiocFileCache as BiocFileCache
19
-
20
- from .db.db_config import Metadata as Metadata
21
- from .db.db_config import Resource as Resource
22
-
23
- from ._exceptions import NoFpathError as NoFpathError
24
- from ._exceptions import RnameExistsError as RnameExistsError
25
- from ._exceptions import RpathTimeoutError as RpathTimeoutError
18
+ from .cache import BiocFileCache