pyBiocFileCache 0.5.1__tar.gz → 0.6.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 (46) hide show
  1. pybiocfilecache-0.6.0/.github/workflows/pypi-publish.yml +52 -0
  2. pybiocfilecache-0.6.0/.github/workflows/pypi-test.yml +33 -0
  3. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/.gitignore +3 -0
  4. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/CHANGELOG.md +10 -0
  5. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/PKG-INFO +2 -3
  6. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/README.md +0 -2
  7. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/changelog.md +10 -0
  8. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/conf.py +9 -0
  9. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/readme.md +0 -2
  10. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/requirements.txt +1 -0
  11. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/pyproject.toml +4 -0
  12. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/setup.cfg +1 -0
  13. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pyBiocFileCache.egg-info/PKG-INFO +2 -3
  14. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pybiocfilecache/cache.py +36 -55
  15. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pybiocfilecache/config.py +0 -9
  16. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pybiocfilecache/models.py +6 -14
  17. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/tests/test_cache.py +1 -1
  18. pybiocfilecache-0.5.1/.github/workflows/pypi-publish.yml +0 -51
  19. pybiocfilecache-0.5.1/.github/workflows/pypi-test.yml +0 -40
  20. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/.coveragerc +0 -0
  21. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/.pre-commit-config.yaml +0 -0
  22. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/.readthedocs.yml +0 -0
  23. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/AUTHORS.md +0 -0
  24. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/CONTRIBUTING.rst +0 -0
  25. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/LICENSE.txt +0 -0
  26. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/Makefile +0 -0
  27. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/_static/.gitignore +0 -0
  28. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/authors.md +0 -0
  29. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/best_practices.md +0 -0
  30. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/contributing.rst +0 -0
  31. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/index.md +0 -0
  32. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/docs/license.rst +0 -0
  33. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/setup.py +0 -0
  34. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pyBiocFileCache.egg-info/SOURCES.txt +0 -0
  35. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pyBiocFileCache.egg-info/dependency_links.txt +0 -0
  36. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pyBiocFileCache.egg-info/not-zip-safe +0 -0
  37. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pyBiocFileCache.egg-info/requires.txt +0 -0
  38. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pyBiocFileCache.egg-info/top_level.txt +0 -0
  39. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pybiocfilecache/__init__.py +0 -0
  40. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pybiocfilecache/const.py +0 -0
  41. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pybiocfilecache/exceptions.py +0 -0
  42. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/src/pybiocfilecache/utils.py +0 -0
  43. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/tests/conftest.py +0 -0
  44. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/tests/data/test1.txt +0 -0
  45. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/tests/data/test2.txt +0 -0
  46. {pybiocfilecache-0.5.1 → pybiocfilecache-0.6.0}/tox.ini +0 -0
@@ -0,0 +1,52 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a single version of Python
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3
+
4
+ name: Publish to PyPI
5
+
6
+ on:
7
+ push:
8
+ tags: "*"
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python 3.11
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: 3.11
21
+
22
+ - name: Install dependencies
23
+ run: |
24
+ python -m pip install --upgrade pip
25
+ pip install tox
26
+
27
+ - name: Test with tox
28
+ run: |
29
+ tox
30
+
31
+ - name: Build docs
32
+ run: |
33
+ tox -e docs
34
+
35
+ - run: touch ./docs/_build/html/.nojekyll
36
+
37
+ - name: GH Pages Deployment
38
+ uses: JamesIves/github-pages-deploy-action@v4
39
+ with:
40
+ branch: gh-pages # The branch the action should deploy to.
41
+ folder: ./docs/_build/html
42
+ clean: true # Automatically remove deleted files from the deploy branch
43
+
44
+ - name: Build Project and Publish
45
+ run: |
46
+ python -m tox -e clean,build
47
+
48
+ - name: Publish package
49
+ uses: pypa/gh-action-pypi-publish@v1.12.2
50
+ with:
51
+ user: __token__
52
+ password: ${{ secrets.PYPI_PASSWORD }}
@@ -0,0 +1,33 @@
1
+ name: Run tests
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15
+
16
+ name: Python ${{ matrix.python-version }}
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Setup Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ cache: "pip"
25
+
26
+ - name: Install dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ pip install tox
30
+
31
+ - name: Test with tox
32
+ run: |
33
+ tox
@@ -51,3 +51,6 @@ MANIFEST
51
51
  # Per-project virtualenvs
52
52
  .venv*/
53
53
  .conda*/
54
+
55
+ # remove cache
56
+ cache
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.6.0
4
+
5
+ - Reverting schema changes that break compatibility with the R/BiocFileCache implementation.
6
+ - Added support for Python 3.13
7
+
8
+ ## Version 0.5.5
9
+
10
+ - chore: Remove Python 3.8 (EOL).
11
+ - precommit: Replace docformatter with ruff's formatter.
12
+
3
13
  ## Version 0.5.0
4
14
 
5
15
  - SQLAlchemy session management
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyBiocFileCache
3
- Version: 0.5.1
3
+ Version: 0.6.0
4
4
  Summary: File based cache for resources and metadata
5
5
  Home-page: https://github.com/epiviz/pyBiocFileCache
6
6
  Author: jkanche
@@ -10,6 +10,7 @@ Project-URL: Documentation, https://pyscaffold.org/
10
10
  Platform: any
11
11
  Classifier: Development Status :: 4 - Beta
12
12
  Classifier: Programming Language :: Python
13
+ Requires-Python: >=3.9
13
14
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
14
15
  License-File: LICENSE.txt
15
16
  License-File: AUTHORS.md
@@ -66,9 +67,7 @@ from pathlib import Path
66
67
  # Create custom configuration
67
68
  config = CacheConfig(
68
69
  cache_dir=Path("cache_directory"),
69
- max_size_bytes=1024 * 1024 * 1024, # 1GB
70
70
  cleanup_interval=timedelta(days=7),
71
- compression=True
72
71
  )
73
72
 
74
73
  # Initialize cache with configuration
@@ -44,9 +44,7 @@ from pathlib import Path
44
44
  # Create custom configuration
45
45
  config = CacheConfig(
46
46
  cache_dir=Path("cache_directory"),
47
- max_size_bytes=1024 * 1024 * 1024, # 1GB
48
47
  cleanup_interval=timedelta(days=7),
49
- compression=True
50
48
  )
51
49
 
52
50
  # Initialize cache with configuration
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.6.0
4
+
5
+ - Reverting schema changes that break compatibility with the R/BiocFileCache implementation.
6
+ - Added support for Python 3.13
7
+
8
+ ## Version 0.5.5
9
+
10
+ - chore: Remove Python 3.8 (EOL).
11
+ - precommit: Replace docformatter with ruff's formatter.
12
+
3
13
  ## Version 0.5.0
4
14
 
5
15
  - SQLAlchemy session management
@@ -72,6 +72,7 @@ extensions = [
72
72
  "sphinx.ext.ifconfig",
73
73
  "sphinx.ext.mathjax",
74
74
  "sphinx.ext.napoleon",
75
+ "sphinx_autodoc_typehints",
75
76
  ]
76
77
 
77
78
  # Add any paths that contain templates here, relative to this directory.
@@ -169,6 +170,14 @@ pygments_style = "sphinx"
169
170
  # If this is True, todo emits a warning for each TODO entries. The default is False.
170
171
  todo_emit_warnings = True
171
172
 
173
+ autodoc_default_options = {
174
+ 'special-members': True,
175
+ 'undoc-members': False,
176
+ 'exclude-members': '__weakref__, __dict__, __str__, __module__, __annotations__'
177
+ }
178
+
179
+ autosummary_generate = True
180
+ autosummary_imported_members = True
172
181
 
173
182
  # -- Options for HTML output -------------------------------------------------
174
183
 
@@ -44,9 +44,7 @@ from pathlib import Path
44
44
  # Create custom configuration
45
45
  config = CacheConfig(
46
46
  cache_dir=Path("cache_directory"),
47
- max_size_bytes=1024 * 1024 * 1024, # 1GB
48
47
  cleanup_interval=timedelta(days=7),
49
- compression=True
50
48
  )
51
49
 
52
50
  # Initialize cache with configuration
@@ -5,3 +5,4 @@ furo
5
5
  # sphinx_rtd_theme
6
6
  recommonmark
7
7
  sphinx>=3.2.1
8
+ sphinx-autodoc-typehints
@@ -16,6 +16,10 @@ extend-ignore = ["F821"]
16
16
  [tool.ruff.pydocstyle]
17
17
  convention = "google"
18
18
 
19
+ [tool.ruff.format]
20
+ docstring-code-format = true
21
+ docstring-code-line-length = 20
22
+
19
23
  [tool.ruff.per-file-ignores]
20
24
  "__init__.py" = ["E402", "F401"]
21
25
 
@@ -20,6 +20,7 @@ packages = find_namespace:
20
20
  include_package_data = True
21
21
  package_dir =
22
22
  =src
23
+ python_requires = >=3.9
23
24
  install_requires =
24
25
  importlib-metadata; python_version<"3.8"
25
26
  sqlalchemy
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyBiocFileCache
3
- Version: 0.5.1
3
+ Version: 0.6.0
4
4
  Summary: File based cache for resources and metadata
5
5
  Home-page: https://github.com/epiviz/pyBiocFileCache
6
6
  Author: jkanche
@@ -10,6 +10,7 @@ Project-URL: Documentation, https://pyscaffold.org/
10
10
  Platform: any
11
11
  Classifier: Development Status :: 4 - Beta
12
12
  Classifier: Programming Language :: Python
13
+ Requires-Python: >=3.9
13
14
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
14
15
  License-File: LICENSE.txt
15
16
  License-File: AUTHORS.md
@@ -66,9 +67,7 @@ from pathlib import Path
66
67
  # Create custom configuration
67
68
  config = CacheConfig(
68
69
  cache_dir=Path("cache_directory"),
69
- max_size_bytes=1024 * 1024 * 1024, # 1GB
70
70
  cleanup_interval=timedelta(days=7),
71
- compression=True
72
71
  )
73
72
 
74
73
  # Initialize cache with configuration
@@ -6,14 +6,14 @@ from pathlib import Path
6
6
  from time import sleep, time
7
7
  from typing import Any, Dict, Iterator, List, Literal, Optional, Tuple, Union
8
8
 
9
- from sqlalchemy import create_engine, func
9
+ from sqlalchemy import create_engine, func, text
10
10
  from sqlalchemy.orm import Session, sessionmaker
11
11
  from sqlalchemy.pool import QueuePool
12
12
 
13
13
  from .config import CacheConfig
14
+ from .const import SCHEMA_VERSION
14
15
  from .exceptions import (
15
16
  BiocCacheError,
16
- CacheSizeLimitError,
17
17
  InvalidRnameError,
18
18
  NoFpathError,
19
19
  RnameExistsError,
@@ -25,7 +25,6 @@ from .utils import (
25
25
  copy_or_move,
26
26
  create_tmp_dir,
27
27
  generate_id,
28
- get_file_size,
29
28
  validate_rname,
30
29
  )
31
30
 
@@ -42,9 +41,7 @@ class BiocFileCache:
42
41
  Features:
43
42
  - Resource validation and integrity checking
44
43
  - Cache size management
45
- - File compression
46
- - Resource tagging
47
- - Automatic cleanup of expired resources
44
+ - Cleanup of expired resources
48
45
  """
49
46
 
50
47
  def __init__(self, cache_dir: Optional[Union[str, Path]] = None, config: Optional[CacheConfig] = None):
@@ -66,10 +63,15 @@ class BiocFileCache:
66
63
 
67
64
  self.config = config
68
65
  self._setup_cache_dir()
69
- self._setup_database()
66
+ db_schema_version = self._setup_database()
67
+
68
+ if db_schema_version != SCHEMA_VERSION:
69
+ print(db_schema_version)
70
+ raise RuntimeError(f"Database version is not {SCHEMA_VERSION}.")
71
+
70
72
  self._last_cleanup = datetime.now()
71
73
 
72
- def _setup_cache_dir(self) -> None:
74
+ def _setup_cache_dir(self) -> bool:
73
75
  if not self.config.cache_dir.exists():
74
76
  self.config.cache_dir.mkdir(parents=True, exist_ok=True)
75
77
 
@@ -87,6 +89,28 @@ class BiocFileCache:
87
89
  Base.metadata.create_all(self.engine)
88
90
  self.SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=self.engine)
89
91
 
92
+ with self.engine.connect() as conn:
93
+ result = conn.execute(
94
+ text("""
95
+ SELECT value FROM metadata
96
+ WHERE key = 'schema_version'
97
+ """)
98
+ )
99
+ row = result.fetchone()
100
+
101
+ if row is not None:
102
+ return row[0]
103
+
104
+ conn.execute(
105
+ text("""
106
+ INSERT INTO metadata (key, value)
107
+ VALUES ('schema_version', :version);
108
+ """),
109
+ {"version": SCHEMA_VERSION},
110
+ )
111
+
112
+ return SCHEMA_VERSION
113
+
90
114
  def _get_detached_resource(self, session: Session, resource: Resource) -> Optional[Resource]:
91
115
  """Get a detached copy of a resource."""
92
116
  if resource is None:
@@ -118,17 +142,6 @@ class BiocFileCache:
118
142
  finally:
119
143
  session.close()
120
144
 
121
- def _check_cache_size(self, new_size: int) -> None:
122
- """Verify cache size limit won't be exceeded."""
123
- if self.config.max_size_bytes is None:
124
- return
125
-
126
- current_size = self.get_cache_size()
127
- if current_size + new_size > self.config.max_size_bytes:
128
- raise CacheSizeLimitError(
129
- f"Adding {new_size} bytes would exceed cache limit of " f"{self.config.max_size_bytes} bytes"
130
- )
131
-
132
145
  def _validate_rname(self, rname: str) -> None:
133
146
  """Validate resource name format."""
134
147
  if not validate_rname(rname, self.config.rname_pattern):
@@ -218,7 +231,6 @@ class BiocFileCache:
218
231
  fpath: Union[str, Path],
219
232
  rtype: Literal["local", "web", "relative"] = "local",
220
233
  action: Literal["copy", "move", "asis"] = "copy",
221
- tags: Optional[List[str]] = None,
222
234
  expires: Optional[datetime] = None,
223
235
  ext: bool = False,
224
236
  ) -> Resource:
@@ -240,9 +252,6 @@ class BiocFileCache:
240
252
  How to handle the file ("copy", "move", or "asis").
241
253
  Defaults to ``copy``.
242
254
 
243
- tags:
244
- Optional list of tags for categorization.
245
-
246
255
  expires:
247
256
  Optional expiration datetime.
248
257
  If None, resource never expires.
@@ -267,8 +276,6 @@ class BiocFileCache:
267
276
  rid = generate_id()
268
277
  rpath = self.config.cache_dir / f"{rid}{fpath.suffix if ext else ''}" if action != "asis" else fpath
269
278
 
270
- self._check_cache_size(get_file_size(fpath))
271
-
272
279
  # Create resource record
273
280
  resource = Resource(
274
281
  rid=rid,
@@ -276,9 +283,7 @@ class BiocFileCache:
276
283
  rpath=str(rpath),
277
284
  rtype=rtype,
278
285
  fpath=str(fpath),
279
- tags=",".join(tags) if tags else None,
280
286
  expires=expires,
281
- size_bytes=get_file_size(fpath),
282
287
  )
283
288
 
284
289
  # Store file and update database
@@ -287,7 +292,7 @@ class BiocFileCache:
287
292
  session.commit()
288
293
 
289
294
  try:
290
- copy_or_move(fpath, rpath, rname, action, self.config.compression)
295
+ copy_or_move(fpath, rpath, rname, action, False)
291
296
 
292
297
  # Calculate and store checksum
293
298
  resource.etag = calculate_file_hash(rpath, self.config.hash_algorithm)
@@ -324,7 +329,6 @@ class BiocFileCache:
324
329
  rname: str,
325
330
  fpath: Union[str, Path],
326
331
  action: Literal["copy", "move", "asis"] = "copy",
327
- tags: Optional[List[str]] = None,
328
332
  ) -> Resource:
329
333
  """Update an existing resource.
330
334
 
@@ -339,9 +343,6 @@ class BiocFileCache:
339
343
  Either ``copy``, ``move`` or ``asis``.
340
344
  Defaults to ``copy``.
341
345
 
342
- tags:
343
- Optional new list of tags.
344
-
345
346
  Returns:
346
347
  Updated `Resource` object.
347
348
 
@@ -358,14 +359,10 @@ class BiocFileCache:
358
359
 
359
360
  old_path = Path(resource.rpath)
360
361
  try:
361
- copy_or_move(fpath, old_path, rname, action, self.config.compression)
362
+ copy_or_move(fpath, old_path, rname, action, False)
362
363
 
363
364
  resource.last_modified_time = datetime.now()
364
365
  resource.etag = calculate_file_hash(old_path, self.config.hash_algorithm)
365
- resource.size_bytes = get_file_size(old_path)
366
-
367
- if tags is not None:
368
- resource.tags = ",".join(tags)
369
366
 
370
367
  session.commit()
371
368
  return self._get_detached_resource(session, resource)
@@ -404,14 +401,10 @@ class BiocFileCache:
404
401
  session.rollback()
405
402
  raise BiocCacheError(f"Failed to remove resource '{rname}'") from e
406
403
 
407
- def list_resources(
408
- self, tag: Optional[str] = None, rtype: Optional[str] = None, expired: Optional[bool] = None
409
- ) -> List[Resource]:
404
+ def list_resources(self, rtype: Optional[str] = None, expired: Optional[bool] = None) -> List[Resource]:
410
405
  """List resources in the cache with optional filtering.
411
406
 
412
407
  Args:
413
- tag:
414
- Filter resources by tag.
415
408
 
416
409
  rtype:
417
410
  Filter resources by type.
@@ -429,8 +422,6 @@ class BiocFileCache:
429
422
  with self.get_session() as session:
430
423
  query = session.query(Resource)
431
424
 
432
- if tag:
433
- query = query.filter(Resource.tags.like(f"%{tag}%"))
434
425
  if rtype:
435
426
  query = query.filter(Resource.rtype == rtype)
436
427
  if expired is not None:
@@ -468,11 +459,6 @@ class BiocFileCache:
468
459
  logger.error(f"Failed to validate resource: {resource.rname}", exc_info=e)
469
460
  return False
470
461
 
471
- def get_cache_size(self) -> int:
472
- """Get total size of cached files in bytes."""
473
- with self.get_session() as session:
474
- return session.query(func.sum(Resource.size_bytes)).scalar() or 0
475
-
476
462
  def export_metadata(self, path: Path) -> None:
477
463
  """Export cache metadata to JSON file."""
478
464
  data = {
@@ -480,14 +466,11 @@ class BiocFileCache:
480
466
  {
481
467
  "rname": r.rname,
482
468
  "rtype": r.rtype,
483
- "tags": r.tags,
484
469
  "expires": r.expires.isoformat() if r.expires else None,
485
470
  "etag": r.etag,
486
- "size_bytes": r.size_bytes,
487
471
  }
488
472
  for r in self.list_resources()
489
473
  ],
490
- "cache_size": self.get_cache_size(),
491
474
  "export_time": datetime.now().isoformat(),
492
475
  }
493
476
 
@@ -503,7 +486,6 @@ class BiocFileCache:
503
486
  for resource_data in data["resources"]:
504
487
  resource = self._get(session, resource_data["rname"])
505
488
  if resource:
506
- resource.tags = resource_data["tags"]
507
489
  resource.expires = (
508
490
  datetime.fromisoformat(resource_data["expires"]) if resource_data["expires"] else None
509
491
  )
@@ -532,7 +514,7 @@ class BiocFileCache:
532
514
  Search string.
533
515
 
534
516
  field:
535
- Resource field to search ("rname", "rtype", "tags", etc.).
517
+ Resource field to search ("rname", "rtype", etc.).
536
518
 
537
519
  exact:
538
520
  Whether to require exact match.
@@ -565,7 +547,6 @@ class BiocFileCache:
565
547
  return {
566
548
  "total_resources": total,
567
549
  "expired_resources": expired,
568
- "cache_size_bytes": self.get_cache_size(),
569
550
  "resource_types": types,
570
551
  "last_cleanup": self._last_cleanup.isoformat(),
571
552
  "cleanup_enabled": self.config.cleanup_interval is not None,
@@ -16,10 +16,6 @@ class CacheConfig:
16
16
  cache_dir:
17
17
  Directory to store cached files.
18
18
 
19
- max_size_bytes:
20
- Maximum total size of cache.
21
- None for unlimited.
22
-
23
19
  cleanup_interval:
24
20
  How often to run expired resource cleanup.
25
21
  None for no cleanup.
@@ -29,14 +25,9 @@ class CacheConfig:
29
25
 
30
26
  hash_algorithm:
31
27
  Algorithm to use for file checksums.
32
-
33
- compression:
34
- Whether to compress cached files.
35
28
  """
36
29
 
37
30
  cache_dir: Path
38
- max_size_bytes: Optional[int] = None
39
31
  cleanup_interval: Optional[timedelta] = None # timedelta(days=30)
40
32
  rname_pattern: str = r"^[a-zA-Z0-9_-]+$"
41
33
  hash_algorithm: str = "md5"
42
- compression: bool = False
@@ -13,7 +13,7 @@ class Metadata(Base):
13
13
 
14
14
  __tablename__ = "metadata"
15
15
 
16
- key = Column(Text(), primary_key=True, index=True)
16
+ key = Column(Text(), primary_key=True, index=True, unique=True)
17
17
  value = Column(Text())
18
18
 
19
19
  def __repr__(self) -> str:
@@ -56,29 +56,21 @@ class Resource(Base):
56
56
 
57
57
  expires:
58
58
  When the resource should be considered expired.
59
-
60
- tags:
61
- Optional comma-separated tags for categorization.
62
-
63
- size_bytes:
64
- Size of the resource in bytes.
65
59
  """
66
60
 
67
61
  __tablename__ = "resource"
68
62
 
69
63
  id = Column(Integer, primary_key=True, index=True, autoincrement=True)
70
- rid = Column(Text(), index=True)
71
- rname = Column(Text(), index=True, unique=True)
64
+ rid = Column(Text())
65
+ rname = Column(Text())
72
66
  create_time = Column(DateTime, server_default=func.now())
73
67
  access_time = Column(DateTime, server_default=func.now())
74
68
  rpath = Column(Text())
75
69
  rtype = Column(Text())
76
70
  fpath = Column(Text())
77
- last_modified_time = Column(DateTime, onupdate=func.now())
78
- etag = Column(Text())
79
- expires = Column(DateTime)
80
- tags = Column(Text())
81
- size_bytes = Column(Integer)
71
+ last_modified_time = Column(DateTime, onupdate=func.now(), default=None)
72
+ etag = Column(Text(), default=None)
73
+ expires = Column(DateTime, default=None)
82
74
 
83
75
  def __repr__(self) -> str:
84
76
  return f"<Resource(id='{self.id}', rname='{self.rname}')>"
@@ -17,7 +17,7 @@ def test_create_cache():
17
17
  bfc.purge()
18
18
 
19
19
 
20
- def test_add_get_operations():
20
+ def test_add_get_list_operations():
21
21
  bfc = BiocFileCache(CACHE_DIR)
22
22
 
23
23
  rtrip = bfc.add("test1", os.getcwd() + "/tests/data/test1.txt")
@@ -1,51 +0,0 @@
1
- # This workflow will install Python dependencies, run tests and lint with a single version of Python
2
- # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3
-
4
- name: Publish to PyPI
5
-
6
- on:
7
- push:
8
- tags: "*"
9
-
10
- jobs:
11
- build:
12
-
13
- runs-on: ubuntu-latest
14
-
15
- steps:
16
- - uses: actions/checkout@v2
17
- - name: Set up Python 3.9
18
- uses: actions/setup-python@v2
19
- with:
20
- python-version: 3.9
21
- - name: Install dependencies
22
- run: |
23
- python -m pip install --upgrade pip
24
- pip install flake8 pytest tox
25
- # - name: Lint with flake8
26
- # run: |
27
- # # stop the build if there are Python syntax errors or undefined names
28
- # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
29
- # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
30
- # # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
31
- - name: Test with tox
32
- run: |
33
- tox
34
- - name: Build docs
35
- run: |
36
- tox -e docs
37
- - run: touch ./docs/_build/html/.nojekyll
38
- - name: GH Pages Deployment
39
- uses: JamesIves/github-pages-deploy-action@4.1.3
40
- with:
41
- branch: gh-pages # The branch the action should deploy to.
42
- folder: ./docs/_build/html
43
- clean: true # Automatically remove deleted files from the deploy branch
44
- - name: Build Project and Publish
45
- run: |
46
- python -m tox -e clean,build
47
- - name: Publish package
48
- uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
49
- with:
50
- user: __token__
51
- password: ${{ secrets.PYPI_PASSWORD }}
@@ -1,40 +0,0 @@
1
- # This workflow will install Python dependencies, run tests and lint with a single version of Python
2
- # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3
-
4
- name: Test the library
5
-
6
- on:
7
- push:
8
- branches: [ master ]
9
- pull_request:
10
- branches: [ master ]
11
-
12
- jobs:
13
- build:
14
-
15
- runs-on: ubuntu-latest
16
- strategy:
17
- matrix:
18
- python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12' ]
19
-
20
- name: Python ${{ matrix.python-version }}
21
- steps:
22
- - uses: actions/checkout@v2
23
- - name: Setup Python
24
- uses: actions/setup-python@v2
25
- with:
26
- python-version: ${{ matrix.python-version }}
27
- cache: 'pip'
28
- - name: Install dependencies
29
- run: |
30
- python -m pip install --upgrade pip
31
- pip install flake8 pytest tox
32
- # - name: Lint with flake8
33
- # run: |
34
- # # stop the build if there are Python syntax errors or undefined names
35
- # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
36
- # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37
- # # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38
- - name: Test with tox
39
- run: |
40
- tox
File without changes