1

I was trying to switch to different database on runtime in gremlin_python. To do this, I used JanusGraphFactory.open() to open different configuration. Because gremlin_python does not have JanusGraphFactory, I had to run this code via submit().

from gremlin_python.driver import client
client = client.Client('ws://localhost:8182/gremlin','g')

query = "conf = new BaseConfiguration();\
conf.setProperty('gremlin.graph', 'org.janusgraph.core.JanusGraphFactory');\
conf.setProperty('cache.db-cache-size', 0.25);\
conf.setProperty('cache.db-cache-clean-wait', 20);\
conf.setProperty('ids.block-size', 10000);\
conf.setProperty('cache.db-cache', true);\
conf.setProperty('storage.backend', 'hbase');\
conf.setProperty('storage.write-time', '1000000 ms');\
conf.setProperty('storage.hostname', 'hostname');\
conf.setProperty('storage.transactions', false);\
conf.setProperty('storage.hbase.table', 'table');\
conf.setProperty('storage.batch-loading', true);\
conf.setProperty('cache.db-cache-time', 180000);\
graph = JanusGraphFactory.open(conf);"

result  = client.submit(query)
future_results = result.all()
results = future_results.result()
print(results)

However, I got the following error, I believe that the error was coming from "graph = JanusGraphFactory.open(conf);":

Traceback (most recent call last):
File "/home/kk/project/janusgraph_test/janusgraph_test3.py", line 29, in \<module\>
results = future_results.result()
File "/usr/lib/python3.10/concurrent/futures/\_base.py", line 458, in result
return self.\__get_result()
File "/usr/lib/python3.10/concurrent/futures/\_base.py", line 403, in \__get_result
raise self.\_exception
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/driver/resultset.py", line 90, in cb
f.result()
File "/usr/lib/python3.10/concurrent/futures/\_base.py", line 451, in result
return self.\__get_result()
File "/usr/lib/python3.10/concurrent/futures/\_base.py", line 403, in \__get_result
raise self.\_exception
File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(\*self.args, \*\*self.kwargs)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/driver/connection.py", line 90, in \_receive
status_code = self.\_protocol.data_received(data, self.\_results)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/driver/protocol.py", line 96, in data_received
message = self.\_message_serializer.deserialize_message(message)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/driver/serializer.py", line 280, in deserialize_message
result = self.\_graphbinary_reader.to_object(b)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 203, in to_object
return self.deserializers\[DataType(bt)\].objectify(buff, self, nullable)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 502, in objectify
return cls.is_null(buff, reader, cls.\_read_list, nullable)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 231, in is_null
return None if nullable and buff.read(1)\[0\] == 0x01 else else_opt(buff, reader)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 509, in \_read_list
the_list.append(r.read_object(b))
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 194, in read_object
return self.to_object(b)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 203, in to_object
return self.deserializers\[DataType(bt)\].objectify(buff, self, nullable)
File "/home/kk/project/janusgraph_test/venv/lib/python3.10/site-packages/gremlin_python/structure/io/graphbinaryV1.py", line 662, in objectify
raise AttributeError("TinkerGraph deserialization is not currently supported by gremlin-python")
AttributeError: TinkerGraph deserialization is not currently supported by gremlin-python`

I tried the same codes on Groovy console and it had no problem opening the conf.

I also researched about ConfiguredGraphFactory. It is not included in gremlin_python either and I did not find explicit usages for gremlin-python. Hope someone have some ideas about this, thank you in advance!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.