Heuristic:AGI Edgerunners LLM Agents Papers Incremental Skip Existing
| Knowledge Sources | |
|---|---|
| Domains | Optimization, Data_Collection, File_Download |
| Last Updated | 2026-10-10 14:30 GMT |
Overview
Incremental processing pattern that skips items already processed in previous runs, enabling safe re-runs without redundant work or duplicate network requests.
Description
The incremental skip-existing pattern checks whether an item has already been processed before performing expensive work (network crawl, file download). In the crawl phase, URLs are keyed by MD5 hash and checked against the in-memory store loaded from existing JSON files. In the download phase, the output file path is checked for existence before initiating the HTTP download.
This pattern makes the pipeline idempotent: running it multiple times produces the same result. Failed items from a previous run are automatically retried on the next run, while successful items are skipped.
Usage
Use this heuristic when:
- Running a long pipeline that may be interrupted or fail partway through
- You want to add new items to the seed list and re-run to process only the additions
- Network requests are expensive or rate-limited and should not be repeated
- You need to resume a partially-completed download or crawl job
The Insight (Rule of Thumb)
- Action: Before processing each item, check if it already exists in the output store or filesystem.
- Value: For crawl: if not parsed and url.startswith('https://arxiv.org/abs/'): — only crawl URLs not already in all_parsed_datas. For download: if not os.path.exists(pdf_file): — only download files not already on disk.
- Trade-off: Requires loading all existing data into memory on startup (crawl) or doing a filesystem stat per file (download). Both are cheap relative to network I/O.
- Compatibility: Works with any keying scheme (MD5 hash, URL, filename). The MD5 key ensures URL version changes (e.g., v1 → v2) create new entries.
Reasoning
Loading existing parsed data into all_parsed_datas (keyed by MD5 hash of URL) at startup costs one file-read per JSON file. This is negligible compared to the cost of re-crawling hundreds of arXiv pages. The MD5 hash of the full URL (including version suffix) means that if arXiv updates a paper to a new version, the old entry remains and a new entry is created — no data is lost.
For PDF downloads, checking os.path.exists(pdf_file) is a single filesystem stat call — orders of magnitude cheaper than an HTTP request. This allows re-running the download script to fill in any missing files without re-downloading completed ones.
Code Evidence
Incremental crawl skip in parse_paper (script_v5_step1.py:L123-141):
# Load all existing parsed data into memory
files = os.listdir(PARSED_FOLDER)
for file_name in files:
year = file_name.split('.')[0]
parsed_datas = read_json(f"{PARSED_FOLDER}/{file_name}")
stored_datas[year] = parsed_datas
all_parsed_datas.update(parsed_datas)
datas = read_json(URL_FILE)
for data_idx, data in enumerate(datas):
url = data.get('url', '')
md5_id = md5(url.encode()).hexdigest()
parsed = {}
if url:
parsed = all_parsed_datas.get(md5_id, {}) # Skip if already parsed
if not parsed and url.startswith('https://arxiv.org/abs/'):
parsed = parse_by_crawl(url) # Only crawl new URLs
Incremental download skip in download_pdf.py:L67-69:
if not os.path.exists(pdf_file):
print(f'{pdf_link} downloading...')
pdf_downloader(pdf_link, pdf_file)
print(f'{pdf_link} save to {pdf_file}')