Skip to content

Commit

Permalink
Bump [skip actions]
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 11, 2024
1 parent a2a578d commit b735450
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
<!-- insertion marker -->
## Unreleased

<small>[Compare with latest](https://github.com/AllenInstitute/npc_lims/compare/v0.1.163...HEAD)</small>
<small>[Compare with latest](https://github.com/AllenInstitute/npc_lims/compare/v0.1.164...HEAD)</small>

### Fixed

- Fix cached iteratator bug ([a2a578d](https://github.com/AllenInstitute/npc_lims/commit/a2a578db071280a79811a08ec1f93143d620354a) by bjhardcastle).

<!-- insertion marker -->
## [v0.1.164](https://github.com/AllenInstitute/npc_lims/releases/tag/v0.1.164) - 2024-07-11

<small>[Compare with v0.1.163](https://github.com/AllenInstitute/npc_lims/compare/v0.1.163...v0.1.164)</small>

### Added

Expand All @@ -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).

<!-- insertion marker -->
## [v0.1.163](https://github.com/AllenInstitute/npc_lims/releases/tag/v0.1.163) - 2024-07-10

<small>[Compare with v0.1.162](https://github.com/AllenInstitute/npc_lims/compare/v0.1.162...v0.1.163)</small>
Expand Down
2 changes: 1 addition & 1 deletion npc_lims
Submodule npc_lims updated from 925e7e to a2a578
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" },
Expand Down
20 changes: 15 additions & 5 deletions src/npc_lims/status/tracked_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit b735450

Please sign in to comment.