MaRDI4NFDI / docker-importer

Import data from external data sources into the portal
https://mardi4nfdi.github.io/docker-importer
0 stars 0 forks source link

Wikidata importer fails with some items #144

Closed eloiferrer closed 3 months ago

eloiferrer commented 3 months ago

Describe the bug The wikidata importer (import_entitites function) fails when importing some specific items. For instance, the item Software (Q7397) cannot be imported.

  File "/usr/local/lib/python3.11/site-packages/wikibaseintegrator/models/claims.py", line 128, in from_json
    data_type = [x for x in BaseDataType.subclasses if x.DTYPE == claim['mainsnak']['datatype']][0]
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Expected behavior The items should be imported without errors.

To Reproduce Steps to reproduce the behavior:

  1. Run .import_entities('Q7397')

Screenshots (If applicable, add screenshots to help explain your problem.)

Additional context Add any other context about the problem here.

Checklist for this issue: (Some checks for making sure this issue is completely formulated)

eloiferrer commented 3 months ago

The error is caused due to the 'entity-schema' datatype not being recognized by wikibaseintegrator.

As a hack before we find a more permanent solution, just edit:

/usr/local/lib/python3.11/site-packages/wikibaseintegrator/models/claims.py

in line 128 to contain this:

if 'datatype' in claim['mainsnak']:
    if claim['mainsnak']['datatype'] == 'entity-schema':
        data_type = BaseDataType
    else:
        data_type = [x for x in BaseDataType.subclasses if x.DTYPE == claim['mainsnak']['datatype']][0]

instead of just

if 'datatype' in claim['mainsnak']:
        data_type = [x for x in BaseDataType.subclasses if x.DTYPE == claim['mainsnak']['datatype']][0]
eloiferrer commented 3 months ago

This has been fixed with https://github.com/MaRDI4NFDI/docker-importer/commit/d366d50250c56b8969d19799320f7df8ed89385a and the latest release of WikibaseIntegrator.