Skip to content

Error running the Getting started example, unhashable type: 'SPARQLConnectorΒ #210

@sky-2002

Description

@sky-2002

First of all, thanks a lot for this repo, @bsteenwi @GillesVandewiele @rememberYou .

πŸ› Bug

TypeError: unhashable type: 'SPARQLConnector' when running example code given in readme. The error arises out of the following code: responses = [self.connector.fetch(query) for query in queries] present here.

I also tried installing from the develop branch as was mentioned in this issue. But I am still getting the error.

Expected Behavior

No errors.

Current Behavior

The line embeddings, literals = transformer.fit_transform(knowledge_graph, entities) results into the error - TypeError: unhashable type: 'SPARQLConnector'.

Steps to Reproduce

I tried the code given in the readme file on the repo.

# Create our transformer, setting the embedding & walking strategy.
transformer = RDF2VecTransformer(
    Word2Vec(epochs=10),
    walkers=[RandomWalker(4, 10, with_reverse=False, n_jobs=2)],
    # verbose=1
)
# Get our embeddings.
embeddings, literals = transformer.fit_transform(knowledge_graph, entities)
print(embeddings)

Environment

  • Operating system: Ubuntu 22.04.2
  • pyRDF2Vec version: 0.2.3
  • Python version: 3.11.3

Possible Solution

For me, changing this line in connectors.py:

@cachedmethod(operator.attrgetter("cache"), key=partial(hashkey, "fetch"))
def fetch(self, query: str) -> Response:

to this:

@cachedmethod(operator.attrgetter("cache"))
def fetch(self, query: str) -> Response:

solved the issue. But I think a solution for error free installation is needed, without needing to change this line, happy to contribute if guided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions