embed_docsite: download docsite via git clone instead of GitHub contents API - #627
embed_docsite: download docsite via git clone instead of GitHub contents API#627IZO-Ong wants to merge 6 commits into
Conversation
|
Hey @IZO-Ong I've started to run some tests all this and it already feels a lot faster than prod. I got an error at the end but I think that's just my local setup, I'm gonna explore it now. I'll try and get full testing and review done today. I might have to ask you to rebase on a different PR which adds an important fix that's related. |
josephjclark
left a comment
There was a problem hiding this comment.
Looking great @IZO-Ong thank you for this
I've left some feedback about structure and style.
We probably need to rebase this on top of #623 because I think they overlap a bit.
I think maybe first you should refactor here per my comments, then we should merge this and 623 into a merge branch, and then into main.
|
Hi all, I've updated the branch based on your comments (thank you!). Please feel free to re-review the changes so that we can merge / rebase into PR #623 if needed. |
Short Description
Replaces
embed_docsite's recursive GitHub Contents API walk with a shallow, blobless and sparsegit cloneofOpenFn/docs.Fixes #182
Implementation Details
The old
github_utils.pyfetchedgeneral_docs/adaptor_docsone directory at a time viaapi.github.com/.../contents/{path}(~22 requests for OpenFn/docs, against a 60/hour unauthenticated limit), then downloaded each file individually. This PR ships two commits 4315b60 (for naivegit clone --depth 1) and 4508e30 (for a more optimized git clone using--filter=blob:none --sparse, checked out to onlydocs/andadaptors/, thus avoiding downloading static assets and images).adaptor_functionsis untouched.New module
services/embed_docsite/docs_repo.pyholds all git/filesystem access behind one subprocess seam (_run_git) for unit-testing.sync_docs_repo()clones on the first call in a process andfetch+reset --hards on every call after. If a refresh fails and a checkout already exists, the existing copy is served and a warning is logged; the run only fails if there's no checkout to fall back on, similar tolatest_adaptors.py's cache.Measurements
git clone --depth 1(commit 1)The sparse clone's corpus was verified byte-identical to the naive clone's by hashing the full
get_docsoutput (sha256 of sorted-key JSON).Next steps
If the optimized, blobless / sparse
git cloneis ok, we can change the command fordockerfileon line 17 to use the optimized version instead.AI Usage
Please disclose whether you've used AI in this work (it's cool, we just want to
know!):
You can read more details in our
Responsible AI Policy