Page MenuHomePhabricator

`get_value_at_timestamp` should exclude deprecated values
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

the bot would believe that as of today the value for this property is Q15242449 when in fact wikidata is asserting that it is Q5.

What should have happened instead?:

now obviously both uses could be what you want but given the name of the function I think Q5 is the right answer. I suggest either changing it or adding an kwarg to specify if a back compat break is no good.

unrelatedly but would you accept pull requests for other similar utility functions? i have some in my repo that I use that could be generally useful.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

name = "pywikibot"
version = "10.5.0"

running against live wikidata

Other information (browser name/version, screenshots, etc.):

tagging Xqt because you seem to be the main (only) dev here? i'm unclear on ownership here

Details

Related Changes in Gerrit:

Event Timeline

I wasn't able to reproduce it.

pwb 10.6:

import pywikibot
item = pywikibot.ItemPage(pywikibot.Site('wikidata'), 'Q4115189')
item.get_value_at_timestamp("P31", pywikibot.WbTime(year=2020, month=1, day=1))
ItemPage('Q5')

pwb 10.5:

import pywikibot
item = pywikibot.ItemPage(pywikibot.Site('wikidata'), 'Q4115189')
item.get_value_at_timestamp("P31", pywikibot.WbTime(year=2020, month=1, day=1))
ItemPage('Q5')

@Strainu: any ideas what happened?

@derenrich:

unrelatedly but would you accept pull requests for other similar utility functions? i have some in my repo that I use that could be generally useful.

You are welcome. You cannot use PR at github but you have to use gerrit instead; see here for more information. A simplier way might be using Gerrit Patch Uploader.

I think it won't reproduce because the contents of the sandbox item has
changed.

Thanks for taking a look.

*Daniel Erenrich* (he/him)
Software Person
Wikimedia Foundation https://wikimediafoundation.org/

i restored the sandbox to a state where it demonstrates the bug

>>> import pywikibot
>>> item = pywikibot.ItemPage(pywikibot.Site('wikidata'), 'Q4115189')
>>> item.get_value_at_timestamp("P31", pywikibot.WbTime(year=2020, month=1, day=1))
ItemPage('Q15242449')

looking at the source i'm unclear if this is an oversight or by design.

the code does have a comment saying

"""Find the first best ranked claim at a given timestamp."""

but unless I'm confused it never checks rank

It's an oversight, working on it.

unrelatedly but would you accept pull requests for other similar utility functions? i have some in my repo that I use that could be generally useful.

Yes please, making it easier to work with Wikidata is extremely useful for me.

Change #1197039 had a related patch set uploaded (by Strainu; author: Strainu):

[pywikibot/core@master] Wikibase: Fix get_value_at_timestamp

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

I'm not sure how to write a reliable test for this, any suggestions are welcome.

i've had trouble testing these kinds of things myself. optimally we'd mock out an item?

Change #1197039 merged by Xqt:

[pywikibot/core@master] Wikibase: Fix get_value_at_timestamp

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