Resolve manager id column in ETL readers - #1364
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 39 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughAdds helper functions in adapters/base.py (is_sqlite, get_table_columns, manager_id_column) to dynamically detect the managers table primary key column name. Updates diff_holdings.py and three ETL flow modules (activism_flow, daily_diff_flow, news_flow) to use this resolver instead of hard-coded column names. Adds a corresponding test. ChangesDynamic manager ID column resolution
Estimated code review effort: 2 (Simple) | ~15 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes ETL manager lookups to work against SQLite databases created via the Manager API (where the primary key column is id), while keeping Postgres behavior intact (where the column is manager_id). It does this by introducing a shared resolver for the managers table PK column and updating multiple ETL readers to use it, plus adding a regression test that exercises the API-created SQLite schema.
Changes:
- Added
manager_id_column()(and supporting schema-introspection helpers) to resolve the managers PK column across SQLite/Postgres. - Updated manager ID reads in
news_flow,daily_diff_flow,activism_flow, anddiff_holdingsto use the resolved column. - Added a regression test that creates the managers table via the API path and asserts ETL readers can load/resolve the inserted manager.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
adapters/base.py |
Adds manager_id_column() and table column introspection utilities used by ETL readers. |
etl/news_flow.py |
Uses resolved manager PK column when selecting managers for entity matching. |
etl/daily_diff_flow.py |
Uses resolved manager PK column when enumerating managers. |
etl/activism_flow.py |
Uses resolved manager PK column for manager row lookup and ID enumeration. |
diff_holdings.py |
Uses resolved manager PK column when resolving a manager by CIK. |
tests/test_etl_flows_additional.py |
Adds regression coverage for API-created SQLite managers schema (id PK). |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@adapters/base.py`:
- Around line 114-115: The exception handling in the table/column lookup logic
is too broad and silently hides real failures. Update the `except Exception`
block in the `adapters.base` lookup path to emit a debug or warning log before
returning `set()`, using the surrounding method name and the exception details
so connectivity, permission, or query errors are visible instead of being
treated like a missing table.
- Around line 101-116: The SQLite branch in get_table_columns still manually
escapes table_name before querying pragma_table_info, which should be replaced
with a bound parameter using the table-valued pragma_table_info(?) form. Update
the is_sqlite(conn) path in get_table_columns to pass table_name as a parameter
to conn.execute instead of interpolating it into the SQL string, and remove the
escaped_table handling entirely.
In `@diff_holdings.py`:
- Around line 69-73: The fallback logic for selecting the manager ID column is
duplicated across multiple call sites and should be centralized. Add a single
helper such as resolve_manager_id_column in adapters/base.py that wraps
manager_id_column(conn) with the sqlite3-vs-default fallback, then replace the
inline fallback in diff_holdings.py and the ETL flows (activism_flow,
daily_diff_flow, news_flow) with that helper so all callers share one consistent
behavior.
In `@etl/news_flow.py`:
- Around line 71-74: `match_entities` is doing repeated schema introspection for
`id_column` on every source, which duplicates the `manager_id_column` lookup and
`managers` query during `news_flow` runs. Resolve the manager ID column once in
`news_flow` (where `match_entities.fn` is invoked per source) and pass that
value into `match_entities`, or add connection-level caching so
`manager_id_column` is not re-run for each call. Keep the change centered around
`news_flow`, `match_entities`, and `manager_id_column`.
In `@tests/test_etl_flows_additional.py`:
- Around line 55-83: The sqlite connection in
test_etl_manager_id_readers_support_api_created_sqlite_schema is only closed at
the end of the test, so a failed assertion can leave it open. Wrap the body of
the test in a try/finally (or use a context-managed connection) so conn.close()
is guaranteed to run even if one of the assertions involving
news_flow.match_entities.fn, daily_flow._fetch_all_manager_ids,
diff_holdings_module._resolve_manager_id, or activism_flow._load_manager_row
fails.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: a2350eba-07c6-4e98-b101-fc1baa69bd76
📒 Files selected for processing (6)
adapters/base.pydiff_holdings.pyetl/activism_flow.pyetl/daily_diff_flow.pyetl/news_flow.pytests/test_etl_flows_additional.py
2ed2cba to
823b220
Compare
|
Closer pushed Changes:
Validation from disposable checkout
Fresh GitHub checks are expected on the new head. |
823b220 to
daf9167
Compare
|
Follow-up push Root cause:
Change:
Additional validation from
Fresh GitHub checks are async on the new head. |
|
Runner dispatch state for codex on PR #1364. Do not edit. |
🤖 Keepalive Loop StatusPR #1364 | Agent: Codex | Iteration 0/12 Current State
Last Codex Run
To retry immediately:
Or wait for the next successful Gate run to automatically retry. Codex output:
🔍 Failure Classification| Error type | infrastructure | 🧠 Task Analysis| Provider | ✅ GitHub Models (primary) |
|
Keepalive Work Log (click to expand)
|
Provider Comparison ReportProvider Summary
📋 Full Provider Details (click to expand)openai
anthropic
Agreement
DisagreementNo major disagreements detected. Unique Insights
🔍 LangSmith Traces |
|
Workflow state fingerprint for Agents Verifier. Do not edit. |
Closes #1302
Summary
idValidation
python -m pytest tests/test_etl_flows_additional.py::test_etl_manager_id_readers_support_api_created_sqlite_schema -qpython -m pytest tests/test_etl_flows_additional.py tests/test_daily_diff.py tests/test_edgar_flow.py::test_fetch_and_store_uses_postgres_safe_persistence tests/test_edgar_flow.py::test_replace_holdings_for_filing_uses_postgres_transaction -qpython -m ruff check adapters/base.py etl/news_flow.py etl/daily_diff_flow.py etl/activism_flow.py diff_holdings.py tests/test_etl_flows_additional.pyblack --fast --check --line-length 100 --exclude "(\.workflows-lib|node_modules)" adapters/base.py etl/news_flow.py etl/daily_diff_flow.py etl/activism_flow.py diff_holdings.py tests/test_etl_flows_additional.pygit diff --checkSummary by CodeRabbit