DerwenAI / kuzu-rdflib

An integration of KùzuDB and RDFlib.
MIT License
10 stars 2 forks source link

Unable to register plugin #7

Open ericthomas1 opened 2 days ago

ericthomas1 commented 2 days ago

Hello,

This code:

import json
import logging
import rdflib

logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

def main():

    rdflib.plugin.register(
        "kuzudb",
        rdflib.store.Store,
        "graph",
        "PropertyGraph",
    )

    # Create an RDF graph instance
    graph = rdflib.Graph(
        store = "kuzudb",
        identifier = "kuzudb",
    )

    # Populate the configuration data

    config_data: str = json.dumps({
        "db_path": "db",
        "db_name": "UniKG",
    })

    # Open the RDF graph
    graph.open(
        configuration = config_data,
        create = True,
    )

if __name__ == '__main__':
    main()

Returns this error:

Traceback (most recent call last):
  File "C:\Users\me\Documents\projects\kuzu-graph\register_plugin.py", line 37, in <module>
    main()
  File "C:\Users\me\Documents\projects\kuzu-graph\register_plugin.py", line 18, in main
    graph = rdflib.Graph(
            ^^^^^^^^^^^^^
  File "C:\Users\me\Documents\projects\kuzu-graph\.venv\Lib\site-packages\rdflib\graph.py", line 458, in __init__
    self.__store = store = plugin.get(store, Store)()
                           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\Documents\projects\kuzu-graph\.venv\Lib\site-packages\rdflib\plugin.py", line 137, in get
    return p.getClass()
           ^^^^^^^^^^^^
  File "C:\Users\me\Documents\projects\kuzu-graph\.venv\Lib\site-packages\rdflib\plugin.py", line 101, in getClass
    module = __import__(self.module_path, globals(), locals(), [""])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'graph'

I'm following the tutorial in the Kuzu Blog here. I've already created the database. Not really sure how to get past this. Could you provide some assistance?

Thank you

prrao87 commented 2 days ago

Hi @ericthomas1 could you list what versions of the rdflib and kuzu packages you used/installed?

ericthomas1 commented 2 days ago

Hi @prrao87 ,

rdflib==7.1.1
kuzu==0.6.1
prrao87 commented 2 hours ago

Hi @ericthomas1, please see #8 for the fix. You can hopefully resolve the issue by pinning the right versions of the dependencies (I tested on macOS and it works fine -- hopefully you don't run into dependency hell on Windows!).

Please also note that for now, Kùzu 0.6.1 is the last version for the next several months that you can use this RDFLib plugin with Kùzu. We will re-implement the RDF functionality as a Kùzu extension in a future version for the reasons described in #8 (for the coming months, only Kùzu will be a property graph-only database). Please reach out to us on Discord if you have more questions. Cheers!