Issues with `` example code

Moved from GitHub pydgraph/94

Posted by jayaddison:

Hi there,

I’m evaluating dgraph for a Python environment and trying out the example script in pydgraph. Unfortunately I’m not finding expected behaviour so far.

Here’s what I’ve found:

Steps to reproduce:

# setup dgraph server on default port
# install pydgraph via pip or pipenv
$ python examples/simple/

Results (pydgraph==2.0.2):

Created person named "Alice" with uid = 0x26
Number of people named "Alice": 1
Number of people named "Bob": 1
Bob's UID: 0x25
Bob deleted
Number of people named "Alice": 1
Number of people named "Bob": 1

Bob is not deleted.

Results (pydgraph==master@2e3b821):

Error: <_Rendezvous of RPC that terminated with:
	status = StatusCode.UNKNOWN
	details = "line 10 column 12: Missing colon in type declaration. Got 
	debug_error_string = "{"created":"@1571758478.030906774","description":"Error received from peer ipv6:[::1]:9080","file":"src/core/lib/surface/","file_line":1055,"grpc_message":"line 10 column 12: Missing colon in type declaration. Got \n","grpc_status":2}"

Expected results:

Script runs to completion, and user ‘Bob’ is deleted.

It looks like some of these problems may be related to the type system which is being introduced. Are types required for dgraph==1.1.0 and pydgraph==2.0.2 to perform a successful delete operation?

jayaddison commented :

Ok, it looks like types are indeed required - that this was a breaking change explained in - I’ll also assume that the most recent script version in master@2e3b821 is to run against newer versions of dgraph than the version I’m using.

jayaddison commented :

@campoy This is early evaluation, so take all this with a grain of salt - but I saw that you were on some threads (particularly Create predicates from type fields · Issue #4085 · dgraph-io/dgraph · GitHub) around types and developer expectations, and I just wanted to note the behaviour here (not being able to delete a node without a type specified) as a slightly confusing developer experience for me and at least one other (ref: Question mutation delete · Issue #91 · dgraph-io/pydgraph · GitHub).

Totally understand that the dgraph team is iterating quickly through the type system at the moment and that things will evolve. If I’ve missed any upcoming features/changes that modify this, my bad.

Some naive initial thoughts:

  • Could/should dgraph.type be required if it is essentially a core requirement for UID nodes?
  • Alternatively should there be special-case delete behavior if a node has no types attached and is deleted-by-uid?
  • Could the txn response include some measure of objects modified so that developers might be able to detect unexpected outcomes like this? (afaik it’s not possible for the client to determine without making another query)

Again, this is early into my understanding of dgraph (which looks great in many other regards) so I may see things a bit differently after properly understanding the principles, but I figured it was worth mentioning as I’d imagine others may experience the same.