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

WikibaseIntegrator cannot write to empty MediaInfo files #836

Open
lubianat opened this issue Feb 11, 2025 · 4 comments
Open

WikibaseIntegrator cannot write to empty MediaInfo files #836

lubianat opened this issue Feb 11, 2025 · 4 comments
Assignees

Comments

@lubianat
Copy link
Contributor

lubianat commented Feb 11, 2025

EDIT: Previous title was Some mediainfo IDs are not returning results --> The MW API returned that the entity was missing., changed to reflect updates.

Hi!

I continue working with mediainfo, and now I am running into this issue:

Image

Code:

from wikibaseintegrator import wbi_login, WikibaseIntegrator, wbi_enums
from wikibaseintegrator.wbi_config import config as wbi_config


wbi_config['MEDIAWIKI_API_URL'] = 'https://commons.wikimedia.org/w/api.php'
wbi_config['SPARQL_ENDPOINT_URL'] = 'https://query.wikidata.org/sparql'
wbi_config['WIKIBASE_URL'] = 'https://commons.wikimedia.org'
wbi_config['USER_AGENT'] = 'TiagoLubiana (https://meta.wikimedia.org/wiki/User:TiagoLubiana)'

wbi = WikibaseIntegrator()

mediainfo_id = 'M44422187'

media = wbi.mediainfo.get(entity_id=mediainfo_id)

The issue only happens for some MediaInfo ids.

E.g. M91125720 works fine, but M44422187 does not.

The website does not return the .ttl for these entries too, e.g.

https://commons.wikimedia.org/wiki/Special:EntityData/M44422187.ttl

leads to

Image

but the entry resolves just fine:

https://commons.wikimedia.org/entity/M44422187

I realize this is not a WikibaseIntegrator issue, and I'll try and report it on Phabricator. Leaving it for information.

@lubianat
Copy link
Contributor Author

Well, it looks like the files do not have structured data yet (as Lucas Werkmeister noted on Telegram). Maybe it is just a matter of how the API is returning this error.

@lubianat
Copy link
Contributor Author

This is a noticeble inconsistency with QIDs — there are no empty QIDs as far as I can tell.

@lubianat lubianat changed the title Some mediainfo IDs are not returning results --> The MW API returned that the entity was missing. WikibaseIntegrator cannot write to empty MediaInfo files Feb 11, 2025
@lubianat
Copy link
Contributor Author

@LeMyst Thankfully there was a simple workaround:

           except Exception as e:
                if "The MW API returned that the entity was missing." in str(e):
                    media = wbi.mediainfo.new(id=mediainfo_id)

I did not find this in the documentation though, and maybe the message could be a bit more clear on the WikibaseIntegrator end?

I will open a ticket on Phab anyways

@LeMyst
Copy link
Owner

LeMyst commented Feb 12, 2025

Hello @lubianat
Thanks for opening an issue.

I don't think it's a WikibaseIntegrator related issue, we correctly have a MissingEntityException and that's what we want.
I think there was a temporary issue on commons side related to MediaInfos, because today the link https://commons.wikimedia.org/wiki/Special:EntityData/M44422187.ttl works correctly for me and the code you provided works correctly for me too.

Do you think WBI need some improvement for this case (more than the Exception)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants