From ab6a6e072701ac7dbd9465020c36d7f904cab227 Mon Sep 17 00:00:00 2001 From: Brian McMahon Date: Thu, 28 May 2026 08:30:20 -0700 Subject: [PATCH] refactor(arcticdb): delegate _open_*_library to lib chokepoint (L2771) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `executor/price_cache.py::_open_universe_library` + `_open_macro_library` now delegate to `alpha_engine_lib.arcticdb.open_universe_lib` / `open_macro_lib` — the lib chokepoint that centralizes S3 URI construction + `get_library` error wrapping across all alpha-engine ArcticDB consumers (data + predictor + executor + research + backtester). Local wrappers retained (not deleted) for two reasons: 1. Existing callers (`load_price_histories`, `load_atr_14_pct`, etc.) keep their import surface unchanged. 2. The module-top `import arcticdb as _arcticdb` (line 23) preserves the macOS allocator-prime invariant — pyarrow's allocator must NOT load before arcticdb's bundled aws-c-common allocator, else `aws_fatal_assert` segfaults on first `get_library()`. Lazy import inside the lib helper would defeat that ordering if the wrapper here were deleted entirely. ROADMAP: **L2771** — _Migrate 6 ArcticDB get_library("universe") sites to alpha_engine_lib.arcticdb_. First of 5 repos (executor); ae-data + ae-predictor + ae-research + ae-backtester follow in sibling PRs. Composes with PR #224 (L1346 c SPY-special-case retirement, OPEN) — both edit `price_cache.py`; textual conflict is trivial. Suite: 1021 passed (no regression). Co-Authored-By: Claude Opus 4.7 (1M context) --- executor/price_cache.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/executor/price_cache.py b/executor/price_cache.py index 9371b0b..f563e45 100644 --- a/executor/price_cache.py +++ b/executor/price_cache.py @@ -57,16 +57,15 @@ def _open_universe_library(signals_bucket: str): those live in the `macro` library; use ``_open_macro_library`` for those. - Hard-fails on connection/library errors per feedback_no_silent_fails. + Thin wrapper over ``alpha_engine_lib.arcticdb.open_universe_lib`` — + the lib chokepoint (L2771) centralizes the S3 URI construction and + `get_library` error-wrapping across all alpha-engine consumers. + Kept as a local wrapper so the existing callers' import surface + stays unchanged and so the macOS allocator-prime invariant + (``import arcticdb`` at module top, BEFORE pandas) is preserved. """ - adb = _arcticdb # already imported at module top for macOS allocator prime - region = os.environ.get("AWS_REGION", "us-east-1") - uri = ( - f"s3s://s3.{region}.amazonaws.com:{signals_bucket}" - f"?path_prefix=arcticdb&aws_auth=true" - ) - arctic = adb.Arctic(uri) - return arctic.get_library("universe") + from alpha_engine_lib.arcticdb import open_universe_lib + return open_universe_lib(signals_bucket) def _open_macro_library(signals_bucket: str): @@ -77,16 +76,11 @@ def _open_macro_library(signals_bucket: str): and builders.backfill. SPY in particular is what the morning freshness gate and EOD reconcile check. - Hard-fails on connection/library errors per feedback_no_silent_fails. + Thin wrapper over ``alpha_engine_lib.arcticdb.open_macro_lib`` — + see ``_open_universe_library`` above for the rationale. """ - adb = _arcticdb - region = os.environ.get("AWS_REGION", "us-east-1") - uri = ( - f"s3s://s3.{region}.amazonaws.com:{signals_bucket}" - f"?path_prefix=arcticdb&aws_auth=true" - ) - arctic = adb.Arctic(uri) - return arctic.get_library("macro") + from alpha_engine_lib.arcticdb import open_macro_lib + return open_macro_lib(signals_bucket) def load_price_histories(