Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ jobs:
AIRTABLE_BASE_ID: ${{ vars.AIRTABLE_BASE_ID }}
WIKIDATA_BOT_PW: ${{ secrets.WIKIDATA_BOT_PW }}
WIKIDATA_BOT_USERNAME: ${{ secrets.WIKIDATA_BOT_USERNAME }}
WIKIDATA_MAX_RESULTS_PER_SEARCH: ${{ vars.WIKIDATA_MAX_RESULTS_PER_SEARCH }}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Core fix making results configurable to reduce noise and airtable limits.

1 change: 1 addition & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ jobs:
AIRTABLE_BASE_ID: ${{ vars.AIRTABLE_BASE_ID }}
WIKIDATA_BOT_PW: ${{ secrets.WIKIDATA_BOT_PW }}
WIKIDATA_BOT_USERNAME: ${{ secrets.WIKIDATA_BOT_USERNAME }}
WIKIDATA_MAX_RESULTS_PER_SEARCH: ${{ vars.WIKIDATA_MAX_RESULTS_PER_SEARCH }}
505 changes: 254 additions & 251 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = [
readme = "README.md"
requires-python = "<4.0,>=3.13"
dependencies = [
"wikibaseintegrator (>=0.12.12,<0.13.0)",
"wikibaseintegrator @ git+https://github.com/LeMyst/WikibaseIntegrator.git@301067883ddce0bca31fdd54973c3d6c8cbbcb7d",

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is temporary to get around a login issue.

"pyairtable (>=3.1.1,<4.0.0)",
"more_itertools"
]
Expand Down
4 changes: 4 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ class airtable:

wbi = WikibaseIntegrator()

WIKIDATA_MAX_RESULTS_PER_SEARCH: int = int(
os.getenv("WIKIDATA_MAX_RESULTS_PER_SEARCH", 50)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

using 50 to match the library's default, but realistically, we probably want just 5, which is what I've set in the public repo var

)


LANGUAGE_CODE = "en"
4 changes: 3 additions & 1 deletion src/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
types = ctfg.summarize_types(items)
(unmatched_items, matched_items) = ctfg.partition_matched(items)

wiki_matches = wiki.get_matches(unmatched_items, max_attempts=5)
wiki_matches = wiki.get_matches(
unmatched_items, max_attempts=5, max_results=config.WIKIDATA_MAX_RESULTS_PER_SEARCH
)
# wiki_match_histogram = wiki.summarize_matches(wiki_matches)

# matched_wikis = wiki.get_jsons(matched_items)
Expand Down
9 changes: 7 additions & 2 deletions src/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@


def get_matches(
items: list[ctfg.Listing], max_attempts=None, from_cache=False
items: list[ctfg.Listing],
max_attempts=None,
from_cache=False,
max_results: int = 50,
) -> dict[ctfg.Listing, list[dict[str, Any]]]:
matchable_items = [x for x in items if x.name]
attempting_items = (
Expand All @@ -27,7 +30,9 @@ def get_matches(
else:
wiki_matches = {}
for x in attempting_items:
raw_matches = search_entities(x.name, "en", dict_result=True)
raw_matches = search_entities(
x.name, config.LANGUAGE_CODE, dict_result=True, max_results=max_results

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

also configured language here where it was previously missed

)
wiki_matches[x] = raw_matches

if not max_attempts:
Expand Down