FetchPolicy.can_skip - #94
Merged
Merged
Conversation
can_skip is a cheap, one-sided pre-check (bloom-filter style): a policy may return True only when it is certain, from a lightweight per-dataset summary, that an existing dataset is up-to-date. The engine then skips it without loading the full Dataset graph and without reaching should_refetch. Returning False means "unknown" -> fall through to the authoritative path. Base FetchPolicy returns False, so the hook is additive and non-breaking. Red test asserts that, on a second run, can_skip=True skips the fetch (loader never runs) and short-circuits before should_refetch. A regression guard asserts the base policy still reaches should_refetch and refetches (can_skip=False). Implementation (summary type + get_dataset_summary_map + the hook + engine call) follows. Claude-Session: https://claude.ai/code/session_01B5EfLJqoafjW1FhvkxGSmg
Turns the engine's inline timestamp pre-check into a single, overridable policy hook so a policy can skip an up-to-date dataset without loading the full dataset+revision+file graph or reaching should_refetch. - DatasetSummary (+ DatasetSummaryMap): lightweight per-dataset projection (last_modified, current revision created_at/state, has_revisions). - DatasetRepository.get_dataset_summary_map + SqlAlchemy implementation: one grouped "latest revision per dataset" query (portable — no Postgres-only DISTINCT ON, no correlated subquery-in-join), restricted to the provider. - FetchPolicy.can_skip(summary, dataset_resource) -> bool: base keeps the old timestamp behaviour (skip when stored is at least as new as every reported file), so this is additive and non-breaking. One-sided: True only when certain; False = fall through to the authoritative path. - Engine: the inline last_modified pre-check is replaced by a single can_skip call (no duplicate pre-check logic); loader builds the summary map once per (provider, dataset_type). Makes test_can_skip green; existing fast-skip/engine tests unchanged. Claude-Session: https://claude.ai/code/session_01B5EfLJqoafjW1FhvkxGSmg
…-skip # Conflicts: # ingestify/domain/models/dataset/dataset.py # ingestify/domain/models/ingestion/ingestion_job.py
koenvo
force-pushed
the
feat/fetch-policy-can-skip
branch
from
August 12, 2026 09:38
05df951 to
2b9ef37
Compare
get_dataset_summary_map carries last_modified too, so the old map and its DatasetLastModifiedAtMap type alias are redundant. Drop the repository interface method, the SqlAlchemy implementation, the DatasetStore delegation, and the type alias; repoint the fast-skip test to get_dataset_summary_map. Claude-Session: https://claude.ai/code/session_01B5EfLJqoafjW1FhvkxGSmg
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.
FetchPolicy operates on a fully loaded Dataset. This works fine until we have to check 200k+ datasets for each run. In certain cases with more complex FetchPolicies - like "fetch every 2 weeks" - we will check all datasets.
This PR introduces a can_skip method in FetchPolicy which gets a summary of each dataset instead of the full loaded Dataset. The summary is cheap to produce, and works like a bloom-filter: the method will return True when it's certain the dataset can be skipped and a non-True value when the full Dataset needs to be loaded.