skybristol / geokb

Data processing workflows for initializing and building the Geoscience Knowledgebase
The Unlicense
3 stars 3 forks source link

Problem in pywikibot.ItemPage.get() method #1

Closed skybristol closed 1 year ago

skybristol commented 1 year ago

I'm stuck right now in my notebook approach on initializing the GeoKB in adding claims. Once I add a claim to an item with either pywikibot or the Wikibase GUI, I'm seeing an error that doesn't seem to have much information behind it whenever trying to run a get() on the item.

DataSite instance has no attribute 'entity_sources'

This essentially results in the item being dead at that point, because I can't work with it to examine claims and add anything else. I can, however, run a sparql query and get the claim information that was added and it shows up in the GUI just fine.

J-Oliveros commented 1 year ago

I tried replicating your issue with the nb you created, but I can't seem to get the error you're getting my output

I thought maybe it was because I was logged in as an admin so I created my own account and tried again, but that didn't come up with any errors. Here is my version of pywikibot, maybe that will help solve the issue

pwb --version
Pywikibot: pywikibot/__init__.py (, -1 (unknown), 2023/02/21, 10:32:37, UNKNOWN)
Release version: 8.0.0
setuptools version: 65.6.3
mwparserfromhell version: 0.6.4
wikitextparser version: 0.51.1
requests version: 2.28.2
  cacerts: /home/joliveros/miniconda3/envs/geokb/lib/python3.10/site-packages/certifi/cacert.pem
    certificate test: ok
Python: 3.10.9 (main, Jan 11 2023, 15:21:40) [GCC 11.2.0]
PYWIKIBOT_DIR: Not set
PYWIKIBOT_DIR_PWB: /home/joliveros/miniconda3/envs/geokb/lib/python3.10/site-packages/pywikibot/scripts
PYWIKIBOT_NO_USER_CONFIG: Not set
Config base dir: /mnt/c/Xentity/USGS/geokb
Usernames for family 'geokb':
        en: Joliveros

Another thing I looked into was where the method was being called. This family file has that added in, maybe you could repurpose the method within the geokb_family.py file and try again to see if that fixes it.

skybristol commented 1 year ago

Thanks for checking on this @J-Oliveros. You may have tried hitting item Q33 after I'd removed the claim. I don't get an error with that one either. I tried again this morning and am still seeing the issue on any ItemPage that has a claim like Q6. Here's a barebones snippet:

import pywikibot as pwb

test_site = pwb.Site('en', 'geokb')
test_site.login()
test_repo = test_site.data_repository()
test_item = pwb.ItemPage(test_repo, 'Q6')
test_item.get()

My version of pywikibot is the same, and the environment is not far off.

pwb --version
Pywikibot: pywikibot/__init__.py (, -1 (unknown), 2023/02/17, 07:38:05, UNKNOWN)
Release version: 8.0.0
setuptools version: 67.3.2 
mwparserfromhell version: 0.6.4
wikitextparser version: 0.51.1
requests version: 2.28.2
  cacerts: /opt/anaconda3/envs/geokb/lib/python3.11/site-packages/certifi/cacert.pem
    certificate test: ok
Python: 3.11.0 | packaged by conda-forge | (main, Jan 15 2023, 05:44:48) [Clang 14.0.6 ]
PYWIKIBOT_DIR: Not set
PYWIKIBOT_DIR_PWB: /opt/anaconda3/envs/geokb/lib/python3.11/site-packages/pywikibot/scripts
PYWIKIBOT_NO_USER_CONFIG: Not set
Config base dir: /opt/anaconda3/envs/geokb
skybristol commented 1 year ago

I messed around further with the ItemPage object and methods. the get() operation does not work, still but I got around it. I just need to keep learning the myriad methods for operating on page objects of different kinds. We can use ItemPage against the site.data_repository() with any identifier and the simple exists() function to check its existence.

I've reworked my item processing functions in the latest version of the notebook and think I have a reasonable pathway. I'll keep plugging on the claims processing next.