From 616aaa92652cf9af5ecdb40e29bc83b5fe6ec393 Mon Sep 17 00:00:00 2001 From: bjhardcastle Date: Tue, 9 Jan 2024 17:52:04 -0800 Subject: [PATCH] Make cache version format less restrictive --- src/npc_lims/paths/cache.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/npc_lims/paths/cache.py b/src/npc_lims/paths/cache.py index 7e94131..51e04f0 100644 --- a/src/npc_lims/paths/cache.py +++ b/src/npc_lims/paths/cache.py @@ -66,7 +66,10 @@ 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( @@ -74,8 +77,12 @@ def _parse_cache_path( 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 (