RDFLib/VocPrez

config template inconsistent with code for VocabSource FILE

Opened this issue · 0 comments

When configuring VocPrez to run with the example files provided in data/vocab_files by adapting the default template (_config/template.py) I use the following configuration.

DATA_SOURCES = {
    # example SPARQL source configured using variables in "Instance Vars" above
    "defaults": {
        "source": VocabSource.FILE,
        "directory":"/home/user/src/VocPrez/vocprez/data"
    }

VocPrez throws an error when trying to load the dataset:

ERROR:vocprez.app:Exception on / [GET]
Traceback (most recent call last):
  File "/home/user/src/VocPrez/vocenv/lib/python3.8/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/user/src/VocPrez/vocenv/lib/python3.8/site-packages/flask/app.py", line 1518, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/user/src/VocPrez/vocenv/lib/python3.8/site-packages/flask/app.py", line 1514, in full_dispatch_request
    rv = self.preprocess_request()
  File "/home/user/src/VocPrez/vocenv/lib/python3.8/site-packages/flask/app.py", line 1857, in preprocess_request
    rv = self.ensure_sync(before_func)()
  File "/home/user/src/VocPrez/vocprez/app.py", line 63, in before_request
    u.cache_reload()
  File "/home/user/src/VocPrez/vocprez/utils.py", line 93, in cache_reload
    cache_load()
  File "/home/user/src/VocPrez/vocprez/utils.py", line 83, in cache_load
    getattr(source, source_details["source"]).collect(source_details)
AttributeError: module 'vocprez.source' has no attribute 'FILE'

I was able to fix this by changing the capitalization in VocabSource to match the definition of the File class

class VocabSource:
    File= "File"
    SPARQL = "SPARQL"
    RVA = "RVA"
    VOCBENCH = "VOCBENCH"
    GITHUB = "GITHUB"

and

DATA_SOURCES = {
    # example SPARQL source configured using variables in "Instance Vars" above
    "defaults": {
        "source": VocabSource.File,
        "directory":"/home/user/src/VocPrez/vocprez/data"
    }

I suppose this could also be done by changing the File class to FILE .