HelgeCPH / cypher_kernel

An experimental Jupyter kernel for the Cypher query language.
4 stars 1 forks source link

Chicken and Egg Problem #1

Open HelgeCPH opened 6 years ago

HelgeCPH commented 6 years ago

Currently, the kernel wraps the cypher-shell. That is, when the kernel is getting started, a command similar to cypher-shell -u neo4j -p neo4j is executed. That will of course only succeed when a Neo4j instance is running. Otherwise, cypher-shell returns Connection refused and the kernel crashes. That is an issue in case one wants to start notebooks in which one wants to create a Neo4j container only for this notebook, such as in examples/paradise_papers.ipynb.

A possible solution could be to try to run cypher-shell -u neo4j -p neo4j and check if it can connect (or check if a neo4j process is running) and if not to start a small instance in a container and connect to that.

psychemedia commented 4 years ago

I have an example repo here that uses a Binder postBuild file to run a:

neo4j-community-3.5.8/bin/neo4j-admin set-initial-password neo4jbinder

command to reset the default password.

That repo also bundles your kernel (hope you don't mind...).

(On a quick test I couldn't use the notebook running the kernel to add things to the db? I don't speak cypher, tho, so my CREATE attempts may have been badly formed.)

Do you know of any recent IPython magic that works with neo4j? For completeness I should probably add a magic route for folk who do want to work in a Python notebook environment.

HelgeCPH commented 4 years ago

@psychemedia, thank you for the question and MyBinder notebook. I will have a look at it as soon as I have time for it (latest during the weekend). I just had a quick look and cannot find an issue directly but my gut feeling is that the kernel cannot find the cypher-shell binary, which it wraps and then the request from the notebook just times out.

I do not know of any recent Neo4j magics except of the one that are linked. In case you want to work with Python you should be able to do it via this kernel. It wraps the Neo4j response (in case it works :)) and creates a pandas DataFrame out of it, which one can process then further.

psychemedia commented 4 years ago

@HelgeCPH I just did some really quick proof-of-concept magic here: https://github.com/innovationOUtside/cypher_magic which I also bundled into my binder repo too.

FWIW, I don't seem to get any issues in the Binder set up, eg when the password is reset after the container starts.