zombie-squirrel 0.1.0__tar.gz → 0.1.1__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zombie-squirrel
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Generated from aind-library-template
5
5
  Author: Allen Institute for Neural Dynamics
6
6
  License: MIT
@@ -0,0 +1,4 @@
1
+ """Init package"""
2
+ __version__ = "0.1.1"
3
+
4
+ from zombie_squirrel.squirrels import unique_project_names
@@ -4,6 +4,7 @@ from typing import Any, Callable, Optional
4
4
  from zombie_squirrel.acorns import RedshiftAcorn, MemoryAcorn
5
5
  from aind_data_access_api.document_db import MetadataDbClient
6
6
  import os
7
+ import logging
7
8
 
8
9
  # --- Backend setup ---------------------------------------------------
9
10
 
@@ -12,8 +13,10 @@ API_GATEWAY_HOST = "api.allenneuraldynamics.org"
12
13
  tree_type = os.getenv("TREE_SPECIES", "memory").lower()
13
14
 
14
15
  if tree_type == "redshift":
16
+ logging.info("Using Redshift acorn for caching")
15
17
  ACORN = RedshiftAcorn()
16
18
  else:
19
+ logging.info("Using in-memory acorn for caching")
17
20
  ACORN = MemoryAcorn()
18
21
 
19
22
  # --- Squirrel registry -----------------------------------------------------
@@ -31,13 +34,23 @@ def register_squirrel(name: str):
31
34
 
32
35
  # --- Squirrels -----------------------------------------------------
33
36
 
37
+ NAMES = {
38
+ "upn": "unique-project-names",
39
+ "usi": "unique-subject-ids",
40
+ }
34
41
 
35
- @register_squirrel("unique-project-names")
42
+
43
+ @register_squirrel(NAMES["upn"])
36
44
  def unique_project_names(force_update: bool = False) -> list[str]:
37
- df = ACORN.scurry("unique-project-names")
45
+ try:
46
+ df = ACORN.scurry(NAMES["upn"])
47
+ except Exception as e:
48
+ logging.warning(f"Error fetching from cache: {e}")
49
+ df = pd.DataFrame()
38
50
 
39
51
  if df.empty or force_update:
40
52
  # If cache is missing, fetch data
53
+ logging.info("Updating cache for unique project names")
41
54
  client = MetadataDbClient(
42
55
  host=API_GATEWAY_HOST,
43
56
  version="v2",
@@ -49,14 +62,14 @@ def unique_project_names(force_update: bool = False) -> list[str]:
49
62
  ]
50
63
  )
51
64
  df = pd.DataFrame(unique_project_names)
52
- ACORN.hide("unique-project-names", df)
65
+ ACORN.hide(NAMES["upn"], df)
53
66
 
54
67
  return df["project_name"].tolist()
55
68
 
56
69
 
57
- @register_squirrel("unique-subject-ids")
70
+ @register_squirrel(NAMES["usi"])
58
71
  def unique_subject_ids(force_update: bool = False) -> list[str]:
59
- df = ACORN.scurry("unique-subject-ids")
72
+ df = ACORN.scurry(NAMES["usi"])
60
73
 
61
74
  if df.empty or force_update:
62
75
  # If cache is missing, fetch data
@@ -71,6 +84,6 @@ def unique_subject_ids(force_update: bool = False) -> list[str]:
71
84
  ]
72
85
  )
73
86
  df = pd.DataFrame(unique_subject_ids)
74
- ACORN.hide("unique-subject-ids", df)
87
+ ACORN.hide(NAMES["usi"], df)
75
88
 
76
89
  return df["subject_id"].tolist()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zombie-squirrel
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Generated from aind-library-template
5
5
  Author: Allen Institute for Neural Dynamics
6
6
  License: MIT
@@ -1,4 +0,0 @@
1
- """Init package"""
2
- __version__ = "0.1.0"
3
-
4
- from zombie_squirrel.squirrels import unique_project_names
File without changes