Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up requests for partner imports #10175

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scripts/partner_batch_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from infogami import config # noqa: F401 side effects may be needed
from openlibrary.config import load_config
from openlibrary.core.imports import Batch
from openlibrary.plugins.openlibrary.code import setup_requests
from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI

logger = logging.getLogger("openlibrary.importer.bwb")
Expand Down Expand Up @@ -82,6 +83,8 @@
"/openlibrary-client/master/olclient/schemata/import.schema.json"
)

required_fields = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
required_fields = None
required_fields = []

In service of getting the tests passing, how about this?



class Biblio:
ACTIVE_FIELDS = [
Expand All @@ -107,7 +110,6 @@ class Biblio:
"width",
"height",
]
REQUIRED_FIELDS = requests.get(SCHEMA_URL).json()['required']

NONBOOK = """A2 AA AB AJ AVI AZ BK BM C3 CD CE CF CR CRM CRW CX D3 DA DD DF DI DL
DO DR DRM DRW DS DV EC FC FI FM FR FZ GB GC GM GR H3 H5 L3 L5 LP MAC MC MF MG MH ML
Expand All @@ -116,6 +118,9 @@ class Biblio:
VU VY VZ WA WC WI WL WM WP WT WX XL XZ ZF ZZ""".split()

def __init__(self, data):
global required_fields
self.REQUIRED_FIELDS = required_fields

self.primary_format = data[6]
self.product_type = data[121]
assert (
Expand Down Expand Up @@ -312,7 +317,11 @@ def batch_import(path, batch, batch_size=5000):


def main(ol_config: str, batch_path: str):
global required_fields

load_config(ol_config)
setup_requests()
required_fields = requests.get(SCHEMA_URL).json()['required']

# Partner data is offset ~15 days from start of month
date = datetime.date.today() - datetime.timedelta(days=15)
Expand Down
Loading