zombie-squirrel 0.8.2__py3-none-any.whl → 0.8.4__py3-none-any.whl

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.
@@ -3,7 +3,7 @@
3
3
  Provides functions to fetch and cache project names, subject IDs, and asset
4
4
  metadata from the AIND metadata database with support for multiple backends."""
5
5
 
6
- __version__ = "0.8.2"
6
+ __version__ = "0.8.4"
7
7
 
8
8
  from zombie_squirrel.acorn_contents.asset_basics import asset_basics # noqa: F401
9
9
  from zombie_squirrel.acorn_contents.raw_to_derived import raw_to_derived # noqa: F401
@@ -6,6 +6,7 @@ import pandas as pd
6
6
  from aind_data_access_api.document_db import MetadataDbClient
7
7
 
8
8
  import zombie_squirrel.acorns as acorns
9
+ from zombie_squirrel.utils import setup_logging
9
10
 
10
11
 
11
12
  @acorns.register_acorn(acorns.NAMES["basics"])
@@ -37,7 +38,13 @@ def asset_basics(force_update: bool = False) -> pd.DataFrame:
37
38
  "location",
38
39
  ]
39
40
 
41
+ if df.empty and not force_update:
42
+ raise ValueError(
43
+ "Cache is empty. Use force_update=True to fetch data from database."
44
+ )
45
+
40
46
  if df.empty or force_update:
47
+ setup_logging()
41
48
  logging.info("Updating cache for asset basics")
42
49
  df = pd.DataFrame(
43
50
  columns=[
@@ -6,6 +6,7 @@ import pandas as pd
6
6
  from aind_data_access_api.document_db import MetadataDbClient
7
7
 
8
8
  import zombie_squirrel.acorns as acorns
9
+ from zombie_squirrel.utils import setup_logging
9
10
 
10
11
 
11
12
  @acorns.register_acorn(acorns.NAMES["r2d"])
@@ -22,7 +23,13 @@ def raw_to_derived(force_update: bool = False) -> pd.DataFrame:
22
23
  DataFrame with _id and derived_records columns."""
23
24
  df = acorns.TREE.scurry(acorns.NAMES["r2d"])
24
25
 
26
+ if df.empty and not force_update:
27
+ raise ValueError(
28
+ "Cache is empty. Use force_update=True to fetch data from database."
29
+ )
30
+
25
31
  if df.empty or force_update:
32
+ setup_logging()
26
33
  logging.info("Updating cache for raw to derived mapping")
27
34
  client = MetadataDbClient(
28
35
  host=acorns.API_GATEWAY_HOST,
@@ -50,9 +57,10 @@ def raw_to_derived(force_update: bool = False) -> pd.DataFrame:
50
57
  source_data_list = derived_record.get("data_description", {}).get("source_data", [])
51
58
  derived_id = derived_record["_id"]
52
59
  # Add this derived record to each raw record it depends on
53
- for source_id in source_data_list:
54
- if source_id in raw_to_derived_map:
55
- raw_to_derived_map[source_id].append(derived_id)
60
+ if source_data_list:
61
+ for source_id in source_data_list:
62
+ if source_id in raw_to_derived_map:
63
+ raw_to_derived_map[source_id].append(derived_id)
56
64
 
57
65
  # Convert to DataFrame
58
66
  data = []
@@ -6,6 +6,7 @@ import pandas as pd
6
6
  from aind_data_access_api.document_db import MetadataDbClient
7
7
 
8
8
  import zombie_squirrel.acorns as acorns
9
+ from zombie_squirrel.utils import setup_logging
9
10
 
10
11
 
11
12
  @acorns.register_acorn(acorns.NAMES["d2r"])
@@ -22,7 +23,13 @@ def source_data(force_update: bool = False) -> pd.DataFrame:
22
23
  DataFrame with _id and source_data columns."""
23
24
  df = acorns.TREE.scurry(acorns.NAMES["d2r"])
24
25
 
26
+ if df.empty and not force_update:
27
+ raise ValueError(
28
+ "Cache is empty. Use force_update=True to fetch data from database."
29
+ )
30
+
25
31
  if df.empty or force_update:
32
+ setup_logging()
26
33
  logging.info("Updating cache for source data")
27
34
  client = MetadataDbClient(
28
35
  host=acorns.API_GATEWAY_HOST,
@@ -6,6 +6,7 @@ import pandas as pd
6
6
  from aind_data_access_api.document_db import MetadataDbClient
7
7
 
8
8
  import zombie_squirrel.acorns as acorns
9
+ from zombie_squirrel.utils import setup_logging
9
10
 
10
11
 
11
12
  @acorns.register_acorn(acorns.NAMES["upn"])
@@ -22,8 +23,13 @@ def unique_project_names(force_update: bool = False) -> list[str]:
22
23
  List of unique project names."""
23
24
  df = acorns.TREE.scurry(acorns.NAMES["upn"])
24
25
 
26
+ if df.empty and not force_update:
27
+ raise ValueError(
28
+ "Cache is empty. Use force_update=True to fetch data from database."
29
+ )
30
+
25
31
  if df.empty or force_update:
26
- # If cache is missing, fetch data
32
+ setup_logging()
27
33
  logging.info("Updating cache for unique project names")
28
34
  client = MetadataDbClient(
29
35
  host=acorns.API_GATEWAY_HOST,
@@ -6,6 +6,7 @@ import pandas as pd
6
6
  from aind_data_access_api.document_db import MetadataDbClient
7
7
 
8
8
  import zombie_squirrel.acorns as acorns
9
+ from zombie_squirrel.utils import setup_logging
9
10
 
10
11
 
11
12
  @acorns.register_acorn(acorns.NAMES["usi"])
@@ -22,8 +23,13 @@ def unique_subject_ids(force_update: bool = False) -> list[str]:
22
23
  List of unique subject IDs."""
23
24
  df = acorns.TREE.scurry(acorns.NAMES["usi"])
24
25
 
26
+ if df.empty and not force_update:
27
+ raise ValueError(
28
+ "Cache is empty. Use force_update=True to fetch data from database."
29
+ )
30
+
25
31
  if df.empty or force_update:
26
- # If cache is missing, fetch data
32
+ setup_logging()
27
33
  logging.info("Updating cache for unique subject IDs")
28
34
  client = MetadataDbClient(
29
35
  host=acorns.API_GATEWAY_HOST,
zombie_squirrel/acorns.py CHANGED
@@ -45,3 +45,14 @@ def register_acorn(name: str):
45
45
  return func
46
46
 
47
47
  return decorator
48
+
49
+
50
+ # Import acorn_contents modules to trigger registration
51
+ # This must be done after the registry and decorator are defined
52
+ from zombie_squirrel.acorn_contents import ( # noqa: E402, F401
53
+ asset_basics,
54
+ raw_to_derived,
55
+ source_data,
56
+ unique_project_names,
57
+ unique_subject_ids,
58
+ )
zombie_squirrel/sync.py CHANGED
@@ -1,7 +1,5 @@
1
1
  """Synchronization utilities for updating all cached data."""
2
2
 
3
- import logging
4
-
5
3
  from .acorns import ACORN_REGISTRY
6
4
 
7
5
 
@@ -10,9 +8,5 @@ def hide_acorns():
10
8
 
11
9
  Calls each acorn function with force_update=True to refresh
12
10
  all cached data in the tree backend."""
13
- logging.basicConfig(
14
- level=logging.INFO,
15
- format="%(asctime)s %(levelname)s %(message)s"
16
- )
17
11
  for acorn in ACORN_REGISTRY.values():
18
12
  acorn(force_update=True)
zombie_squirrel/utils.py CHANGED
@@ -1,5 +1,19 @@
1
1
  """Utility functions for zombie-squirrel package."""
2
2
 
3
+ import logging
4
+
5
+
6
+ def setup_logging():
7
+ """Configure logging for zombie-squirrel package.
8
+
9
+ Sets up INFO level logging with timestamp format.
10
+ Safe to call multiple times - uses force=True to reconfigure."""
11
+ logging.basicConfig(
12
+ level=logging.INFO,
13
+ format="%(asctime)s %(levelname)s %(message)s",
14
+ force=True
15
+ )
16
+
3
17
 
4
18
  def prefix_table_name(table_name: str) -> str:
5
19
  """Add zombie-squirrel prefix and parquet extension to filenames.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zombie-squirrel
3
- Version: 0.8.2
3
+ Version: 0.8.4
4
4
  Summary: Generated from aind-library-template
5
5
  Author: Allen Institute for Neural Dynamics
6
6
  License: MIT
@@ -0,0 +1,16 @@
1
+ zombie_squirrel/__init__.py,sha256=V1ZXhNO1h3PxKP-k5yb8YtU1sgw0ie8JduMXfR3C7Zo,693
2
+ zombie_squirrel/acorns.py,sha256=oFrRkE3P6Mf9ZUCM8JmzDPBdc4gnoc-gVau7kWt0EJY,1429
3
+ zombie_squirrel/forest.py,sha256=v0K1u0EA0OptzxocFC-fPEi6xYcnJ9SoWJ6aiPF4jLg,2939
4
+ zombie_squirrel/sync.py,sha256=51ufe4n_3CvYrfTKW4KHngY4k-E9k0I_HGdWOIHY-bA,366
5
+ zombie_squirrel/utils.py,sha256=v9IsbICSflk5TjSFSgcEoL0FSyU-M8_fn3OYdkjBu8Y,983
6
+ zombie_squirrel/acorn_contents/__init__.py,sha256=N4Wun9kn44_nCwV4g6naEVzf76ozOgEoupAHLYpiGsI,224
7
+ zombie_squirrel/acorn_contents/asset_basics.py,sha256=_vbZS7fa_u-2J592aKWzFd3jFFBZMU7PnrVeF4WWrkw,5741
8
+ zombie_squirrel/acorn_contents/raw_to_derived.py,sha256=iQ5L12VJm2GVUU9J9HjLcr_YhMcHYFGLtXzfqmLrgNM,2718
9
+ zombie_squirrel/acorn_contents/source_data.py,sha256=boO6kd8ksdYzg_LBhmvTFfI1vjJuIFRUKWSC40TVwnA,1755
10
+ zombie_squirrel/acorn_contents/unique_project_names.py,sha256=inHOXd1_XeUVFGv9HT9m4GXE3vN9qbPR0H6aEtzVAZo,1475
11
+ zombie_squirrel/acorn_contents/unique_subject_ids.py,sha256=J9F_I0iR5HU6D2gme6vdC-kMGPxb6F6TfoW1zX1x-PM,1446
12
+ zombie_squirrel-0.8.4.dist-info/licenses/LICENSE,sha256=U0Y7B3gZJHXpjJVLgTQjM8e_c8w4JJpLgGhIdsoFR1Y,1092
13
+ zombie_squirrel-0.8.4.dist-info/METADATA,sha256=FDGupBmCDrMY4maTCb-U2xJeZ0mSp02dWyWI4K2iplA,1898
14
+ zombie_squirrel-0.8.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
15
+ zombie_squirrel-0.8.4.dist-info/top_level.txt,sha256=FmM0coe4AangURZLjM4JwwRv2B8H6oINYCoZLKLDCKA,16
16
+ zombie_squirrel-0.8.4.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- zombie_squirrel/__init__.py,sha256=9ab8TQH1uvUteReZQi0QoJfjC32WfRofwMJm6nluA1w,693
2
- zombie_squirrel/acorns.py,sha256=BLhySoLfb7D6IfbNMOhxbLJba-8Wp-L9e1w_2KozjjM,1134
3
- zombie_squirrel/forest.py,sha256=v0K1u0EA0OptzxocFC-fPEi6xYcnJ9SoWJ6aiPF4jLg,2939
4
- zombie_squirrel/sync.py,sha256=9cpfSzTj0cQz4-d3glMAOejCZgekMirLc-dwEFFQhlg,496
5
- zombie_squirrel/utils.py,sha256=kojQpHUKlRJD7WEZDfcpQIZTj9iUrtX5_6F-gWWzJW0,628
6
- zombie_squirrel/acorn_contents/__init__.py,sha256=N4Wun9kn44_nCwV4g6naEVzf76ozOgEoupAHLYpiGsI,224
7
- zombie_squirrel/acorn_contents/asset_basics.py,sha256=cTg016sZbrJH5_As7CqnirumR1hSMn4GiYX0IReoou0,5513
8
- zombie_squirrel/acorn_contents/raw_to_derived.py,sha256=EFjLP9szzk3Q6jNhyDwxx8rqhG1bFTVmxeCpCAsv6yg,2445
9
- zombie_squirrel/acorn_contents/source_data.py,sha256=zbw3DnTwXo6xDTZ1uCoIbcYrVBH2r2xZN3trKtxT8cg,1527
10
- zombie_squirrel/acorn_contents/unique_project_names.py,sha256=Fu0P2DyI91W7xhx1uRk2YVMyFG8WPihDCj7n_A7zL2E,1289
11
- zombie_squirrel/acorn_contents/unique_subject_ids.py,sha256=dOVn1ObDF86p8S8US__hlyjTGxT0vz01oeGzjoWGFIc,1260
12
- zombie_squirrel-0.8.2.dist-info/licenses/LICENSE,sha256=U0Y7B3gZJHXpjJVLgTQjM8e_c8w4JJpLgGhIdsoFR1Y,1092
13
- zombie_squirrel-0.8.2.dist-info/METADATA,sha256=IlGrFVZcitVVqTemTzoZCfoFDKO-xYC4HRskY70ovJI,1898
14
- zombie_squirrel-0.8.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
15
- zombie_squirrel-0.8.2.dist-info/top_level.txt,sha256=FmM0coe4AangURZLjM4JwwRv2B8H6oINYCoZLKLDCKA,16
16
- zombie_squirrel-0.8.2.dist-info/RECORD,,