Skip to content

[AGE-383] Refactor Postgres/PostGIS import - #83

Merged
gregsaab merged 20 commits into
mainfrom
greg/AGE-383_refactor_ingestion
Feb 26, 2026
Merged

[AGE-383] Refactor Postgres/PostGIS import#83
gregsaab merged 20 commits into
mainfrom
greg/AGE-383_refactor_ingestion

Conversation

@gregsaab

@gregsaab gregsaab commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

What

Refactor postgres_docs.py and postgis_docs.py so we can share functionality between the two.

Other changes:

  • add vscode launch/tasks for debugging
  • add ruff rules
  • add workflows for prod/dev

Why

This is a follow up to a external PR submission -- decision was to merge that PR then address refactoring.

Testing

I tested postgres and postgis locally and verified that the outputs look good. I scanned through all of the chunks and spot checked a bunch of them.

I have attached the outputs from both
postgres.json
postgis.json

Related PR

#59

Comment thread ingest/tiger_docs.py
@@ -1,43 +1,46 @@
from scrapy.spiders import SitemapSpider
from scrapy.crawler import CrawlerProcess

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only change in this is to use constants, the rest is ruff reformatting

Comment thread ingest/constants.py
) # Default model

MIN_CHUNK_TOKENS = 10 # anything less provides no value
MAX_CHUNK_TOKENS = 8191

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did up this from 7000 to match the actual max from OPENAI

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why 7000 was chosen? Might be some inconsistency in how tokens are counted by the client vs api? But 1191 is a huge margin.

I think this is the right call, just need to keep an eye out for problems.

Comment thread ingest/constants.py
@@ -0,0 +1,26 @@
import os
from pathlib import Path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these were defined all of the place, consolidated

from psycopg.sql import SQL, Identifier


class DocumentImporter(ABC):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

postgres & postgres imports are so similar, created a base class to create a base structure

@murrayju murrayju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only lightly skimmed, but lgtm 👍

Comment thread ingest/constants.py
) # Default model

MIN_CHUNK_TOKENS = 10 # anything less provides no value
MAX_CHUNK_TOKENS = 8191

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why 7000 was chosen? Might be some inconsistency in how tokens are counted by the client vs api? But 1191 is a huge margin.

I think this is the right call, just need to keep an eye out for problems.

@gregsaab
gregsaab merged commit 55d79be into main Feb 26, 2026
3 checks passed
@gregsaab
gregsaab deleted the greg/AGE-383_refactor_ingestion branch February 26, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants