Closed stuchalk closed 1 year ago
hi. thanks for using kglab
.
Your problem is probably due by the fact that you called your script kglab.py
. Please try to change the name of your file to script1.py
or test1.py
or anything with a different name. Calling the file with the same name of the library can create this problem if your are inside a Python module (any directory with the __init__.py
file in it).
Let me know if this fixes.
Apologies, this is such a rookie mistake. I'm not a expert but neither am I am noob - I should have checked that. Interestingly now that it is running I am getting another error:
Traceback (most recent call last):
File "/Users/n00002621/PycharmProjects/chemshapes/chemtwins/kglabexample.py", line 5, in <module>
kg.load_rdf("https://storage.googleapis.com/kglab-tutorial/foaf.rdf", "xml")
File "/Users/n00002621/.local/share/virtualenvs/chemshapes-jx7D4Fdy/lib/python3.10/site-packages/kglab/decorators.py", line 66, in wrapper
bound_arguments = sig.bind(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/inspect.py", line 3179, in bind
return self._bind(args, kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/inspect.py", line 3105, in _bind
raise TypeError(
TypeError: too many positional arguments
Process finished with exit code 1
Any thoughts?
Thanks @stuchalk, these are great questions!
It's rather surprising how often that first issue pops up in Py code development. One would think the interpreters/compilers might eventually give better warnings – although since I'm in PSF, I should probably make a PR before complaining :)
For the second issue, we'd need to see your code. Mostly likely it's a simple change to the argument list for a method code, and I'm guessing probably in load_rdf()
but we can't see it from the copy/pasted exception text.
The same code as before:
In the code above, the line:
kg.load_rdf("...", "xml")
needs to be:
kg.load_rdf("...", format="xml")
For this call to load_rdf()
, the first argument is a "positional argument" and the second argument is a "keyword argument" (aka "kwarg" ) so it requires the format=
before the value.
Here's more history and gory details :) https://peps.python.org/pep-0570/#history-of-positional-only-parameter-semantics-in-python
OK, I am having one of those days. Close this thing so I don't waste any more of your time. Thanks!
No worries, great questions. We want to hammer on our docs to get this into shape :) It needs to be intuitive. Many thanks for all your feedback!
I'm submitting a bug report.
Current Behaviour:
When I run the code I get: AttributeError: partially initialized module 'kglab' has no attribute 'KnowledgeGraph' (most likely due to a circular import)
Expected Behaviour:
That it would work per the repo readme file
Steps to reproduce:
Snapshot:
Environment:
Installed packages