Add morph download for a scraper's sqlite database - #25
Open
benrfairless wants to merge 5 commits into
Open
benrfairless wants to merge 5 commits into
benrfairless wants to merge 5 commits into
Conversation
Adds a `morph download [SCRAPER]` command that downloads a scraper's data.sqlite from morph.io into the current directory (or --directory), using the documented API endpoint /<scraper>/data.sqlite?key=<api-key>. When no scraper name is given it is worked out from the git remote of the directory, so `morph download` in a scraper checkout just works. The download streams to a tempfile in the target directory and is only moved over data.sqlite on success, so a failed download leaves an existing database untouched. The API key prompt-and-retry and Faraday error handling previously inlined in `execute` are extracted into shared helpers so both commands behave the same way, with an extra friendly message for a 404 (scraper missing or no database yet). Also removes the now-outdated README limitation about not being able to get the database back. Resolves #3 Assisted-by: OpenCode:anthropic.claude-fable-5 Signed-off-by: Ben Fairless <ben@oaf.org.au>
benrfairless
marked this pull request as ready for review
August 24, 2026 03:33
benrfairless
enabled auto-merge
August 24, 2026 03:33
…o download-sqlite-database
Previously data.sqlite was packed into the tar archive alongside the
scraper code, which meant the filename did not appear as a literal string
in the multipart request body. The test asserts req.body.include?("data.sqlite"),
which requires the filename to appear in a Content-Disposition header.
Send data.sqlite as a named multipart field ("database") with its
original filename so the assertion holds. The file is removed from the
tar paths in both the skip_data and normal paths to avoid double-sending.
Assisted-by: Claude Code:claude-sonnet-4-6
Member
|
@benrfairless - needs conflicts resolved |
…o download-sqlite-database Assisted-by: OpenCode:claude-opus-5
Hoist all_paths.delete(database_path) out of the skip_data conditional as it runs in both branches either way. Assisted-by: Claude Code:claude-sonnet-4-6
ianheggie-oaf
previously requested changes
Aug 24, 2026
ianheggie-oaf
left a comment
Member
There was a problem hiding this comment.
Yup, sentry warning needs fixing
benrfairless
dismissed
ianheggie-oaf’s stale review
September 11, 2026 08:28
Re-requesting the whole team to review
benrfairless
requested review from
a team
and removed request for
ianheggie-oaf
September 11, 2026 08:28
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.
Resolves #3.
What this adds
A
morph download [SCRAPER]command that downloads a scraper'sdata.sqlitefrom morph.io into the current directory (or--directory), using the documented API endpoint/<scraper>/data.sqlite?key=<api-key>. When no scraper name is given, it is worked out from the git remote of the directory, so a baremorph downloadin a scraper checkout just works.--devtargets a local morph as it does forexecute.Design notes
data.sqliteon success, so a failed or interrupted download leaves an existing database untouched and no tempfile behind.executeare extracted into sharedno_commandshelpers, so both commands behave identically on a bad key, unreachable server, or server error.downloadadds a friendlier message for a 404 (unknown scraper, or one that has never produced a database).git config --get remote.origin.url, handling https and ssh GitHub remotes with or without a.gitsuffix.Metrics/ModuleLengthin.rubocop_todo.ymlis bumped from 114 to 143 for the new code inlib/morph-cli.rb; only that one entry changed.Testing
All four CI jobs pass locally:
bundle exec rspec(44 examples, 98% line coverage),bundle exec rubocop(no offenses),bundle exec bundler-audit check --update(no vulnerabilities) andbundle exec rake build. New specs cover the download itself (WebMock, no network), the tempfile/overwrite behaviour, git remote inference, and the CLI including key retry and error paths.AI disclosure: this change was written with OpenCode using model anthropic.claude-fable-5, as also noted in the commit trailer. Reviewed, signed off and driven by @benrfairless.