Skip to content

Commit d874b7f

Browse files
committed
fix: repair OOM, drop broken table, better compression on fib traces
1 parent 5df44aa commit d874b7f

13 files changed

Lines changed: 53 additions & 611 deletions

File tree

src/biodata_cache/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from biodata_cache.cache_table_helpers.platform_smartspim import assets_smartspim # noqa: F401
2626
from biodata_cache.cache_table_helpers.qc import qc, qc_columns # noqa: F401
2727
from biodata_cache.cache_table_helpers.raw_to_derived import raw_to_derived # noqa: F401
28-
from biodata_cache.cache_table_helpers.scientist.scientist_rl_fib import scientist_rl_fib # noqa: F401
2928
from biodata_cache.cache_table_helpers.source_data import source_data # noqa: F401
3029
from biodata_cache.cache_table_helpers.time_to_qc import time_to_qc # noqa: F401
3130
from biodata_cache.cache_table_helpers.unique_genotypes import ( # noqa: F401

src/biodata_cache/backend.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import boto3
99
import duckdb
1010
import pandas as pd
11+
import pyarrow as pa
12+
import pyarrow.parquet as pq
1113

1214
from biodata_cache.utils import BDC_VERSION, CacheLogMessage
1315

@@ -89,7 +91,16 @@ def write(self, table_name: str, data: pd.DataFrame) -> None:
8991
json_key = f"{_CACHE_ROOT}/{_VERSION_FOLDER}/{table_name}.json"
9092

9193
parquet_buffer = io.BytesIO()
92-
data.to_parquet(parquet_buffer, index=False, compression="zstd")
94+
table = pa.Table.from_pandas(data, preserve_index=False)
95+
float_cols = [f.name for f in table.schema if pa.types.is_floating(f.type)]
96+
dict_cols = [f.name for f in table.schema if f.name not in float_cols]
97+
pq.write_table(
98+
table,
99+
parquet_buffer,
100+
compression="zstd",
101+
use_dictionary=dict_cols if dict_cols else False,
102+
column_encoding={col: "BYTE_STREAM_SPLIT" for col in float_cols} or None,
103+
)
93104
parquet_buffer.seek(0)
94105

95106
self.s3_client.put_object(

src/biodata_cache/cache_table_helpers/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
platform_smartspim,
1515
qc,
1616
raw_to_derived,
17-
scientist,
1817
source_data,
1918
time_to_qc,
2019
unique_genotypes,

src/biodata_cache/cache_table_helpers/platform_fib_traces.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ def _fetch_subject_fib_traces(subject_id: str) -> pd.DataFrame:
179179
frames.append(session_df)
180180

181181
df = pd.concat(frames, ignore_index=True) if frames else pd.DataFrame()
182+
if not df.empty:
183+
df = df.sort_values(["asset_name", "channel", "timestamp", "fiber"]).reset_index(drop=True)
182184

183185
_log(f"Cached fib traces for subject {subject_id} ({len(frames)} sessions, {len(df)} samples)")
184186
registry.BACKEND.write(cache_key, df)

src/biodata_cache/cache_table_helpers/scientist/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/biodata_cache/cache_table_helpers/scientist/scientist_rl_fib.py

Lines changed: 0 additions & 250 deletions
This file was deleted.

src/biodata_cache/registry.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"curriculum": "behavior_curriculum",
5555
"platform_qc": "platform_qc",
5656
"time_to_qc": "time_to_qc",
57-
"scientist_rl_fib": "scientist_rl_fib",
5857
"mouselight": "platform_mouselight",
5958
}
6059

0 commit comments

Comments
 (0)