pyBiocFileCache 0.6.0__tar.gz → 0.6.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.
Files changed (44) hide show
  1. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/CHANGELOG.md +6 -0
  2. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/PKG-INFO +2 -2
  3. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/README.md +1 -1
  4. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/changelog.md +6 -0
  5. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/readme.md +1 -1
  6. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pyBiocFileCache.egg-info/PKG-INFO +2 -2
  7. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pyBiocFileCache.egg-info/SOURCES.txt +2 -2
  8. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pybiocfilecache/cache.py +39 -35
  9. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pybiocfilecache/models.py +1 -1
  10. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pybiocfilecache/utils.py +7 -1
  11. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/.coveragerc +0 -0
  12. /pybiocfilecache-0.6.0/.github/workflows/pypi-publish.yml → /pybiocfilecache-0.6.1/.github/workflows/publish-pypi.yml +0 -0
  13. /pybiocfilecache-0.6.0/.github/workflows/pypi-test.yml → /pybiocfilecache-0.6.1/.github/workflows/run-tests.yml +0 -0
  14. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/.gitignore +0 -0
  15. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/.pre-commit-config.yaml +0 -0
  16. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/.readthedocs.yml +0 -0
  17. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/AUTHORS.md +0 -0
  18. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/CONTRIBUTING.rst +0 -0
  19. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/LICENSE.txt +0 -0
  20. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/Makefile +0 -0
  21. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/_static/.gitignore +0 -0
  22. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/authors.md +0 -0
  23. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/best_practices.md +0 -0
  24. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/conf.py +0 -0
  25. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/contributing.rst +0 -0
  26. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/index.md +0 -0
  27. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/license.rst +0 -0
  28. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/docs/requirements.txt +0 -0
  29. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/pyproject.toml +0 -0
  30. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/setup.cfg +0 -0
  31. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/setup.py +0 -0
  32. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pyBiocFileCache.egg-info/dependency_links.txt +0 -0
  33. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pyBiocFileCache.egg-info/not-zip-safe +0 -0
  34. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pyBiocFileCache.egg-info/requires.txt +0 -0
  35. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pyBiocFileCache.egg-info/top_level.txt +0 -0
  36. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pybiocfilecache/__init__.py +0 -0
  37. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pybiocfilecache/config.py +0 -0
  38. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pybiocfilecache/const.py +0 -0
  39. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/src/pybiocfilecache/exceptions.py +0 -0
  40. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/tests/conftest.py +0 -0
  41. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/tests/data/test1.txt +0 -0
  42. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/tests/data/test2.txt +0 -0
  43. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/tests/test_cache.py +0 -0
  44. {pybiocfilecache-0.6.0 → pybiocfilecache-0.6.1}/tox.ini +0 -0
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.6.1
4
+
5
+ - Generate rid's that match with R's cache.
6
+ - remove rname pattern checks.
7
+ - Rename GitHub actions for consistency with the rest of the packages.
8
+
3
9
  ## Version 0.6.0
4
10
 
5
11
  - Reverting schema changes that break compatibility with the R/BiocFileCache implementation.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyBiocFileCache
3
- Version: 0.6.0
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
  [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
25
25
  [![PyPI-Server](https://img.shields.io/pypi/v/pyBiocFileCache.svg)](https://pypi.org/project/pyBiocFileCache/)
26
- ![Unit tests](https://github.com/BiocPy/pyBiocFileCache/actions/workflows/pypi-test.yml/badge.svg)
26
+ ![Unit tests](https://github.com/BiocPy/pyBiocFileCache/actions/workflows/run-tests.yml/badge.svg)
27
27
 
28
28
  # pyBiocFileCache
29
29
 
@@ -1,6 +1,6 @@
1
1
  [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
2
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)
3
+ ![Unit tests](https://github.com/BiocPy/pyBiocFileCache/actions/workflows/run-tests.yml/badge.svg)
4
4
 
5
5
  # pyBiocFileCache
6
6
 
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.6.1
4
+
5
+ - Generate rid's that match with R's cache.
6
+ - remove rname pattern checks.
7
+ - Rename GitHub actions for consistency with the rest of the packages.
8
+
3
9
  ## Version 0.6.0
4
10
 
5
11
  - Reverting schema changes that break compatibility with the R/BiocFileCache implementation.
@@ -1,6 +1,6 @@
1
1
  [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
2
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)
3
+ ![Unit tests](https://github.com/BiocPy/pyBiocFileCache/actions/workflows/run-tests.yml/badge.svg)
4
4
 
5
5
  # pyBiocFileCache
6
6
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyBiocFileCache
3
- Version: 0.6.0
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
  [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
25
25
  [![PyPI-Server](https://img.shields.io/pypi/v/pyBiocFileCache.svg)](https://pypi.org/project/pyBiocFileCache/)
26
- ![Unit tests](https://github.com/BiocPy/pyBiocFileCache/actions/workflows/pypi-test.yml/badge.svg)
26
+ ![Unit tests](https://github.com/BiocPy/pyBiocFileCache/actions/workflows/run-tests.yml/badge.svg)
27
27
 
28
28
  # pyBiocFileCache
29
29
 
@@ -11,8 +11,8 @@ pyproject.toml
11
11
  setup.cfg
12
12
  setup.py
13
13
  tox.ini
14
- .github/workflows/pypi-publish.yml
15
- .github/workflows/pypi-test.yml
14
+ .github/workflows/publish-pypi.yml
15
+ .github/workflows/run-tests.yml
16
16
  docs/Makefile
17
17
  docs/authors.md
18
18
  docs/best_practices.md
@@ -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
- """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()
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()
@@ -73,4 +73,4 @@ class Resource(Base):
73
73
  expires = Column(DateTime, default=None)
74
74
 
75
75
  def __repr__(self) -> str:
76
- return f"<Resource(id='{self.id}', rname='{self.rname}')>"
76
+ return f"<Resource(rid='{self.rid}', rname='{self.rname}')>"
@@ -22,11 +22,17 @@ def create_tmp_dir() -> Path:
22
22
  return Path(tempfile.mkdtemp())
23
23
 
24
24
 
25
- def generate_id() -> str:
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))
File without changes