Python serializer error

The following code runs ok from the Python Script node Editor, if you previously click on Reset Workspace.

# Copy input to output
from py2neo import Graph, types
from pandas import DataFrame


graph = Graph(host="xxxxx", bolt=True, bolt_port=7687, user="xxx", password="xxx")
query = "match (h:HistClin)-[rt]-(t:ConceptoTrad)-[rc]-(c:Concepto) where toString(h.id) =~ '20180624114754.*' return h,rt,t,rc,c"

result = graph.run(query).data()

df = DataFrame(result)

#output_table = input_table.copy()

output_table = df.copy()

If you run it from the Analytics Platform, or run it without resetting workspace, you get:

ERROR PythonKernel                    LookupError: No serializer extension having the id or processing python type "py2neo.types.Node" could be found.
ERROR Python Script (1⇒1)  0:556:0:618 Execute failed: An exception occured while running the python kernel. See console and log for details.

So it seems to be a bug. Any workaround?

Thanks

Hi Peleitor,

try to add close() at the end of the code in the Python script node.

Best, daria

I’ve added close() as suggested, but it did not work. Am I missing something?

Traceback (most recent call last):
  File "/opt/knime/knime_3.5.3/plugins/org.knime.python2_3.5.0.v201712011355/py/PythonKernel.py", line 491, in execute
    exec(source_code, self._exec_env, self._exec_env)
  File "<string>", line 24, in <module>
NameError: name 'close' is not defined
1 Like

peleitor-

I’m not familiar with the py2neo library. It may not be exactly the same. But, are you sure this error is not related to the other thread Python node failing: No serializer extension having the id or processing python type “int”? See the post by MarcelW.

Adriane

This sounds like the problem mentioned here:

I have not tried the suggested workaround.

Hi peleitor,

Does type(result) return different results when the workspace is reset compared to when it’s not?

Marcel

Hello. It always returns

<class 'list'>

I think it is not related to py2neo, as I’ve tried other alternative (a different library for querying graphs) with exactly the same error.

Solved: the problem is that you need to convert “node type” to something that matches a KNIME dataframe constituent types, eg. split the node attributes into several columns of type String and Int.

This applies to any Graph library based in Python (including py2neo).

Thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.