zombie-squirrel 0.7.4__tar.gz → 0.8.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.
Files changed (31) hide show
  1. {zombie_squirrel-0.7.4/src/zombie_squirrel.egg-info → zombie_squirrel-0.8.1}/PKG-INFO +4 -4
  2. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/README.md +3 -3
  3. zombie_squirrel-0.8.1/src/zombie_squirrel/__init__.py +12 -0
  4. zombie_squirrel-0.8.1/src/zombie_squirrel/acorn_contents/__init__.py +10 -0
  5. zombie_squirrel-0.8.1/src/zombie_squirrel/acorn_contents/asset_basics.py +135 -0
  6. zombie_squirrel-0.8.1/src/zombie_squirrel/acorn_contents/raw_to_derived.py +71 -0
  7. zombie_squirrel-0.8.1/src/zombie_squirrel/acorn_contents/source_data.py +50 -0
  8. zombie_squirrel-0.8.1/src/zombie_squirrel/acorn_contents/unique_project_names.py +41 -0
  9. zombie_squirrel-0.8.1/src/zombie_squirrel/acorn_contents/unique_subject_ids.py +41 -0
  10. zombie_squirrel-0.8.1/src/zombie_squirrel/acorns.py +47 -0
  11. zombie_squirrel-0.7.4/src/zombie_squirrel/acorns.py → zombie_squirrel-0.8.1/src/zombie_squirrel/forest.py +4 -4
  12. zombie_squirrel-0.8.1/src/zombie_squirrel/sync.py +18 -0
  13. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1/src/zombie_squirrel.egg-info}/PKG-INFO +4 -4
  14. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/src/zombie_squirrel.egg-info/SOURCES.txt +8 -2
  15. zombie_squirrel-0.8.1/tests/test_acorns.py +37 -0
  16. zombie_squirrel-0.8.1/tests/test_sync.py +85 -0
  17. zombie_squirrel-0.7.4/tests/test_acorns.py → zombie_squirrel-0.8.1/tests/test_trees.py +51 -51
  18. zombie_squirrel-0.7.4/src/zombie_squirrel/__init__.py +0 -14
  19. zombie_squirrel-0.7.4/src/zombie_squirrel/squirrels.py +0 -355
  20. zombie_squirrel-0.7.4/src/zombie_squirrel/sync.py +0 -18
  21. zombie_squirrel-0.7.4/tests/test_squirrels.py +0 -446
  22. zombie_squirrel-0.7.4/tests/test_sync.py +0 -85
  23. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/LICENSE +0 -0
  24. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/pyproject.toml +0 -0
  25. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/setup.cfg +0 -0
  26. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/setup.py +0 -0
  27. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/src/zombie_squirrel/utils.py +0 -0
  28. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/src/zombie_squirrel.egg-info/dependency_links.txt +0 -0
  29. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/src/zombie_squirrel.egg-info/requires.txt +0 -0
  30. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/src/zombie_squirrel.egg-info/top_level.txt +0 -0
  31. {zombie_squirrel-0.7.4 → zombie_squirrel-0.8.1}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zombie-squirrel
3
- Version: 0.7.4
3
+ Version: 0.8.1
4
4
  Summary: Generated from aind-library-template
5
5
  Author: Allen Institute for Neural Dynamics
6
6
  License: MIT
@@ -21,7 +21,7 @@ Dynamic: license-file
21
21
  ![Code Style](https://img.shields.io/badge/code%20style-black-black)
22
22
  [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
23
23
  ![Interrogate](https://img.shields.io/badge/interrogate-100.0%25-brightgreen)
24
- ![Coverage](https://img.shields.io/badge/coverage-99%25-brightgreen)
24
+ ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
25
25
  ![Python](https://img.shields.io/badge/python->=3.10-blue?logo=python)
26
26
 
27
27
  <img src="zombie-squirrel_logo.png" width="400" alt="Logo (image from ChatGPT)">
@@ -37,10 +37,10 @@ pip install zombie-squirrel
37
37
  ### Set backend
38
38
 
39
39
  ```bash
40
- export TREE_SPECIES='s3'
40
+ export FOREST_TYPE='S3'
41
41
  ```
42
42
 
43
- Options are 's3', 'MEMORY'.
43
+ Options are 'S3', 'MEMORY'.
44
44
 
45
45
  ### Scurry (fetch) data
46
46
 
@@ -4,7 +4,7 @@
4
4
  ![Code Style](https://img.shields.io/badge/code%20style-black-black)
5
5
  [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
6
6
  ![Interrogate](https://img.shields.io/badge/interrogate-100.0%25-brightgreen)
7
- ![Coverage](https://img.shields.io/badge/coverage-99%25-brightgreen)
7
+ ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
8
8
  ![Python](https://img.shields.io/badge/python->=3.10-blue?logo=python)
9
9
 
10
10
  <img src="zombie-squirrel_logo.png" width="400" alt="Logo (image from ChatGPT)">
@@ -20,10 +20,10 @@ pip install zombie-squirrel
20
20
  ### Set backend
21
21
 
22
22
  ```bash
23
- export TREE_SPECIES='s3'
23
+ export FOREST_TYPE='S3'
24
24
  ```
25
25
 
26
- Options are 's3', 'MEMORY'.
26
+ Options are 'S3', 'MEMORY'.
27
27
 
28
28
  ### Scurry (fetch) data
29
29
 
@@ -0,0 +1,12 @@
1
+ """Zombie-squirrel: caching and synchronization for AIND metadata.
2
+
3
+ Provides functions to fetch and cache project names, subject IDs, and asset
4
+ metadata from the AIND metadata database with support for multiple backends."""
5
+
6
+ __version__ = "0.8.1"
7
+
8
+ from zombie_squirrel.acorn_contents.asset_basics import asset_basics # noqa: F401
9
+ from zombie_squirrel.acorn_contents.raw_to_derived import raw_to_derived # noqa: F401
10
+ from zombie_squirrel.acorn_contents.source_data import source_data # noqa: F401
11
+ from zombie_squirrel.acorn_contents.unique_project_names import unique_project_names # noqa: F401
12
+ from zombie_squirrel.acorn_contents.unique_subject_ids import unique_subject_ids # noqa: F401
@@ -0,0 +1,10 @@
1
+ """Acorns module: individual data fetching functions."""
2
+
3
+ # Import the acorn modules to trigger decorator registration
4
+ from zombie_squirrel.acorn_contents import ( # noqa: F401
5
+ asset_basics,
6
+ raw_to_derived,
7
+ source_data,
8
+ unique_project_names,
9
+ unique_subject_ids,
10
+ )
@@ -0,0 +1,135 @@
1
+ """Asset basics acorn."""
2
+
3
+ import logging
4
+
5
+ import pandas as pd
6
+ from aind_data_access_api.document_db import MetadataDbClient
7
+
8
+ import zombie_squirrel.acorns as acorns
9
+
10
+
11
+ @acorns.register_acorn(acorns.NAMES["basics"])
12
+ def asset_basics(force_update: bool = False) -> pd.DataFrame:
13
+ """Fetch basic asset metadata including modalities, projects, and subject info.
14
+
15
+ Returns a DataFrame with columns: _id, _last_modified, modalities,
16
+ project_name, data_level, subject_id, acquisition_start_time, and
17
+ acquisition_end_time. Uses incremental updates based on _last_modified
18
+ timestamps to avoid re-fetching unchanged records.
19
+
20
+ Args:
21
+ force_update: If True, bypass cache and fetch fresh data from database.
22
+
23
+ Returns:
24
+ DataFrame with basic asset metadata."""
25
+ df = acorns.TREE.scurry(acorns.NAMES["basics"])
26
+
27
+ FIELDS = [
28
+ "data_description.modalities",
29
+ "data_description.project_name",
30
+ "data_description.data_level",
31
+ "subject.subject_id",
32
+ "acquisition.acquisition_start_time",
33
+ "acquisition.acquisition_end_time",
34
+ "processing.data_processes.start_date_time",
35
+ "subject.subject_details.genotype",
36
+ "other_identifiers",
37
+ "location",
38
+ ]
39
+
40
+ if df.empty or force_update:
41
+ logging.info("Updating cache for asset basics")
42
+ df = pd.DataFrame(
43
+ columns=[
44
+ "_id",
45
+ "_last_modified",
46
+ "modalities",
47
+ "project_name",
48
+ "data_level",
49
+ "subject_id",
50
+ "acquisition_start_time",
51
+ "acquisition_end_time",
52
+ "code_ocean",
53
+ "process_date",
54
+ "genotype",
55
+ "location",
56
+ ]
57
+ )
58
+ client = MetadataDbClient(
59
+ host=acorns.API_GATEWAY_HOST,
60
+ version="v2",
61
+ )
62
+ # It's a bit complex to get multiple fields that aren't indexed in a database
63
+ # as large as DocDB. We'll also try to limit ourselves to only updating fields
64
+ # that are necessary
65
+ record_ids = client.retrieve_docdb_records(
66
+ filter_query={},
67
+ projection={"_id": 1, "_last_modified": 1},
68
+ limit=0,
69
+ )
70
+ keep_ids = []
71
+ # Drop all _ids where _last_modified matches cache
72
+ for record in record_ids:
73
+ cached_row = df[df["_id"] == record["_id"]]
74
+ if cached_row.empty or cached_row["_last_modified"].values[0] != record["_last_modified"]:
75
+ keep_ids.append(record["_id"])
76
+
77
+ # Now batch by 100 IDs at a time to avoid overloading server, and fetch all the fields
78
+ BATCH_SIZE = 100
79
+ asset_records = []
80
+ for i in range(0, len(keep_ids), BATCH_SIZE):
81
+ logging.info(f"Fetching asset basics batch {i // BATCH_SIZE + 1}...")
82
+ batch_ids = keep_ids[i: i + BATCH_SIZE]
83
+ batch_records = client.retrieve_docdb_records(
84
+ filter_query={"_id": {"$in": batch_ids}},
85
+ projection={field: 1 for field in FIELDS + ["_id", "_last_modified"]},
86
+ limit=0,
87
+ )
88
+ asset_records.extend(batch_records)
89
+
90
+ # Unwrap nested fields
91
+ records = []
92
+ for record in asset_records:
93
+ modalities = record.get("data_description", {}).get("modalities", [])
94
+ modality_abbreviations = [modality["abbreviation"] for modality in modalities if "abbreviation" in modality]
95
+ modality_abbreviations_str = ", ".join(modality_abbreviations)
96
+
97
+ # Get the process date, convert to YYYY-MM-DD if present
98
+ data_processes = record.get("processing", {}).get("data_processes", [])
99
+ if data_processes:
100
+ latest_process = data_processes[-1]
101
+ process_datetime = latest_process.get("start_date_time", None)
102
+ process_date = process_datetime.split("T")[0]
103
+ else:
104
+ process_date = None
105
+
106
+ # Get the CO asset ID
107
+ other_identifiers = record.get("other_identifiers", {})
108
+ if other_identifiers:
109
+ code_ocean = other_identifiers.get("Code Ocean", None)
110
+ else:
111
+ code_ocean = None
112
+
113
+ flat_record = {
114
+ "_id": record["_id"],
115
+ "_last_modified": record.get("_last_modified", None),
116
+ "modalities": modality_abbreviations_str,
117
+ "project_name": record.get("data_description", {}).get("project_name", None),
118
+ "data_level": record.get("data_description", {}).get("data_level", None),
119
+ "subject_id": record.get("subject", {}).get("subject_id", None),
120
+ "acquisition_start_time": record.get("acquisition", {}).get("acquisition_start_time", None),
121
+ "acquisition_end_time": record.get("acquisition", {}).get("acquisition_end_time", None),
122
+ "code_ocean": code_ocean,
123
+ "process_date": process_date,
124
+ "genotype": record.get("subject", {}).get("subject_details", {}).get("genotype", None),
125
+ "location": record.get("location", None),
126
+ }
127
+ records.append(flat_record)
128
+
129
+ # Combine new records with the old df and store in cache
130
+ new_df = pd.DataFrame(records)
131
+ df = pd.concat([df[~df["_id"].isin(keep_ids)], new_df], ignore_index=True)
132
+
133
+ acorns.TREE.hide(acorns.NAMES["basics"], df)
134
+
135
+ return df
@@ -0,0 +1,71 @@
1
+ """Raw to derived mapping acorn."""
2
+
3
+ import logging
4
+
5
+ import pandas as pd
6
+ from aind_data_access_api.document_db import MetadataDbClient
7
+
8
+ import zombie_squirrel.acorns as acorns
9
+
10
+
11
+ @acorns.register_acorn(acorns.NAMES["r2d"])
12
+ def raw_to_derived(force_update: bool = False) -> pd.DataFrame:
13
+ """Fetch mapping of raw records to their derived records.
14
+
15
+ Returns a DataFrame mapping raw record IDs to lists of derived record IDs
16
+ that depend on them as source data.
17
+
18
+ Args:
19
+ force_update: If True, bypass cache and fetch fresh data from database.
20
+
21
+ Returns:
22
+ DataFrame with _id and derived_records columns."""
23
+ df = acorns.TREE.scurry(acorns.NAMES["r2d"])
24
+
25
+ if df.empty or force_update:
26
+ logging.info("Updating cache for raw to derived mapping")
27
+ client = MetadataDbClient(
28
+ host=acorns.API_GATEWAY_HOST,
29
+ version="v2",
30
+ )
31
+
32
+ # Get all raw record IDs
33
+ raw_records = client.retrieve_docdb_records(
34
+ filter_query={"data_description.data_level": "raw"},
35
+ projection={"_id": 1},
36
+ limit=0,
37
+ )
38
+ raw_ids = {record["_id"] for record in raw_records}
39
+
40
+ # Get all derived records with their _id and source_data
41
+ derived_records = client.retrieve_docdb_records(
42
+ filter_query={"data_description.data_level": "derived"},
43
+ projection={"_id": 1, "data_description.source_data": 1},
44
+ limit=0,
45
+ )
46
+
47
+ # Build mapping: raw_id -> list of derived _ids
48
+ raw_to_derived_map = {raw_id: [] for raw_id in raw_ids}
49
+ for derived_record in derived_records:
50
+ source_data_list = derived_record.get("data_description", {}).get("source_data", [])
51
+ derived_id = derived_record["_id"]
52
+ # 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)
56
+
57
+ # Convert to DataFrame
58
+ data = []
59
+ for raw_id, derived_ids in raw_to_derived_map.items():
60
+ derived_ids_str = ", ".join(derived_ids)
61
+ data.append(
62
+ {
63
+ "_id": raw_id,
64
+ "derived_records": derived_ids_str,
65
+ }
66
+ )
67
+
68
+ df = pd.DataFrame(data)
69
+ acorns.TREE.hide(acorns.NAMES["r2d"], df)
70
+
71
+ return df
@@ -0,0 +1,50 @@
1
+ """Source data acorn."""
2
+
3
+ import logging
4
+
5
+ import pandas as pd
6
+ from aind_data_access_api.document_db import MetadataDbClient
7
+
8
+ import zombie_squirrel.acorns as acorns
9
+
10
+
11
+ @acorns.register_acorn(acorns.NAMES["d2r"])
12
+ def source_data(force_update: bool = False) -> pd.DataFrame:
13
+ """Fetch source data references for derived records.
14
+
15
+ Returns a DataFrame mapping record IDs to their upstream source data
16
+ dependencies as comma-separated lists.
17
+
18
+ Args:
19
+ force_update: If True, bypass cache and fetch fresh data from database.
20
+
21
+ Returns:
22
+ DataFrame with _id and source_data columns."""
23
+ df = acorns.TREE.scurry(acorns.NAMES["d2r"])
24
+
25
+ if df.empty or force_update:
26
+ logging.info("Updating cache for source data")
27
+ client = MetadataDbClient(
28
+ host=acorns.API_GATEWAY_HOST,
29
+ version="v2",
30
+ )
31
+ records = client.retrieve_docdb_records(
32
+ filter_query={},
33
+ projection={"_id": 1, "data_description.source_data": 1},
34
+ limit=0,
35
+ )
36
+ data = []
37
+ for record in records:
38
+ source_data_list = record.get("data_description", {}).get("source_data", [])
39
+ source_data_str = ", ".join(source_data_list) if source_data_list else ""
40
+ data.append(
41
+ {
42
+ "_id": record["_id"],
43
+ "source_data": source_data_str,
44
+ }
45
+ )
46
+
47
+ df = pd.DataFrame(data)
48
+ acorns.TREE.hide(acorns.NAMES["d2r"], df)
49
+
50
+ return df
@@ -0,0 +1,41 @@
1
+ """Unique project names acorn."""
2
+
3
+ import logging
4
+
5
+ import pandas as pd
6
+ from aind_data_access_api.document_db import MetadataDbClient
7
+
8
+ import zombie_squirrel.acorns as acorns
9
+
10
+
11
+ @acorns.register_acorn(acorns.NAMES["upn"])
12
+ def unique_project_names(force_update: bool = False) -> list[str]:
13
+ """Fetch unique project names from metadata database.
14
+
15
+ Returns cached results if available, fetches from database if cache is empty
16
+ or force_update is True.
17
+
18
+ Args:
19
+ force_update: If True, bypass cache and fetch fresh data from database.
20
+
21
+ Returns:
22
+ List of unique project names."""
23
+ df = acorns.TREE.scurry(acorns.NAMES["upn"])
24
+
25
+ if df.empty or force_update:
26
+ # If cache is missing, fetch data
27
+ logging.info("Updating cache for unique project names")
28
+ client = MetadataDbClient(
29
+ host=acorns.API_GATEWAY_HOST,
30
+ version="v2",
31
+ )
32
+ unique_project_names = client.aggregate_docdb_records(
33
+ pipeline=[
34
+ {"$group": {"_id": "$data_description.project_name"}},
35
+ {"$project": {"project_name": "$_id", "_id": 0}},
36
+ ]
37
+ )
38
+ df = pd.DataFrame(unique_project_names)
39
+ acorns.TREE.hide(acorns.NAMES["upn"], df)
40
+
41
+ return df["project_name"].tolist()
@@ -0,0 +1,41 @@
1
+ """Unique subject IDs acorn."""
2
+
3
+ import logging
4
+
5
+ import pandas as pd
6
+ from aind_data_access_api.document_db import MetadataDbClient
7
+
8
+ import zombie_squirrel.acorns as acorns
9
+
10
+
11
+ @acorns.register_acorn(acorns.NAMES["usi"])
12
+ def unique_subject_ids(force_update: bool = False) -> list[str]:
13
+ """Fetch unique subject IDs from metadata database.
14
+
15
+ Returns cached results if available, fetches from database if cache is empty
16
+ or force_update is True.
17
+
18
+ Args:
19
+ force_update: If True, bypass cache and fetch fresh data from database.
20
+
21
+ Returns:
22
+ List of unique subject IDs."""
23
+ df = acorns.TREE.scurry(acorns.NAMES["usi"])
24
+
25
+ if df.empty or force_update:
26
+ # If cache is missing, fetch data
27
+ logging.info("Updating cache for unique subject IDs")
28
+ client = MetadataDbClient(
29
+ host=acorns.API_GATEWAY_HOST,
30
+ version="v2",
31
+ )
32
+ unique_subject_ids = client.aggregate_docdb_records(
33
+ pipeline=[
34
+ {"$group": {"_id": "$subject.subject_id"}},
35
+ {"$project": {"subject_id": "$_id", "_id": 0}},
36
+ ]
37
+ )
38
+ df = pd.DataFrame(unique_subject_ids)
39
+ acorns.TREE.hide(acorns.NAMES["usi"], df)
40
+
41
+ return df["subject_id"].tolist()
@@ -0,0 +1,47 @@
1
+ """Acorns: functions to fetch and cache data from MongoDB."""
2
+
3
+ import logging
4
+ import os
5
+ from collections.abc import Callable
6
+ from typing import Any
7
+
8
+ from zombie_squirrel.forest import (
9
+ MemoryTree,
10
+ S3Tree,
11
+ )
12
+
13
+ # --- Backend setup ---------------------------------------------------
14
+
15
+ API_GATEWAY_HOST = "api.allenneuraldynamics.org"
16
+
17
+ forest_type = os.getenv("FOREST_TYPE", "memory").lower()
18
+
19
+ if forest_type == "S3": # pragma: no cover
20
+ logging.info("Using S3 forest for caching")
21
+ TREE = S3Tree()
22
+ else:
23
+ logging.info("Using in-memory forest for caching")
24
+ TREE = MemoryTree()
25
+
26
+ # --- Acorn registry and names -----------------------------------------------------
27
+
28
+ NAMES = {
29
+ "upn": "unique_project_names",
30
+ "usi": "unique_subject_ids",
31
+ "basics": "asset_basics",
32
+ "d2r": "source_data",
33
+ "r2d": "raw_to_derived",
34
+ }
35
+
36
+ ACORN_REGISTRY: dict[str, Callable[[], Any]] = {}
37
+
38
+
39
+ def register_acorn(name: str):
40
+ """Decorator for registering new acorns."""
41
+
42
+ def decorator(func):
43
+ """Register function in acorn registry."""
44
+ ACORN_REGISTRY[name] = func
45
+ return func
46
+
47
+ return decorator
@@ -11,11 +11,11 @@ import pandas as pd
11
11
  from zombie_squirrel.utils import get_s3_cache_path, prefix_table_name
12
12
 
13
13
 
14
- class Acorn(ABC):
14
+ class Tree(ABC):
15
15
  """Base class for a storage backend (the cache)."""
16
16
 
17
17
  def __init__(self) -> None:
18
- """Initialize the Acorn."""
18
+ """Initialize the Tree."""
19
19
  super().__init__()
20
20
 
21
21
  @abstractmethod
@@ -29,7 +29,7 @@ class Acorn(ABC):
29
29
  pass # pragma: no cover
30
30
 
31
31
 
32
- class S3Acorn(Acorn):
32
+ class S3Tree(Tree):
33
33
  """Stores and retrieves caches using AWS S3 with parquet files."""
34
34
 
35
35
  def __init__(self) -> None:
@@ -79,7 +79,7 @@ class S3Acorn(Acorn):
79
79
  return pd.DataFrame()
80
80
 
81
81
 
82
- class MemoryAcorn(Acorn):
82
+ class MemoryTree(Tree):
83
83
  """A simple in-memory backend for testing or local development."""
84
84
 
85
85
  def __init__(self) -> None:
@@ -0,0 +1,18 @@
1
+ """Synchronization utilities for updating all cached data."""
2
+
3
+ import logging
4
+
5
+ from .acorns import ACORN_REGISTRY
6
+
7
+
8
+ def hide_acorns():
9
+ """Trigger force update of all registered acorn functions.
10
+
11
+ Calls each acorn function with force_update=True to refresh
12
+ all cached data in the tree backend."""
13
+ logging.basicConfig(
14
+ level=logging.INFO,
15
+ format="%(asctime)s %(levelname)s %(message)s"
16
+ )
17
+ for acorn in ACORN_REGISTRY.values():
18
+ acorn(force_update=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zombie-squirrel
3
- Version: 0.7.4
3
+ Version: 0.8.1
4
4
  Summary: Generated from aind-library-template
5
5
  Author: Allen Institute for Neural Dynamics
6
6
  License: MIT
@@ -21,7 +21,7 @@ Dynamic: license-file
21
21
  ![Code Style](https://img.shields.io/badge/code%20style-black-black)
22
22
  [![semantic-release: angular](https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release)
23
23
  ![Interrogate](https://img.shields.io/badge/interrogate-100.0%25-brightgreen)
24
- ![Coverage](https://img.shields.io/badge/coverage-99%25-brightgreen)
24
+ ![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen)
25
25
  ![Python](https://img.shields.io/badge/python->=3.10-blue?logo=python)
26
26
 
27
27
  <img src="zombie-squirrel_logo.png" width="400" alt="Logo (image from ChatGPT)">
@@ -37,10 +37,10 @@ pip install zombie-squirrel
37
37
  ### Set backend
38
38
 
39
39
  ```bash
40
- export TREE_SPECIES='s3'
40
+ export FOREST_TYPE='S3'
41
41
  ```
42
42
 
43
- Options are 's3', 'MEMORY'.
43
+ Options are 'S3', 'MEMORY'.
44
44
 
45
45
  ### Scurry (fetch) data
46
46
 
@@ -4,7 +4,7 @@ pyproject.toml
4
4
  setup.py
5
5
  src/zombie_squirrel/__init__.py
6
6
  src/zombie_squirrel/acorns.py
7
- src/zombie_squirrel/squirrels.py
7
+ src/zombie_squirrel/forest.py
8
8
  src/zombie_squirrel/sync.py
9
9
  src/zombie_squirrel/utils.py
10
10
  src/zombie_squirrel.egg-info/PKG-INFO
@@ -12,7 +12,13 @@ src/zombie_squirrel.egg-info/SOURCES.txt
12
12
  src/zombie_squirrel.egg-info/dependency_links.txt
13
13
  src/zombie_squirrel.egg-info/requires.txt
14
14
  src/zombie_squirrel.egg-info/top_level.txt
15
+ src/zombie_squirrel/acorn_contents/__init__.py
16
+ src/zombie_squirrel/acorn_contents/asset_basics.py
17
+ src/zombie_squirrel/acorn_contents/raw_to_derived.py
18
+ src/zombie_squirrel/acorn_contents/source_data.py
19
+ src/zombie_squirrel/acorn_contents/unique_project_names.py
20
+ src/zombie_squirrel/acorn_contents/unique_subject_ids.py
15
21
  tests/test_acorns.py
16
- tests/test_squirrels.py
17
22
  tests/test_sync.py
23
+ tests/test_trees.py
18
24
  tests/test_utils.py
@@ -0,0 +1,37 @@
1
+ """Unit tests for acorn registry mechanism.
2
+
3
+ Tests for acorn registration and NAMES dictionary."""
4
+
5
+ import unittest
6
+
7
+ from zombie_squirrel.acorns import (
8
+ NAMES,
9
+ ACORN_REGISTRY,
10
+ )
11
+
12
+
13
+ class TestAcornRegistration(unittest.TestCase):
14
+ """Tests for acorn registration mechanism."""
15
+
16
+ def test_acorn_registry_contains_all_functions(self):
17
+ """Test that all acorn functions are registered."""
18
+ self.assertIn(NAMES["upn"], ACORN_REGISTRY)
19
+ self.assertIn(NAMES["usi"], ACORN_REGISTRY)
20
+ self.assertIn(NAMES["basics"], ACORN_REGISTRY)
21
+ self.assertIn(NAMES["d2r"], ACORN_REGISTRY)
22
+ self.assertIn(NAMES["r2d"], ACORN_REGISTRY)
23
+
24
+ def test_registry_values_are_callable(self):
25
+ """Test that registry values are callable functions."""
26
+ for name, func in ACORN_REGISTRY.items():
27
+ self.assertTrue(callable(func), f"{name} is not callable")
28
+
29
+ def test_names_dict_completeness(self):
30
+ """Test that NAMES dict has expected keys."""
31
+ expected_keys = ["upn", "usi", "basics", "d2r", "r2d"]
32
+ for key in expected_keys:
33
+ self.assertIn(key, NAMES)
34
+
35
+
36
+ if __name__ == "__main__":
37
+ unittest.main()