pyBiocFileCache 0.4.0__py3-none-any.whl → 0.4.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.
@@ -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>
@@ -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
@@ -13,12 +13,12 @@ Classifier: Programming Language :: Python
13
13
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
14
14
  License-File: LICENSE.txt
15
15
  License-File: AUTHORS.md
16
- Requires-Dist: sqlalchemy <2.1,>=2
17
- Requires-Dist: importlib-metadata ; python_version < "3.8"
16
+ Requires-Dist: importlib-metadata; python_version < "3.8"
17
+ Requires-Dist: sqlalchemy<2.1,>=2
18
18
  Provides-Extra: testing
19
- Requires-Dist: setuptools ; extra == 'testing'
20
- Requires-Dist: pytest ; extra == 'testing'
21
- Requires-Dist: pytest-cov ; extra == 'testing'
19
+ Requires-Dist: setuptools; extra == "testing"
20
+ Requires-Dist: pytest; extra == "testing"
21
+ Requires-Dist: pytest-cov; extra == "testing"
22
22
 
23
23
  [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
24
24
  [![PyPI-Server](https://img.shields.io/pypi/v/pyBiocFileCache.svg)](https://pypi.org/project/pyBiocFileCache/)
@@ -0,0 +1,13 @@
1
+ pybiocfilecache/BiocFileCache.py,sha256=-aqTaPtTSXVi6sBP7VnXEXYOHgZHzDcCK1zJmw3u_3I,8691
2
+ pybiocfilecache/__init__.py,sha256=IAUOQ-SoVfKXEexvljUBJQrVrntYZUxxgFXnlEGi2jY,921
3
+ pybiocfilecache/_exceptions.py,sha256=347Lt1Rrt-TTzP5yEqlRM1QoaPBXB1UnZXv0GfhZmv0,374
4
+ pybiocfilecache/const.py,sha256=c9167eSCGBp0wF1xuAEvr-fbYCzp0lcOtKF9sqxlLF8,26
5
+ pybiocfilecache/utils.py,sha256=dJBZpLqAoD4qIW9SVBTGeoiYjxraeswAOApQxACpSAU,2018
6
+ pybiocfilecache/db/__init__.py,sha256=v1G_gueaai3eECWSgj1G4EPH631x1Yg3AiSoY2jVJHE,107
7
+ pybiocfilecache/db/db_config.py,sha256=UNtjzyZ1Et3j183OUXd5iiyHshGqxwTSUPmqzuxmTi4,2346
8
+ pyBiocFileCache-0.4.1.dist-info/AUTHORS.md,sha256=ptvMLokf9Knfp0Ng-dHSgtEimkXWZhjZAR_o2aJm9bw,161
9
+ pyBiocFileCache-0.4.1.dist-info/LICENSE.txt,sha256=bV5MJ4ezdCnC4yREyxU30iel5hFq8T8kGqobu4Kc-WM,1082
10
+ pyBiocFileCache-0.4.1.dist-info/METADATA,sha256=Ithgx-0PCLVCF9k1klrqSzo5RE9g4LZkRAMtmYs1hA4,2530
11
+ pyBiocFileCache-0.4.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
12
+ pyBiocFileCache-0.4.1.dist-info/top_level.txt,sha256=_A2QFmYMnsz6WoSRPk1EFMDr5mkQVGx9Xtz2RMv3aF4,16
13
+ pyBiocFileCache-0.4.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -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)
pybiocfilecache/utils.py CHANGED
@@ -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,13 +0,0 @@
1
- pybiocfilecache/BiocFileCache.py,sha256=q19EAVMZSyG6I4om2AiY0wMXyMs87nVEza4r3phCJLw,8577
2
- pybiocfilecache/__init__.py,sha256=IAUOQ-SoVfKXEexvljUBJQrVrntYZUxxgFXnlEGi2jY,921
3
- pybiocfilecache/_exceptions.py,sha256=347Lt1Rrt-TTzP5yEqlRM1QoaPBXB1UnZXv0GfhZmv0,374
4
- pybiocfilecache/const.py,sha256=c9167eSCGBp0wF1xuAEvr-fbYCzp0lcOtKF9sqxlLF8,26
5
- pybiocfilecache/utils.py,sha256=jsaF6B1FViqfiWBJEq4ZCY7eI0bznpcozWkbGbBDH0c,2054
6
- pybiocfilecache/db/__init__.py,sha256=v1G_gueaai3eECWSgj1G4EPH631x1Yg3AiSoY2jVJHE,107
7
- pybiocfilecache/db/db_config.py,sha256=R15fSAmuP0pnWYpH6lY1ko7zIrqvvJ5dNKd1aEXoDDE,2360
8
- pyBiocFileCache-0.4.0.dist-info/AUTHORS.md,sha256=o_ehUYmMFNMl2a6xQTKhEKxv6eXIJF0TIUTQRhHdsrk,160
9
- pyBiocFileCache-0.4.0.dist-info/LICENSE.txt,sha256=bV5MJ4ezdCnC4yREyxU30iel5hFq8T8kGqobu4Kc-WM,1082
10
- pyBiocFileCache-0.4.0.dist-info/METADATA,sha256=qjbb84Uq5vZ8GBIhN7NzVGryAfUz_w_52C_iy1ZR9n4,2535
11
- pyBiocFileCache-0.4.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
12
- pyBiocFileCache-0.4.0.dist-info/top_level.txt,sha256=_A2QFmYMnsz6WoSRPk1EFMDr5mkQVGx9Xtz2RMv3aF4,16
13
- pyBiocFileCache-0.4.0.dist-info/RECORD,,