pyBiocFileCache 0.6.0__py3-none-any.whl → 0.6.1__py3-none-any.whl
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.6.0.dist-info → pyBiocFileCache-0.6.1.dist-info}/METADATA +2 -2
- pyBiocFileCache-0.6.1.dist-info/RECORD +13 -0
- {pyBiocFileCache-0.6.0.dist-info → pyBiocFileCache-0.6.1.dist-info}/WHEEL +1 -1
- pybiocfilecache/cache.py +39 -35
- pybiocfilecache/models.py +1 -1
- pybiocfilecache/utils.py +7 -1
- pyBiocFileCache-0.6.0.dist-info/RECORD +0 -13
- {pyBiocFileCache-0.6.0.dist-info → pyBiocFileCache-0.6.1.dist-info}/AUTHORS.md +0 -0
- {pyBiocFileCache-0.6.0.dist-info → pyBiocFileCache-0.6.1.dist-info}/LICENSE.txt +0 -0
- {pyBiocFileCache-0.6.0.dist-info → pyBiocFileCache-0.6.1.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyBiocFileCache
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.1
|
|
4
4
|
Summary: File based cache for resources and metadata
|
|
5
5
|
Home-page: https://github.com/epiviz/pyBiocFileCache
|
|
6
6
|
Author: jkanche
|
|
@@ -23,7 +23,7 @@ Requires-Dist: pytest-cov; extra == "testing"
|
|
|
23
23
|
|
|
24
24
|
[](https://pyscaffold.org/)
|
|
25
25
|
[](https://pypi.org/project/pyBiocFileCache/)
|
|
26
|
-

|
|
27
27
|
|
|
28
28
|
# pyBiocFileCache
|
|
29
29
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
pybiocfilecache/__init__.py,sha256=kClwDkzgGPYAyDW-fuo5LI4lKCruYJhDHvw0lq9u4b0,652
|
|
2
|
+
pybiocfilecache/cache.py,sha256=cBPQYW4EW5ACRvbWotYJaDkzJpNZhvPC2hPlFd9mAO4,20641
|
|
3
|
+
pybiocfilecache/config.py,sha256=bado4Hg6QFIfV46zKwx6Q9AoV__G-e8fghylnk5I-nk,803
|
|
4
|
+
pybiocfilecache/const.py,sha256=c9167eSCGBp0wF1xuAEvr-fbYCzp0lcOtKF9sqxlLF8,26
|
|
5
|
+
pybiocfilecache/exceptions.py,sha256=8jrnctFYF7Rc1xsITtLUwKKvx8GMoKbarucyc-4f2zI,706
|
|
6
|
+
pybiocfilecache/models.py,sha256=oEQaLB9haWtSnm8DybMoMf8INZ4czxs7jriHv61YCb8,1945
|
|
7
|
+
pybiocfilecache/utils.py,sha256=a2sUcnWzu8F0nwdmun8Ke0hj0-bFJ5JF-Z1tq9NT0NM,2406
|
|
8
|
+
pyBiocFileCache-0.6.1.dist-info/AUTHORS.md,sha256=ptvMLokf9Knfp0Ng-dHSgtEimkXWZhjZAR_o2aJm9bw,161
|
|
9
|
+
pyBiocFileCache-0.6.1.dist-info/LICENSE.txt,sha256=bV5MJ4ezdCnC4yREyxU30iel5hFq8T8kGqobu4Kc-WM,1082
|
|
10
|
+
pyBiocFileCache-0.6.1.dist-info/METADATA,sha256=KhKuU1Dbho0go2sWVpVrrm2WHTDPFn_doktKrqNRdO8,2947
|
|
11
|
+
pyBiocFileCache-0.6.1.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
|
12
|
+
pyBiocFileCache-0.6.1.dist-info/top_level.txt,sha256=_A2QFmYMnsz6WoSRPk1EFMDr5mkQVGx9Xtz2RMv3aF4,16
|
|
13
|
+
pyBiocFileCache-0.6.1.dist-info/RECORD,,
|
pybiocfilecache/cache.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import json
|
|
2
1
|
import logging
|
|
3
2
|
from contextlib import contextmanager
|
|
4
3
|
from datetime import datetime
|
|
@@ -108,6 +107,7 @@ class BiocFileCache:
|
|
|
108
107
|
"""),
|
|
109
108
|
{"version": SCHEMA_VERSION},
|
|
110
109
|
)
|
|
110
|
+
conn.commit()
|
|
111
111
|
|
|
112
112
|
return SCHEMA_VERSION
|
|
113
113
|
|
|
@@ -263,7 +263,7 @@ class BiocFileCache:
|
|
|
263
263
|
Returns:
|
|
264
264
|
The `Resource` object added to the cache.
|
|
265
265
|
"""
|
|
266
|
-
self._validate_rname(rname)
|
|
266
|
+
# self._validate_rname(rname)
|
|
267
267
|
fpath = Path(fpath)
|
|
268
268
|
|
|
269
269
|
if not fpath.exists():
|
|
@@ -273,7 +273,7 @@ class BiocFileCache:
|
|
|
273
273
|
raise RnameExistsError(f"Resource '{rname}' already exists")
|
|
274
274
|
|
|
275
275
|
# Generate paths and check size
|
|
276
|
-
rid = generate_id()
|
|
276
|
+
rid = generate_id(size=len(self))
|
|
277
277
|
rpath = self.config.cache_dir / f"{rid}{fpath.suffix if ext else ''}" if action != "asis" else fpath
|
|
278
278
|
|
|
279
279
|
# Create resource record
|
|
@@ -459,38 +459,38 @@ class BiocFileCache:
|
|
|
459
459
|
logger.error(f"Failed to validate resource: {resource.rname}", exc_info=e)
|
|
460
460
|
return False
|
|
461
461
|
|
|
462
|
-
def export_metadata(self, path: Path) -> None:
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
def import_metadata(self, path: Path) -> None:
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
462
|
+
# def export_metadata(self, path: Path) -> None:
|
|
463
|
+
# """Export cache metadata to JSON file."""
|
|
464
|
+
# data = {
|
|
465
|
+
# "resources": [
|
|
466
|
+
# {
|
|
467
|
+
# "rname": r.rname,
|
|
468
|
+
# "rtype": r.rtype,
|
|
469
|
+
# "expires": r.expires.isoformat() if r.expires else None,
|
|
470
|
+
# "etag": r.etag,
|
|
471
|
+
# }
|
|
472
|
+
# for r in self.list_resources()
|
|
473
|
+
# ],
|
|
474
|
+
# "export_time": datetime.now().isoformat(),
|
|
475
|
+
# }
|
|
476
|
+
|
|
477
|
+
# with open(path, "w") as f:
|
|
478
|
+
# json.dump(data, f, indent=2)
|
|
479
|
+
|
|
480
|
+
# def import_metadata(self, path: Path) -> None:
|
|
481
|
+
# """Import cache metadata from JSON file."""
|
|
482
|
+
# with open(path) as f:
|
|
483
|
+
# data = json.load(f)
|
|
484
|
+
|
|
485
|
+
# with self.get_session() as session:
|
|
486
|
+
# for resource_data in data["resources"]:
|
|
487
|
+
# resource = self._get(session, resource_data["rname"])
|
|
488
|
+
# if resource:
|
|
489
|
+
# resource.expires = (
|
|
490
|
+
# datetime.fromisoformat(resource_data["expires"]) if resource_data["expires"] else None
|
|
491
|
+
# )
|
|
492
|
+
# session.merge(resource)
|
|
493
|
+
# session.commit()
|
|
494
494
|
|
|
495
495
|
def verify_cache(self) -> Tuple[int, int]:
|
|
496
496
|
"""Verify integrity of all cached resources.
|
|
@@ -612,3 +612,7 @@ class BiocFileCache:
|
|
|
612
612
|
logger.warning(f"Failed to remove {file}: {file_e}")
|
|
613
613
|
|
|
614
614
|
return False
|
|
615
|
+
|
|
616
|
+
def __len__(self):
|
|
617
|
+
with self.get_session() as session:
|
|
618
|
+
return session.query(Resource).count()
|
pybiocfilecache/models.py
CHANGED
pybiocfilecache/utils.py
CHANGED
|
@@ -22,11 +22,17 @@ def create_tmp_dir() -> Path:
|
|
|
22
22
|
return Path(tempfile.mkdtemp())
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def
|
|
25
|
+
def generate_uuid() -> str:
|
|
26
26
|
"""Generate unique identifier."""
|
|
27
27
|
return uuid.uuid4().hex
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
def generate_id(size) -> str:
|
|
31
|
+
"""Generate unique identifier."""
|
|
32
|
+
size += 1
|
|
33
|
+
return "BFC" + str(size)
|
|
34
|
+
|
|
35
|
+
|
|
30
36
|
def validate_rname(rname: str, pattern: str) -> bool:
|
|
31
37
|
"""Validate resource name format."""
|
|
32
38
|
return bool(re.match(pattern, rname))
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
pybiocfilecache/__init__.py,sha256=kClwDkzgGPYAyDW-fuo5LI4lKCruYJhDHvw0lq9u4b0,652
|
|
2
|
-
pybiocfilecache/cache.py,sha256=N1xJFCDFINvWxDKwO7ibPiFOJHQOTlr_IV6UrxIW8Bk,20434
|
|
3
|
-
pybiocfilecache/config.py,sha256=bado4Hg6QFIfV46zKwx6Q9AoV__G-e8fghylnk5I-nk,803
|
|
4
|
-
pybiocfilecache/const.py,sha256=c9167eSCGBp0wF1xuAEvr-fbYCzp0lcOtKF9sqxlLF8,26
|
|
5
|
-
pybiocfilecache/exceptions.py,sha256=8jrnctFYF7Rc1xsITtLUwKKvx8GMoKbarucyc-4f2zI,706
|
|
6
|
-
pybiocfilecache/models.py,sha256=inFECbprbU6W67XAkx8-Wbj3p57PdVlerb1SRvp1WlY,1943
|
|
7
|
-
pybiocfilecache/utils.py,sha256=lBK4BmzT6Z7XCn4j8kmhz9BPQpWT-RYfWvWC7YNtIGM,2291
|
|
8
|
-
pyBiocFileCache-0.6.0.dist-info/AUTHORS.md,sha256=ptvMLokf9Knfp0Ng-dHSgtEimkXWZhjZAR_o2aJm9bw,161
|
|
9
|
-
pyBiocFileCache-0.6.0.dist-info/LICENSE.txt,sha256=bV5MJ4ezdCnC4yREyxU30iel5hFq8T8kGqobu4Kc-WM,1082
|
|
10
|
-
pyBiocFileCache-0.6.0.dist-info/METADATA,sha256=xFfkcCK-paxNVnt02VWdvxO39zgUkorb5cCp8usgWG4,2947
|
|
11
|
-
pyBiocFileCache-0.6.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
12
|
-
pyBiocFileCache-0.6.0.dist-info/top_level.txt,sha256=_A2QFmYMnsz6WoSRPk1EFMDr5mkQVGx9Xtz2RMv3aF4,16
|
|
13
|
-
pyBiocFileCache-0.6.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|