osm-quality / wikibrain

Stores knowledge and data necessary to properly use links from OpenStreetMap to Wikipedia, Wikidata and Wikimedia Commons.
MIT License
4 stars 1 forks source link

Fix #9 #12

Open KasperFranz opened 5 months ago

KasperFranz commented 5 months ago

This PR fixes the reported issue

matkoniecz commented 5 months ago

Curiously, tests fail for me with

======================================================================
ERROR: test_well_formed_nonexisting_wikidata (test_wikimedia_link_issue_reporter.Tests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mateusz/Documents/install_moje/OSM_software/wikibrain_py_package_published/test_wikimedia_link_issue_reporter.py", line 173, in test_well_formed_nonexisting_wikidata
    self.assertNotEqual(None, self.detector().critical_structural_issue_report('node', {'wikidata': 'Q812843783738234723482347238272487927', 'wikipedia': 'en:Oslo'}))
  File "/home/mateusz/Documents/install_moje/OSM_software/wikibrain_py_package_published/wikibrain/wikimedia_link_issue_reporter.py", line 316, in critical_structural_issue_report
    something_reportable = self.check_is_wikidata_page_existing(key, tags.get(key))
  File "/home/mateusz/Documents/install_moje/OSM_software/wikibrain_py_package_published/wikibrain/wikimedia_link_issue_reporter.py", line 520, in check_is_wikidata_page_existing
    wikidata = wikimedia_connection.get_data_from_wikidata_by_id(present_wikidata_id)
  File "/home/mateusz/.local/lib/python3.8/site-packages/wikimedia_connection/wikimedia_connection.py", line 561, in get_data_from_wikidata_by_id
    if it_is_necessary_to_reload_wikidata_by_id_files(wikidata_id) or forced_refresh:
  File "/home/mateusz/.local/lib/python3.8/site-packages/wikimedia_connection/wikimedia_connection.py", line 592, in it_is_necessary_to_reload_wikidata_by_id_files
    content_filename = get_filename_with_wikidata_entity_by_id(wikidata_id)
  File "/home/mateusz/.local/lib/python3.8/site-packages/wikimedia_connection/wikimedia_connection.py", line 440, in get_filename_with_wikidata_entity_by_id
    return os.path.join(cache_location(), cache_folder_name(), wikidata_language_placeholder(), get_form_of_link_usable_as_filename(id) + ".wikidata_entity.txt")
  File "/home/mateusz/.local/lib/python3.8/site-packages/wikimedia_connection/wikimedia_connection.py", line 430, in cache_location
    assert cache_location_store != None, "wikimedia_connection.set_cache_location must be called before that point"
NameError: name 'cache_location_store' is not defined

etc. I will try to look is it broken on my side.

KasperFranz commented 5 months ago

That is interesting, leave it with me to verify a few things

KasperFranz commented 5 months ago

I have just pushed a fix for that, it seems like the library my IDE is using a new style, whereas the module is using the uppercase version

matkoniecz commented 5 months ago

I am still getting NameError: name 'cache_location_store' is not defined

KasperFranz commented 5 months ago

With the last changes pushed by you, do you still get the issue?

if you are what commands are you running?

KasperFranz commented 5 months ago

I have pushed in a test helper and moved to use a local cache directory for the test (this makes it possible to clear the test cache without having to clear the global cache)