Add backfill script to link subgenre Tags to parent genres - #45
Open
Chisomnwa wants to merge 1 commit into
Open
Conversation
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.
Add backfill script for genre refs on subgenre Tags
Summary
Adds
scripts/backfill_genre_refs.pyto populate thegenrefield on our 24 existing subgenre Tags, linking each subgenre to its parent genre Tag(s). This is step 2 of the Genre Explorer phasing plan (issue #13158).What this does
Reads the parent genre mapping from our subgenre vocabulary (
tag_types/subgenres/vocabulary.json), matches each subgenre to its parent genre Tag key from the genre vocabulary, and writes thegenrereference to each subgenre Tag object on Open Library.Example
Biopunk (
/tags/OL268T) will get:Linking it to Sci-Fi (
/tags/OL179T).Gothic (/tags/OL281T) will get:
Linking it to Horror, Romance, and Literary.
Usage
Dry-run results:

Why we load genre keys from vocabulary, not OL search API
We initially tried querying the OL search API (/search.json) to discover genre Tags, but Tags aren't indexed in Solr yet (@cdrini hasn't indexed them). The search API returns 0 results for Tags.
But, the script doesn't need Solr indexing at all — it uses the OL JSON API (via
olclient) to fetch and save Tags, not the search API.We load genre keys from the vocabulary files instead of querying OL because:
When Tags get indexed in Solr, the search-based approach can be used as an alternative.
Prerequisites
The PR adding
genreproperty to/type/tagmust be merged first PR link~/.config/ol.inimust have bot credentials (for non-dry-run)Usage
Reviewrs
@mekarpeles