Repository navigation
feat(crawl): read the discovery strategies a crawl ran with, and save a page as a file - #49
Draft
zenrows-dev-pool[bot] wants to merge 2 commits into
Draft
zenrows-dev-pool[bot] wants to merge 2 commits into
zenrows-dev-pool[bot] wants to merge 2 commits into
Conversation
… a page as a file A crawl reports `discovery`, the strategies it finds URLs with on each page it walks, and a create can ask for them. `links` follows the links in the page's HTML, and is what a crawl runs with when the create leaves it out. The field reads `["links"]` when the server does not send it, so the model parses an older answer too. `content(..., download=True)` asks for the page as a file to save rather than one to show. The text is the same; the server sends a file name built from the content id. `CrawlErrorCode` gains `api_key_cap_reached`, which a crawl ends with when the key that created it reaches one of its credit caps. It parsed as an unknown value before.
… stopped one has none The check that reads a page as a file borrowed the crawl another check stops mid-flight. That stop can land before any page is fetched, and the check then skipped instead of covering anything. It now falls back to a one-item crawl of its own and waits for it, as the check beside it already did.
This branch has not been deployed
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
A crawl reports
discovery, the strategies it found URLs with, and a createcan ask for them. Reading a page takes
download=Trueto get it as a file tosave.
CrawlErrorCodegainsapi_key_cap_reached. The client dropped allthree, so a caller could not see or set what the API already accepts.
What the task asked for
The client had drifted from the API it wraps. Three things the API serves were
missing here. The
discoveryparameter and the field echoing it, thedownloadquery parameter on a page read, and one run error code. Markdownoutput needed nothing: this client already had it.
How the check confirmed it
uv run ruff check,uv run ruff format --check,uv run ty check srcanduv run pytestall pass, 249 tests. This change adds three checks to the Crawlacceptance suite: 22 for
discovery, 23 forcontent(download=True), 24 forthe new error code.
A running Crawl service answered the same way. A create with
discovery=["links"]came back with["links"], and so did a create that leftit out. A create with
output_format="markdown"came back withmarkdown. Aresponse carrying no
discoveryat all still parsed.Encoded by: acceptance checks 22, 23 and 24.How to try it
discoveryreads['links']whether or not you pass it.download=Truereturns the same text, asked for as a file to save.
Provenance
discoveryis optional on the response model with a default of["links"],not required. The API documents that default. An optional field also parses an
answer from a server that does not send it yet. A required one would reject the
whole response instead.
DiscoveryStrategylistslinksonly, and is open like every other enum here,so a value this version does not list keeps its raw string.
Review
models.py:107discoverybroke 16 tests and would reject any response without the field. Fixed before commit: the field is optional with the documented default.One pass, by the author. Human must verify: that the default of
["links"]isthe right reading for a crawl created before
discoveryexisted.Deviations
This change writes no lock file for the surface. Nobody has confirmed the blob
it would record as the one production serves. A lock pointing at an unconfirmed
contract is worse than no lock.
Record owed
None.