Repository navigation
feat: external events ingestion and normalization - #42
Merged
Merged
Conversation
Alexcchip
force-pushed
the
external-factors-events
branch
2 times, most recently
from
October 7, 2026 22:31
eb7be70 to
d147226
Compare
Alexcchip
force-pushed
the
external-factors-events
branch
from
October 7, 2026 22:45
a6cab78 to
414479a
Compare
selvarajuv
force-pushed
the
external-factors-events
branch
3 times, most recently
from
October 11, 2026 00:10
d4ab031 to
17bf7ff
Compare
selvarajuv
approved these changes
Oct 11, 2026
selvarajuv
force-pushed
the
external-factors-events
branch
from
October 11, 2026 00:21
17bf7ff to
11dc877
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#8
Type of change
Addition of ingestion from PredictHQ and AskNews APIs as well as a normalized form that all future events should follow
feat— new featurefix— bug fixdocs— documentation onlyrefactor— code change that neither fixes a bug nor adds a featureperf— performance improvementtest— adding or updating testschore/build/ci— tooling, deps, or pipeline changesChanges
ingest/normalize.py— the shared contract.NormalizedEventvalidates on construction;dedupe_key= normalized title + city slug + local start date. Category is excluded from the key on purpose: the sources disagree on it, and that must not split one event into two rows.ingest/predicthq.py— structured listings near a point, paged byupdated.gte. Requestsdeletedstate explicitly so upstream cancellations propagate instead of inflating demand forever.ingest/asknews.py+ingest/textdates.py— infers events from news articles: one scoped search per city, prose date resolution ("August 28-30, 2026", "Q3 2027") with the precision achieved recorded rather than rounded, and a named reject reason for everything dropped.ingest/repository.py—upsert_event, source-agnostic. Resolves by(source, source_ref)beforededupe_key, because a revised start date changes the key and resolving by key first would orphan the original row. PredictHQ outranks AskNews on contested fields.ingest/run.py— ingest CLI, with--dry-runto fetch and print without writing.scripts/run_asknews.py— AskNews runner with the per-run cleaning report; replays recorded batches by default,--livecalls the API.docs/event-extraction.md— architecture, file inventory, real run output for both sources, and how to test.httpx, promotesscikit-learnto a runtime dependency.events(one merged row per occurrence) andevent_observations(append-only, one row per source sighting, raw payload kept verbatim).Database migrations
just migrate-create "...")just migrate) and rolls back (just migrate-down)Checklist
just lint) and code is formatted (just format)just hooksinstalled).env.examplewhere relevantjust dev) and verified the API athttp://localhost:8000/docsHow to test
cd backend && uv run python scripts/run_asknews.py --dry-runNotes for reviewers
At the end I added a .commit() to DB to test but this should be removed when we move to an API
Check to see if the normalized form is going to fit what we need