Page MenuHomePhabricator

Make sure that Pywikibot still works with new api data output format
Closed, ResolvedPublic

Description

In T95168 the Wikidata api is slightly changed. In the old format if an item doesn't have claims, you won't see claim in the api. In the new format will return '"claims": {}' as part of the output. Same goes for descriptions, aliases and sitelinks. More info at https://www.wikidata.org/wiki/User:Addshore/API_Break_September_2015 . We just need to make sure pywikibot can work with both formats.

Details

Related Changes in Gerrit:

Event Timeline

Multichill raised the priority of this task from to Medium.
Multichill updated the task description. (Show Details)
Multichill added a project: Pywikibot-Wikidata.
Multichill subscribed.

I don't think this is going to be a problem as pywikibot.page.WikibasePage.get is defining an empty dict and then checking if that dict is in the returned data to then just iterate over it: https://phabricator.wikimedia.org/diffusion/PWBC/browse/master/pywikibot/page.py;51f7a894d15e5883053e13de03f14d2f2b46abdf$3306

wbgetentities was returning a entities dict. It is now a list.

https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q943

{
    "entities": {
        "Q943": {
            "pageid": 1827,
            "ns": 0,
            "title": "Q943",
...

https://test.wikidata.org/w/api.php?action=wbgetentities&ids=Q943

{
    "entities": [
        {
            "pageid": 1827,
            "ns": 0,
            "title": "Q943",
...

The fix for T110668 doesnt appear to solve the problem of dict->list for entities.

The 'after' in https://www.wikidata.org/wiki/User:Addshore/API_Break_September_2015#Sample_JSON_changes doesnt show entities has changed to a list. :/

Change 237004 had a related patch set uploaded (by John Vandenberg):
Support new Wikibase entities

https://gerrit.wikimedia.org/r/237004

jayvdb raised the priority of this task from Medium to Unbreak Now!.Sep 9 2015, 12:59 AM

https://gerrit.wikimedia.org/r/237028
Unfortunately the JSON format is poorly tested, so it's going to break again sooner or later.

this might be a bug in wikibase and not intentional. (regarding entities as a dict)

need to poke addshore and see if this is something we can fix quickly

This will be fixed for the release, the keys will be there.
Our API output does have good test coverage, just apparently not of these keys...
As a follow up I will add a JSON integration test for getentities

XZise lowered the priority of this task from Unbreak Now! to Low.Sep 9 2015, 8:57 PM

With the test not failing anymore and the patches have be merged (both request from @jayvdb's post T110559#1618721 have the same structure now) I don't think we'll be further affected by that change.

jayvdb claimed this task.

Latest build passes all wikibase related tests.

Change 237004 abandoned by Xqt:
DataSite.get_entity

Reason:
already solved

https://gerrit.wikimedia.org/r/237004