Closed kristall closed 5 years ago
Thanks for the issue and clear explanation :) This is something we definitely want to be able to do in the future, but as of right now it's on our longer term roadmap rather than short term.
The reason you can do this in console is that it uses java under the hood, which can in turn utilise the full language definition for Graql
, including grammar parsing. The method that parses a series of queries is called Graql.parseList(String)
and returns our native GraqlQuery
types that can be fed directly into client-java
.
As it stands, we don't have a full grammar parser in languages other than Java, though it is something we want to do, and would enable exactly the behavior you're looking for.
The shortest way to do it in pytho might actually be to call console -f
from python! That way you can load all the static data in one go, and restrict the client for interactive database operations. How feasible is this for you? If you don't have the client on the same machine on the server, you may be able to write a tiny java program that encapsulates this functionality and also takes URI.
@flyingsilverfin Ah, you are right. Since I use ipython (or jupyter) notebook anyways I can just access the shell behind and call it from there, that will most likely work. Still having a function in the python client should be the long term solution, so shall we leave this issue open or close it?
Let's shut this one and track it in Graql
's repository directly. Thanks!
Problem to Solve
If you have an .gql file, that contains definitions and inserts then this causes an exception
but from console this works:
./grakn console --keyspace test --file tests/foo.gql
Current Workaround
To avoid such behavior the original .gql file need to be split in two parts, definitions as one and inserts as the other like this:
Now the definitions are committable, but unfortunately the insert part still fails with exceptions.
So one needs to do the following:
But since in the foo_i.gql some of the inserts are multilines (
match\n..\n..insert\n..\n
) one need to insert blank lines to make an easy split with little logic (not empty and not just a comment which also causes exceptions) and split at\n\n
. This is painful since one needs to also split up single-line inserts with blank lines.Example:
(the blank line between the first two inserts is painful especially if you have a lot of them).
Proposed Solution
Since my guess is that you don't want to change the behaviour of
write_transaction.query()
it be great to have awrite_transaction.from_file()
which would take the path to the originalfoo.gql
and read it without exceptions like: