Skip to content

Commit

Permalink
Make cache version format less restrictive
Browse files Browse the repository at this point in the history
  • Loading branch information
bjhardcastle committed Jan 10, 2024
1 parent 55264e5 commit 616aaa9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/npc_lims/paths/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,23 @@ def get_current_cache_version() -> str:


def _parse_version(version: str) -> str:
return f"v{packaging.version.parse(str(version))}"
try:
return f"v{packaging.version.parse(str(version))}"
except packaging.version.InvalidVersion:
raise ValueError(f"Invalid version {version!r}")


def _parse_cache_path(
nwb_component: NWBComponentStr,
session_id: str | npc_session.SessionRecord | None = None,
version: str | None = None,
) -> upath.UPath:
version = _parse_version(version) if version else get_current_cache_version()
d = CACHE_ROOT / version / nwb_component
version = version or get_current_cache_version()
d = (
CACHE_ROOT
/ version
/ nwb_component
)
if session_id is None:
return d
return (
Expand Down

0 comments on commit 616aaa9

Please sign in to comment.