pyBiocFileCache 0.4.0__tar.gz → 0.4.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 (43) hide show
  1. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/.github/workflows/pypi-test.yml +2 -2
  2. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/.pre-commit-config.yaml +14 -13
  3. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/AUTHORS.md +1 -1
  4. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/CHANGELOG.md +1 -1
  5. {pybiocfilecache-0.4.0/src/pyBiocFileCache.egg-info → pybiocfilecache-0.4.1}/PKG-INFO +1 -1
  6. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/docs/authors.md +1 -1
  7. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/docs/changelog.md +1 -1
  8. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1/src/pyBiocFileCache.egg-info}/PKG-INFO +1 -1
  9. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pybiocfilecache/BiocFileCache.py +13 -15
  10. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pybiocfilecache/db/db_config.py +1 -3
  11. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pybiocfilecache/utils.py +2 -6
  12. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/tests/conftest.py +3 -3
  13. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/tests/test_cache.py +3 -0
  14. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/.coveragerc +0 -0
  15. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/.github/workflows/pypi-publish.yml +0 -0
  16. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/.gitignore +0 -0
  17. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/.readthedocs.yml +0 -0
  18. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/CONTRIBUTING.rst +0 -0
  19. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/LICENSE.txt +0 -0
  20. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/README.md +0 -0
  21. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/docs/Makefile +0 -0
  22. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/docs/_static/.gitignore +0 -0
  23. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/docs/conf.py +0 -0
  24. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/docs/contributing.rst +0 -0
  25. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/docs/index.md +0 -0
  26. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/docs/license.rst +0 -0
  27. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/docs/readme.md +0 -0
  28. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/docs/requirements.txt +0 -0
  29. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/pyproject.toml +0 -0
  30. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/setup.cfg +0 -0
  31. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/setup.py +0 -0
  32. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pyBiocFileCache.egg-info/SOURCES.txt +0 -0
  33. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pyBiocFileCache.egg-info/dependency_links.txt +0 -0
  34. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pyBiocFileCache.egg-info/not-zip-safe +0 -0
  35. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pyBiocFileCache.egg-info/requires.txt +0 -0
  36. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pyBiocFileCache.egg-info/top_level.txt +0 -0
  37. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pybiocfilecache/__init__.py +0 -0
  38. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pybiocfilecache/_exceptions.py +0 -0
  39. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pybiocfilecache/const.py +0 -0
  40. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/src/pybiocfilecache/db/__init__.py +0 -0
  41. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/tests/data/test1.txt +0 -0
  42. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/tests/data/test2.txt +0 -0
  43. {pybiocfilecache-0.4.0 → pybiocfilecache-0.4.1}/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>
@@ -4,6 +4,6 @@
4
4
 
5
5
  - 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.
6
6
 
7
- ## Version 0.1
7
+ ## Version 0.1
8
8
 
9
9
  - Initial release of the package, Setting up all the actions.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyBiocFileCache
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: File based cache for resources and metadata
5
5
  Home-page: https://github.com/epiviz/pyBiocFileCache
6
6
  Author: jkanche
@@ -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>
@@ -4,6 +4,6 @@
4
4
 
5
5
  - 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.
6
6
 
7
- ## Version 0.1
7
+ ## Version 0.1
8
8
 
9
9
  - Initial release of the package, Setting up all the actions.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyBiocFileCache
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: File based cache for resources and metadata
5
5
  Home-page: https://github.com/epiviz/pyBiocFileCache
6
6
  Author: jkanche
@@ -95,11 +95,7 @@ class BiocFileCache:
95
95
  raise NoFpathError(f"Resource at '{fpath}' does not exist.")
96
96
 
97
97
  rid = generate_id()
98
- rpath = (
99
- f"{self.cache}/{rid}" + (f".{fpath.suffix}" if ext else "")
100
- if action != "asis"
101
- else str(fpath)
102
- )
98
+ rpath = f"{self.cache}/{rid}" + (f".{fpath.suffix}" if ext else "") if action != "asis" else str(fpath)
103
99
 
104
100
  # create new record in the database
105
101
  res = Resource(
@@ -151,11 +147,7 @@ class BiocFileCache:
151
147
  List of matching resources from cache.
152
148
  """
153
149
  with self.sessionLocal() as session:
154
- return (
155
- session.query(Resource)
156
- .filter(Resource[field].ilike("%{}%".format(query)))
157
- .all()
158
- )
150
+ return session.query(Resource).filter(Resource[field].ilike("%{}%".format(query))).all()
159
151
 
160
152
  def _get(self, session: Session, rname: str) -> Optional[Resource]:
161
153
  """Get a resource with `rname` from given `Session`.
@@ -170,9 +162,7 @@ class BiocFileCache:
170
162
  Returns:
171
163
  The `Resource` for the `rname` if available.
172
164
  """
173
- resource: Optional[Resource] = (
174
- session.query(Resource).filter(Resource.rname == rname).first()
175
- )
165
+ resource: Optional[Resource] = session.query(Resource).filter(Resource.rname == rname).first()
176
166
 
177
167
  if resource is not None:
178
168
  # `Resource` may exist but `rpath` could still be being
@@ -182,8 +172,7 @@ class BiocFileCache:
182
172
  while not Path(str(resource.rpath)).exists():
183
173
  if time() - start >= timeout:
184
174
  raise RpathTimeoutError(
185
- f"For resource: '{rname}' the rpath does not exist "
186
- f"after {timeout} seconds."
175
+ f"For resource: '{rname}' the rpath does not exist " f"after {timeout} seconds."
187
176
  )
188
177
  sleep(0.1)
189
178
 
@@ -274,3 +263,12 @@ class BiocFileCache:
274
263
  # but lets just add it to the cache.
275
264
  res = self.add(rname=rname, fpath=fpath, action=action)
276
265
  return res
266
+
267
+ def list_all(self) -> List[Resource]:
268
+ """List all resources currently in the cache.
269
+
270
+ Returns:
271
+ List of all Resource objects in the cache.
272
+ """
273
+ with self.sessionLocal() as session:
274
+ return session.query(Resource).all()
@@ -72,9 +72,7 @@ def create_schema(cache_dir: str) -> Tuple[Engine, sessionmaker]:
72
72
  Returns:
73
73
  A tuple of sqlalchemy engine and session maker.
74
74
  """
75
- engine = create_engine(
76
- f"sqlite:///{cache_dir}", connect_args={"check_same_thread": False}
77
- )
75
+ engine = create_engine(f"sqlite:///{cache_dir}", connect_args={"check_same_thread": False})
78
76
 
79
77
  Base.metadata.create_all(bind=engine, checkfirst=True)
80
78
  sessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
@@ -60,9 +60,7 @@ def copy_or_move(
60
60
  """
61
61
 
62
62
  if action not in ["copy", "move", "asis"]:
63
- raise ValueError(
64
- f"Action must be either 'move', 'copy' or 'asis', provided {action}."
65
- )
63
+ raise ValueError(f"Action must be either 'move', 'copy' or 'asis', provided {action}.")
66
64
 
67
65
  try:
68
66
  if action == "copy":
@@ -84,6 +82,4 @@ def setup_logging(loglevel):
84
82
  loglevel (int): minimum loglevel for emitting messages
85
83
  """
86
84
  logformat = "[%(asctime)s] %(levelname)s:%(name)s:%(message)s"
87
- logging.basicConfig(
88
- level=loglevel, stream=sys.stdout, format=logformat, datefmt="%Y-%m-%d %H:%M:%S"
89
- )
85
+ logging.basicConfig(level=loglevel, stream=sys.stdout, format=logformat, datefmt="%Y-%m-%d %H:%M:%S")
@@ -1,8 +1,8 @@
1
- """Dummy conftest.py for pybiocfilecache.
2
- If you don't know what this is for, just leave it empty.
1
+ """Dummy conftest.py for pybiocfilecache. If you don't know what this is for, just leave it empty.
2
+
3
3
  Read more about conftest.py under:
4
4
  - https://docs.pytest.org/en/stable/fixture.html
5
5
  - https://docs.pytest.org/en/stable/writing_plugins.html
6
6
  """
7
7
 
8
- # import pytest
8
+ # import pytest
@@ -41,6 +41,9 @@ def test_add_get_operations():
41
41
  frec3 = open(rec3.rpath, "r").read().strip()
42
42
  assert frec3 == "test2"
43
43
 
44
+ rtrip = bfc.list_all()
45
+ assert len(rtrip) == 3
46
+
44
47
  bfc.purge()
45
48
 
46
49
 
File without changes