diff --git a/CHANGELOG.md b/CHANGELOG.md
index e1bfe05..0630c4c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## Unreleased
-[Compare with latest](https://github.com/AllenInstitute/npc_lims/compare/v0.1.163...HEAD)
+[Compare with latest](https://github.com/AllenInstitute/npc_lims/compare/v0.1.164...HEAD)
+
+### Fixed
+
+- Fix cached iteratator bug ([a2a578d](https://github.com/AllenInstitute/npc_lims/commit/a2a578db071280a79811a08ec1f93143d620354a) by bjhardcastle).
+
+
+## [v0.1.164](https://github.com/AllenInstitute/npc_lims/releases/tag/v0.1.164) - 2024-07-11
+
+[Compare with v0.1.163](https://github.com/AllenInstitute/npc_lims/compare/v0.1.163...v0.1.164)
### Added
@@ -19,7 +28,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fix test ([925e7e0](https://github.com/AllenInstitute/npc_lims/commit/925e7e02b3e7bb256e71e860e6c10dcbc9d6ce95) by bjhardcastle).
-
## [v0.1.163](https://github.com/AllenInstitute/npc_lims/releases/tag/v0.1.163) - 2024-07-10
[Compare with v0.1.162](https://github.com/AllenInstitute/npc_lims/compare/v0.1.162...v0.1.163)
diff --git a/npc_lims b/npc_lims
index 925e7e0..a2a578d 160000
--- a/npc_lims
+++ b/npc_lims
@@ -1 +1 @@
-Subproject commit 925e7e02b3e7bb256e71e860e6c10dcbc9d6ce95
+Subproject commit a2a578db071280a79811a08ec1f93143d620354a
diff --git a/pyproject.toml b/pyproject.toml
index 12bfd64..cdc1d75 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "npc_lims"
-version = "0.1.164"
+version = "0.1.165"
description = "Tools to fetch and update paths, metadata and state for Mindscope Neuropixels sessions, in the cloud."
authors = [
{ name = "Arjun Sridhar", email = "arjun.sridhar@alleninstitute.org" },
diff --git a/src/npc_lims/status/tracked_sessions.py b/src/npc_lims/status/tracked_sessions.py
index 3d146bf..58e1606 100644
--- a/src/npc_lims/status/tracked_sessions.py
+++ b/src/npc_lims/status/tracked_sessions.py
@@ -6,7 +6,7 @@
import json
import time
import typing
-from collections.abc import Iterator, Mapping, MutableSequence
+from collections.abc import Mapping, MutableSequence
from typing import Any, Literal, TypedDict
import npc_session
@@ -432,7 +432,9 @@ def get_session_info(
tracked_sessions = set(
_get_session_info_from_file(ttl_hash=_get_ttl_hash(seconds=ttl_seconds)),
)
- tracked_sessions.update(_get_session_info_from_data_repo(ttl_hash=_get_ttl_hash(seconds=ttl_seconds)))
+ tracked_sessions.update(
+ _get_session_info_from_data_repo(ttl_hash=_get_ttl_hash(seconds=ttl_seconds))
+ )
if session is None:
filtered_sessions = (
s
@@ -528,13 +530,16 @@ def get_session_kwargs(
def _get_ttl_hash(seconds=10 * 60) -> int:
"""Return the same value within `seconds` time period
-
+
From https://stackoverflow.com/a/55900800
"""
return round(time.time() / seconds)
+
@functools.cache
-def _get_session_info_from_data_repo(ttl_hash: int | None = None) -> tuple[SessionInfo, ...]:
+def _get_session_info_from_data_repo(
+ ttl_hash: int | None = None,
+) -> tuple[SessionInfo, ...]:
"""
Examples:
@@ -554,6 +559,7 @@ def _get_session_info_from_data_repo(ttl_hash: int | None = None) -> tuple[Sessi
all_info.append(info)
return tuple(all_info)
+
@functools.cache
def _get_session_info_from_file(ttl_hash: int | None = None) -> tuple[SessionInfo, ...]:
"""Load yaml and parse sessions.
@@ -568,7 +574,11 @@ def _get_session_info_from_file(ttl_hash: int | None = None) -> tuple[SessionInf
if _TRACKED_SESSIONS_FILE.suffix == ".json":
return f(contents=json.loads(_TRACKED_SESSIONS_FILE.read_text()))
if _TRACKED_SESSIONS_FILE.suffix == ".yaml":
- return f(contents=yaml.load(_TRACKED_SESSIONS_FILE.read_bytes(), Loader=yaml.FullLoader))
+ return f(
+ contents=yaml.load(
+ _TRACKED_SESSIONS_FILE.read_bytes(), Loader=yaml.FullLoader
+ )
+ )
raise ValueError(
f"Add loader for {_TRACKED_SESSIONS_FILE.suffix}"
) # pragma: no cover