GithubHelp home page GithubHelp logo

pydgraph's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pydgraph's Issues

python3 grpcio dependency

pip3 tries to install a non python3 compatible version of prpcio

pip3 install --pre grpcio
pip3 install --no-deps pydgraph

fixed the problem

Connecting to a running alpha

Hi,

I have a zero, alpha and ratel running (from installed binaries). The ratel instance works fine on http://localhost:8080/. I'm trying to run sample.py with:

def create_client_stub():
return pydgraph.DgraphClientStub('localhost:8080')

but get the error:

Error: <_Rendezvous of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = "Trying to connect an http1.x server"
debug_error_string = "{"created":"@1573172159.765943000","description":"Error received from peer ipv6:[::1]:8080","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"Trying to connect an http1.x server","grpc_status":14}"

I'm not sure what this error relates to since I can connect to Alpha fine from terminal/ratel.

Thanks

Remove linread map

The linread map was removed since Dgraph v1.0.8 and is no longer needed in clients. See the corresponding Go client change that removed the linread map: dgraph-io/dgo@ba8ea8b

Conda Package for Dgraph client

Hi ,
Since there is no conda package for the client, i was hoping to build a conda package and update in binstar. Let me know your inputs about the same .

python3 import error

when i try to initialize it i get:

import pydgraph.client
pydgraph.client.DgraphClient("localhost", 8001)

ImportError: No module named 'graphresponse_pb2'

but if change the cwd like this:
!cd /usr/local/lib/python3.5/dist-packages/pydgraph

everything works

pydgraph.client.DgraphClient("localhost", 8001)

<pydgraph.client.DgraphClient at 0x7f5ecfb3b128>

simple.py does not work with the latest dgraph docker container

The example provided does not work. To reproduce:

docker run --rm -it -p 8000:8000 -p 8080:8080 -p 9080:9080 dgraph/standalone:latest (or the docker-compose way, same error)
pip install -r requirements.txt
python simple.py

Error:

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

Query - get_all - Multiple Inputs

Hi,

As stated over here link, it query for 'Alice' and it results for all the information for 'Alice'.

What if I have 'n' inputs in order to get all information say 'Alice', 'Bob', etc.

What would be the query?
I tried with list or array but not working.

Version pinning in requirements.txt

Is there any reason that the protobuf dependency in requirements.txt is pinned to 3.6.1? This is very odd for libraries, since it will cause conflicts if other libraries require for e.g. >=3.7.

I noticed that the dependency for grpcio was recently changed so that its version isn't pinned anymore (#51). Is there some reason that protobuf stayed pinned?

Thanks

is this client thread safe?

trying to using pydgraph, i'm wondering if this client is thread safe.
can i share one client instance between different processes?

from what i'v leant in dgraph doc, it seems that transactional conflicts will cause oprations on hold.
i guess it's best not to share client instance in multi process.

what i concerned is performance. if multi process could help improve performance, i'd like to make it that way. Or if one client instance only is enough for most use cases, i can design my program based on this concept.

Add facet

Hello,

How do you format the data to specify facets (=edge attributes) ? I would like to do something like (A)-distance=1->(B).

txn = client.txn()
data = ?
try:
  assigned = txn.mutate(set_obj=data)
  txn.commit()
finally:
  txn.discard()

Thanks a lot,
lapwat

wrong set_nquads example

Took me a while to figure out how to use set_nquads.
I notice that the README.md example is wrong:

# If you want to use N-Quads, use this instead:
# txn.mutate(set_nquads='_:alice "Alice"')

should be:

# txn.mutate(set_nquads='_:alice "Alice" .')

How to do conditional upsert with variables?

In #102 I had problems with the upsert in that example, which were resolved when setting name as a hard coded string value: NODE as q(func: eq(name, "foo")).

This confirms that what would to me seem as an intuitive way to combine query variables and upsert does not work.

Is it possible to do such an operation and if so, can you perhaps provide documentation for doing this correctly?

Error in my sample code

Hi, I write a simple code like this:

client_stub =pydgraph.DgraphClientStub("spark-1:9082")
client =pydgraph.DgraphClient(client_stub)
txn =client.txn()
p={
    #'uid':'0x12',
    'name':'Tony11',
    'city':'Franch',
}
print p
try:
    assigned = txn.mutate(set_obj=p)
    txn.commit()
finally:
    txn.discard()

client_stub.close()

However I got a error with this code as follows:

Traceback (most recent call last):
  File "dgraphTest.py", line 12, in <module>
    assigned = txn.mutate(set_obj=p)
  File "D:\Program\Anaconda\lib\site-packages\pydgraph\txn.py", line 71, in muta
te
    return self.do_request(req, timeout=timeout, metadata=metadata, credentials=
credentials)
  File "D:\Program\Anaconda\lib\site-packages\pydgraph\txn.py", line 110, in do_
request
    self._common_except_mutate(query_error)
  File "D:\Program\Anaconda\lib\site-packages\pydgraph\txn.py", line 160, in _co
mmon_except_mutate
    raise error
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
        status = StatusCode.UNKNOWN
        details = "Empty query"
        debug_error_string = "{"created":"@1568282122.945000000","description":"
Error received from peer ipv4:10.18.216.230:9082","file":"src/core/lib/surface/c
all.cc","file_line":1052,"grpc_message":"Empty query","grpc_status":2}"

the version of pydgraph is 2.0.2.
the version of Dgraph is v1.0.16
I could not understand what/s wrong with my code, please help me. Thanks!

'list' object has no attribute 'query'

Python 3, pydgraph 2.0.2
I'm playing around with Dgraph and am trying to do a simple query, but I can't figure out where it goes wrong. The query function:

def dgraph_search(dgraph_client):
    query = """{
        updates(func: uid(0x1)) {
            hashed_key
            title
            mentions {
                expand(_all_)
            }
        }
    }"""
    res = dgraph_client.txn(read_only=True).query(query)
    updates = json.loads(res.json)

Client creation:

    dgraph_stub_1 = create_dgraph_stub('localhost:9080')
    dgraph_stub_2 = create_dgraph_stub('localhost:9081')
    dgraph_client = create_dgraph_client([dgraph_stub_1, dgraph_stub_2])
    print("Dgraph client created")
    
    dgraph_search(dgraph_client)

def create_dgraph_stub(dgraph_alpha_address):
    return pydgraph.DgraphClientStub(dgraph_alpha_address)

def create_dgraph_client(dgraph_stub):
    return pydgraph.DgraphClient(dgraph_stub)

As far as I can tell the client is created just fine. Running the query gives me the following error:

Error: 'list' object has no attribute 'query'

What obvious thing am I missing here?

incompatible API problem in simple.py?

with dgraph version 1.1.0 and pydgraph version 2.0.2,:

dgraph version

[Decoder]: Using assembly version of decoder

Dgraph version : v1.1.0
Dgraph SHA-256 : 7d4294a80f74692695467e2cf17f74648c18087ed7057d798f40e1d3a31d2095
Commit SHA-1 : ef7cdb28
Commit timestamp : 2019-09-04 00:12:51 -0700
Branch : HEAD
Go version : go1.12.7

For Dgraph official documentation, visit https://docs.dgraph.io.
For discussions about Dgraph , visit https://discuss.dgraph.io.
To say hi to the community , visit https://dgraph.slack.com.

Licensed variously under the Apache Public License 2.0 and Dgraph Community License.
Copyright 2015-2018 Dgraph Labs, Inc.

pip3 list

Package Version


grpcio 1.25.0
grpcio-tools 1.25.0
pip 18.1
protobuf 3.11.1
pydgraph 2.0.2
setuptools 40.6.2
six 1.13.0

when I ran codes in simple.py, still got the error:

schema = """
... type Person {
name
friend
age
married
loc
dob
}
"""... ... ... ... ... ... ... ...

client.alter(pydgraph.Operation(schema=schema))
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/site-packages/pydgraph/client.py", line 87, in alter
raise error
File "/usr/local/lib/python3.6/site-packages/pydgraph/client.py", line 78, in alter
credentials=credentials)
File "/usr/local/lib/python3.6/site-packages/pydgraph/client_stub.py", line 46, in alter
credentials=credentials)
File "/usr/local/lib/python3.6/site-packages/grpc/_channel.py", line 690, in call
return _end_unary_response_blocking(state, call, False, None)
File "/usr/local/lib/python3.6/site-packages/grpc/_channel.py", line 592, in _end_unary_response_blocking
raise _Rendezvous(state, None, None, deadline)
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.UNKNOWN
details = "line 3 column 12: Missing colon in type declaration. Got
"
debug_error_string = "{"created":"@1576733760.865447033","description":"Error received from peer ipv4:127.0.0.1:9080","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"line 3 column 12: Missing colon in type declaration. Got \n","grpc_status":2}"

I'm wondering if this is imcompatible API problem caused by versions I'm using.

Add preds field

The preds field was added in Dgraph v1.0.8. It tracks the predicates mutated in a transaction and is handled by the client similar to the keys field by merging in the new list with the existing one per transaction.

Corresponding Go client change: dgraph-io/dgo@ed3c52b

Alpha Crashes When Inserting Lots of Data Multithreaded

So I am inserting thousands of data with multi threading, so this caused the alpha to crash. Here is the error :

     

goroutine 56822524 [chan receive, 4 minutes]:
github.com/dgraph-io/dgraph/worker.MutateOverNetwork(0x15a8ae0, 0xcb3ff6c6c0, 0xd1bd8ef810, 0x0, 0x0, 0x0)
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/mutation.go:467 +0x41e
github.com/dgraph-io/dgraph/query.ApplyMutations(0x15a8ae0, 0xc31577d590, 0xd1bd8ef810, 0x0, 0x147dc9a, 0x17)
        /ext-go/1/src/github.com/dgraph-io/dgraph/query/mutation.go:51 +0x118
github.com/dgraph-io/dgraph/edgraph.(*Server).Mutate(0x1fbc410, 0x15a8ae0, 0xc31577d590, 0xd16d2a8f00, 0xd1c68f0240, 0x0, 0x0)
        /ext-go/1/src/github.com/dgraph-io/dgraph/edgraph/server.go:398 +0x517
github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/dgo/protos/api._Dgraph_Mutate_Handler(0x13d8f80, 0x1fbc410, 0x15a8ae0, 0xc31577c210, 0xd1bd8ef650, 0x0, 0x0, 0x0, 0xd1be38ac00, 0x97745f)
        /ext-go/1/src/github.com/dgraph-io/dgraph/vendor/github.com/dgraph-io/dgo/protos/api/api.pb.go:1775 +0x23e
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00019a000, 0x15ae3a0, 0xc161f00000, 0xd1be38ac00, 0xc0004d0390, 0x1ef2630, 0x0, 0x0, 0x0)
        /ext-go/1/src/google.golang.org/grpc/server.go:1011 +0x4cd
google.golang.org/grpc.(*Server).handleStream(0xc00019a000, 0x15ae3a0, 0xc161f00000, 0xd1be38ac00, 0x0)
        /ext-go/1/src/google.golang.org/grpc/server.go:1249 +0x1311
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc161f2bc60, 0xc00019a000, 0x15ae3a0, 0xc161f00000, 0xd1be38ac00)
        /ext-go/1/src/google.golang.org/grpc/server.go:680 +0x9f
created by google.golang.org/grpc.(*Server).serveStreams.func1
        /ext-go/1/src/google.golang.org/grpc/server.go:678 +0xa1

It was working fine when I was inserting with only main thread. And memory usage is around %98. Maybe inserting with multi thread makes the insertions slow and when there are too many insertions stacked (so RAM usage is very high) and it makes the alpha crash?

I have 64 GBs of memory the usage was %98 and it suddenly dropped to %40, very odd. And I just realized that this is issue is related core Dgraph not the Python client. Should I re-open it on the main repo?

Thank you in the advance

Connect Error

When I attempt to connect to dgraph, I follow the example write like this:

from pydgraph.client import DgraphClient

dg_client = DgraphClient('localhost',8080)

response = dg_client.query("""
         mutation
        {
             set
             {
                 <alice> <name> \"Alice\" .
                 <greg> <name> \"Greg\" .
                 <alice> <follows> <greg> .
             }
         }""")

there comes an error like this:
I1026 16:20:47.341823000 140735514100544 subchannel.c:642] Connect failed: {"created":"@1509006047.341751000","description":"Failed to connect to remote host","errno":35,"file":"src/core/lib/iomgr/error.c","file_line":246,"os_error":"Connection refused","target_address":"ipv6:[::1]:8080"} I1026 16:20:47.341858000 140735514100544 subchannel.c:647] Retry in 0.898440040 seconds E1026 16:20:47.342815000 140735514100544 chttp2_transport.c:1810] close_transport: {"created":"@1509006047.342749000","description":"Failed parsing HTTP/2","file":"src/core/ext/transport/chttp2/transport/chttp2_transport.c","file_line":1726,"referenced_errors":[{"created":"@1509006047.342727000","description":"Expected SETTINGS frame as the first frame, got frame type 80","file":"src/core/ext/transport/chttp2/transport/parsing.c","file_line":477}]} Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/anaconda2/lib/python2.7/site-packages/pydgraph/client.py", line 38, in query response = self.stub.Query(request, timeout) File "/anaconda2/lib/python2.7/site-packages/grpc/beta/_client_adaptations.py", line 300, in __call__ self._request_serializer, self._response_deserializer) File "/anaconda2/lib/python2.7/site-packages/grpc/beta/_client_adaptations.py", line 198, in _blocking_unary_unary raise _abortion_error(rpc_error_call) grpc.framework.interfaces.face.face.AbortionError: AbortionError(code=StatusCode.UNAVAILABLE, details="")

In browser, my dgraph can run correctly, but it goes something wrong when I want to use python connect it.

Can anybody help me?

query json how convert python object

We will need this feature:

def create_bob(name="Bob",firend=Alice):
    p = {
           'name':name,
            'friend':Alice,
           'age':30,
        }
     txn.mutate(set_obj=p)
     txn.commit()

Alice = query(name="Alice")
create_bob(name="Bob",firend=Alice)
schema:
    name: string @index(exact) .                                                                              
    friend: uid @reverse .                                                                                    
    age: int .              

object-Alice
uid: 0x1
name: Alice
age:26

set object Bob:
name: Bob
age:26
friend:_Alice 

Roadmap?

Hi pydgraph developers/maintainers -

I'm looking into using Dgraph and pydgraph for a project of mine, and I was wondering if you had time for a conversation about development direction for the python client. I might be able to find significant time for contributions, if our goals are in line. I was specifically thinking about adding something more ORM-ish to the current python capabilities, and possibly implementing a version of sessions that would integrate well with caching systems, and I would be interesting in knowing if dgraph would be interested in those kinds of contributions, and working out the details if so.

Thanks!
-Lyla Fischer

Getting result from an upsert

When doing an upsert, it is not clear how to get the result of the upsert.

E.g:

def upsert(client, name, state):
    q = """query q($name: string)
    {
        NODE as q(func: eq(name, $name)) {
            expand(_all_)
        }
    }"""

    txn = client.txn()
    state['uid'] = 'uid(NODE)'
    m = txn.create_mutation(set_obj=state, cond='@if(eq(len(NODE), 1))')
    request = txn.create_request(query=q,
                                 mutations=(m,),
                                 variables={'$name': name},
                                 commit_now=True)

    try:
        result = txn.do_request(request)
    finally:
        txn.discard()

It would seem intuitive to have the newly changed state accessible in result.json, but reading this attribute returns b''.

What's the intended way of getting the newly updated state? Make a new query? That would seem redundant to me, but perhaps there are good reasons to have the user explicitly make a new query.

Upon further contemplation, you could simply return state as that should be your updated data, but then it is unclear how to idiomatically check if the request caused a write to the db.

EDIT: Updated example with setting uid, but the issue still persists.

ModuleNotFoundError: No module named 'google'

I'm having trouble installing pydgraph using pip, while this used to work before 2.0.0 (downgrading using pydgraph==1.2.0 does work).

image

Stack trace

Collecting pydgraph (from -r /runtime/app/requirements.txt (line 40))
  Downloading https://files.pythonhosted.org/packages/4d/19/025436211062e121cc344d2f34ed40e990a12a6437d3478161552bf08451/pydgraph-2.0.0.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-fejh1_9l/pydgraph/setup.py'"'"'; __file__='"'"'/tmp/pip-install-fejh1_9l/pydgraph/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
         cwd: /tmp/pip-install-fejh1_9l/pydgraph/
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-fejh1_9l/pydgraph/setup.py", line 33, in <module>
        from pydgraph.meta import VERSION
      File "/tmp/pip-install-fejh1_9l/pydgraph/pydgraph/__init__.py", line 15, in <module>
        from pydgraph.proto.api_pb2 import Operation, Payload, Request, Response, Mutation, TxnContext,\
      File "/tmp/pip-install-fejh1_9l/pydgraph/pydgraph/proto/api_pb2.py", line 7, in <module>
        from google.protobuf import descriptor as _descriptor
    ModuleNotFoundError: No module named 'google'

Trying to install the protobuf or google packages before dgraph (as advised on StackOverflow) doesn't make a difference.

Dockerfile

# https://github.com/aciobanu/docker-scrapy
FROM python:3.7.0-alpine3.8

WORKDIR /runtime/app

# https://unix.stackexchange.com/a/417661/299202
RUN apk add --update --no-cache openssh sshpass

RUN apk -U add \
        gcc \
        g++ \
        git \
        bash \
        libffi-dev \
        libxml2-dev \
        libxslt-dev \
        libjpeg \
        jpeg-dev \
        musl-dev \
        #openssl-dev \
        python-dev \
        python3-dev \
        py-imaging \
        py3-pillow \
        py3-lxml \
        libxml2-utils \
        linux-headers \
        py-pip \
        make \
        db-dev \
        #mariadb-dev \
        mysql-dev \
        curl \
        ca-certificates \
        rsync \
        tidyhtml \
        tidyhtml-libs \
        tidyhtml-dev \
    && update-ca-certificates \
    && rm -rf /var/cache/apk/*

# TODO: automate this away by using the python-alpine-small image with onbuild
ADD ./requirements.txt /runtime/app/requirements.txt

RUN pip3 install --upgrade pip

# https://github.com/grpc/grpc/issues/17711
RUN pip3 install cython

RUN pip3 install -r /runtime/app/requirements.txt #--target=/runtime/app/.packages

requirements.txt

google-cloud #even these packages do not fix missing google module
#google
grpcio
grpcio-tools
protobuf
pydgraph

Related:
protocolbuffers/protobuf#6135
https://stackoverflow.com/a/47904556/399058

[bug] doesn't handle forking well

I've been trying to use pydgraph to load data to train a PyTorch model but the pydgraph client really doesn't like multiprocessing/forking. If you make a call via pydgraph before forking it will throw errors if there are any concurrent queries made in the sub processes.

import torch
from torch.utils.data import Dataset, DataLoader
import pydgraph

def dgraph_client():
    stub = pydgraph.DgraphClientStub('localhost:9080')
    return pydgraph.DgraphClient(stub)


class GraphDataset(Dataset):
    def __init__(self):
        super().__init__()

        self.docs = list(range(100))

    def __len__(self) -> int:
        return len(self.docs)

    def __getitem__(self, i):
        resp = dgraph_client().txn(read_only=True).query(
            """{
                user(func: has(username), first: 1) {
                   uid
                   username
                }
            }""",
        )
        print(resp)
        return torch.tensor([i])


train_dataset = GraphDataset()
train_dataset[0] # removing this line fixes this code

train_loader = DataLoader(train_dataset, batch_size=8, num_workers=8)
# running multiple dgraph requests in parallel causes the crash
print(next(iter(train_loader)))

Output

json: "{\"user\":[{\"uid\":\"0x2\",\"username\":\"blah\"}]}"
txn {
  start_ts: 1177930
}
latency {
  parsing_ns: 17013
  processing_ns: 308037700
  encoding_ns: 920495
}

Exception ignored in: <function _Rendezvous.__del__ at 0x7f182b90fb70>
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/grpc/_channel.py", line 436, in __del__
    with self._state.condition:
AttributeError: '_Rendezvous' object has no attribute '_state'
Traceback (most recent call last):
  File "repro.py", line 38, in <module>
    print(next(iter(train_loader)))
  File "/usr/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 582, in __next__
    return self._process_next_batch(batch)
  File "/usr/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 608, in _process_next_batch
    raise batch.exc_type(batch.exc_msg)
TypeError: __init__() missing 3 required positional arguments: 'call', 'response_deserializer', and 'deadline'

Seems to be caused by some issue with grpc. Googling the error didn't pull anything up from the grpc project so it might be specific to how pydgraph uses it.

It'd be really nice if torch's DataLoader was well supported since it'll make graph learning much easier to do. I'm very excited to use dgraph for ML :)

Versions:

Name: pydgraph
Version: 1.2.0
Summary: Official Dgraph client implementation for Python
Home-page: https://github.com/dgraph-io/pydgraph
Author: Dgraph Labs
Author-email: [email protected]
License: Apache License, Version 2.0
Location: /usr/lib/python3.7/site-packages
Requires: grpcio, protobuf
Required-by:
---
Name: grpcio
Version: 1.22.0
Summary: HTTP/2-based RPC framework
Home-page: https://grpc.io
Author: The gRPC Authors
Author-email: [email protected]
License: Apache License 2.0
Location: /usr/lib/python3.7/site-packages
Requires: six
Required-by: tensorflow, tensorflow-serving-api, tensorflow-serving-api-gpu, tensorboard, pydgraph
---
Name: protobuf
Version: 3.7.0
Summary: Protocol Buffers
Home-page: https://developers.google.com/protocol-buffers/
Author: None
Author-email: None
License: 3-Clause BSD License
Location: /usr/lib/python3.7/site-packages
Requires: six, setuptools
Required-by: tensorflow, tensorflow-serving-api, tensorflow-serving-api-gpu, tensorboardX, tensorboard, pydgra
ph, googleapis-common-protos, google-api-core
---
Name: torch
Version: 1.1.0
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: /usr/lib/python3.7/site-packages
Requires: numpy
Required-by: torchvision

List pydgraph incompatabilities with v0.9

The dgraph website says:

Incomplete

A lot of development has gone into the Go client and the Python client is not up to date with it. The Python client is not compatible with dgraph v0.9.0 and onwards. We are looking for help from contributors to bring it up to date.

Is there a list of incompatibilities available? I'd be willing to contribute some patches to pydgraph.

client.query() causes dgraph alpha to write to disk constantly

When I use client.query(...) to do pure reads from dgraph, I noticed the dgraph alpha process constantly writing to disk. Snippet:

for q in pure_read_queries_to_run:
    client.query(q)

I have to do something like the following as a workaround:

txn = client.txn()

for q in pure_read_queries_to_run:
    txn.query(q)

txn.discard()

By doing this, performance improved by around 4 fold.

I think it may have something to do with the transaction handling in pydgraph?

How to increase message size in gprc for fetching all nodes of dgraph?

when I try to fetch all nodes and its attributes from dgraph using the query:
query = """ { total (func: has (_predicate_) ) { count(uid) uid } }"""
I get error:

grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.RESOURCE_EXHAUSTED
details = "Received message larger than max (4673233 vs. 4194304)"
debug_error_string = "{"created":"@1550746922.282325865","description":"Received message larger than max (4673233 vs.4194304)","file":"src/core/ext/filters/message_size/message_size_filter.cc","file_line":174,"grpc_status":8}"

I try to use the code below to increase the size but it doesn't work.
MAX_MESSAGE_LENGTH = 10673233
channel = grpc.insecure_channel('10.0.131.64:9080', options=[('grpc.max_send_message_length', MAX_MESSAGE_LENGTH), ( 'grpc.max_receive_message_length', MAX_MESSAGE_LENGTH)])
Source: Stack Overflow

How can I increase the size? Or is there a better way to iterate over all the nodes of dgraph?

@lang directive ignored

I am trying to add some sample data to a Dgraph instance. Here is my code thus far:

p = {}
record = { some JSON document }

p['title@en'] = record['title_translated']['en']
p['title@fr'] = "<" + str(record['title_translated']['fr']) + ">"
p['date_published'] = record['date_published']

assigned = txn.mutate(set_obj=p)

txn.commit()

I get the following error:

Error: <_Rendezvous of RPC that terminated with:
status = StatusCode.UNKNOWN
details = "Attr: [title] should have @lang directive in schema to mutate edge: [entity:1903 attr:"title" value:"Versatile Soil Moisture Budget" value_type:STRING lang:"en" ]"

I have checked the lang checkbox in the schema configuration for the title predicate. Any idea on how I can get this to work?

Add update protobufs for v0.9+

Hi, I was going through the source for the pydgraph, and needed some help with figuring out the protobuffers for LinRead. Are there updated .proto files available which can be used to generate the python proto classes?

LocalError: unknown service graph.Dgraph

I use the code bellow to query dgraph(VERSION=0.7.4) , then it fails.
when use curl to query the same content, it's OK.

In [1]: from pydgraph.client import DgraphClient
In [2]: pydgraph.client.__version__
Out[1]: '0.3.5'
In [3]: dg_client = DgraphClient('localhost', 8080)
In [4]: response = dg_client.query("""
        mutation
        {
            set
            {
                <alice> <name> \"Alice\" .
                <greg> <name> \"Greg\" .
                <alice> <follows> <greg> .
            }
        }
        """)

The error is look like this:

LocalError                                Traceback (most recent call last)
<ipython-input-14-22802b274334> in <module>()
      9             }
     10         }
---> 11         """)


/home/app/caizb/venv/local/lib/python2.7/site-packages/pydgraph/client.pyc in query(self, q, timeout)
     36     def query(self, q, timeout=None):
     37         request = graphresponse_pb2.Request(query=q)
---> 38         response = self.stub.Query(request, timeout)
     39         return response

/home/app/caizb/venv/local/lib/python2.7/site-packages/grpc/beta/_client_adaptations.pyc in __call__(self, request, timeout, metadata, with_call, protocol_options)
    298         self._channel, self._group, self._method, timeout, with_call,
    299         protocol_options, metadata, self._metadata_transformer, request,
--> 300         self._request_serializer, self._response_deserializer)
    301
    302   def future(self, request, timeout, metadata=None, protocol_options=None):

/home/app/caizb/venv/local/lib/python2.7/site-packages/grpc/beta/_client_adaptations.pyc in _blocking_unary_unary(channel, group, method, timeout, with_call, protocol_options, metadata, metadata_transformer, request, request_serializer, response_deserializer)
    196           credentials=_credentials(protocol_options))
    197   except grpc.RpcError as rpc_error_call:
--> 198     raise _abortion_error(rpc_error_call)
    199
    200

LocalError: LocalError(code=StatusCode.UNIMPLEMENTED, details="unknown service graph.Dgraph")

Why is pypandoc a build requirement?

This line is now causing errors in the build process of the software I manage that has pydgraph as a dependency!

I'm wondering if there's something I can change on my end or if I need to request a change to your setup.py file.

On my end I'm doing:

devpi upload --no-vcs --formats=bdist_wheel

This seems to trigger the code in the setup.py of pydgraph.
Is it possible for you to correctly format your code without causing errors for users of your package?

Issues with `simple.py` example code

Hi there,

I'm evaluating dgraph for a Python environment and trying out the example simple.py 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/simple.py

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
DONE!

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/call.cc","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?

Update a node adding edges

Hi All

first of all I'm quite new with dgraph and maybe my question is a bit stupid, so in that case, sorry to waste your time.

i have a schema:

`

    id: int @index(int) .
    name: string @index(term) .
    realname: string .
    aliases: [uid] @reverse @count .
    namevariations: [string] .
    affiliation: uid @reverse @count .
    
    address: string @index(exact) .
    number: string .
    email: string .
    
    type Aie {
      address: string
      number: string
      email: string
    }
    
    type Artist {
        id: int
      name: string
      realname: string
      aliases: [Artist]
      namevariations: [string]
      affiliate: Aie
    }

`

first of all i have added artists with a mutation and all worked well.
the second step was update the Artist type with aliases, to do that i have created a query:

`

 query_artist_by_id = """
            query artist($a: int) {
                 artist(func: eq(id, $a)) {
                    uid
                    id
                   name
                   realname
                   aliases
                   namevariations
                   affiliation
              }
}
"""

`

this is the python code

`

    path_xml = os.path.join(BASE_PATH, "uploader_db", 'xml', 'artists.xml')
    init_numb = 0
    list_artists = []
    artist = {}
    for event, element in etree.iterparse(path_xml, tag="artist"):
        # check if trhe artist have aliases
        aliases = element.find('aliases')
        members = element.find('members')
        if aliases is not None and members is None:
            # tag is an artist and have aliases
            id = element.find('id')
            # get the user from the id
            variable = {'$a': id.text}
            res = client.txn(read_only=True).query(query_artist_by_id, variables=variable)
            ppl = json.loads(res.json)
            aliases_array = []
            for artist_aliases in aliases.getchildren():
                #print(artist_aliases.get('id'))
                variable = {'$a': artist_aliases.get('id')}
                res_alias = client.txn(read_only=True).query(query_artist_by_id, variables=variable)
                rpl = json.loads(res_alias.json)
                if len(rpl['artist']) > 0:
                    aliases_array.append(rpl['artist'][0])
            if len(aliases_array) > 0:
                ppl['aliases'] = aliases_array
                txn = client.txn()
                try:
                    response = txn.mutate(set_obj=ppl)
                    txn.commit()
                except Exception as e:
                    if isinstance(e, pydgraph.AbortedError):
                        break
                    else:
                        raise e
                        break
                finally:
                    txn.discard()
                    aliases_array = []

`

in the python code i do that:

read the file with the content and iter all the results
i find into the dgraph database the Artist with the query below.
i find the Artist for every aliases that i have parsed and i update the main Artist object
and finaly i send the mutation

the problem is that after the update the Artist object with aliases loose the information like name, namevariations etc

i do something wrong?

thanks in advance

Question mutation delete

I am using pydgraph 2.0.2 and dgraph 1.1.0. I have a graph with a node with uid "0x2e" and name "Charlie". When I run

del_obj = {"uid": "0x2e"}
txn = client.txn();
try:
    txn.mutate(del_obj=del_obj)
    txn.commit()
finally:
    txn.discard()

The node is not deleted. But when I add the name:

del_obj = {"uid": "0x2e", "name": "Charlie"}
txn = client.txn();
try:
    txn.mutate(del_obj=del_obj)
    txn.commit()
finally:
    txn.discard()

The node is deleted. Is this expected behaviour ? If so, is there a way to expand a node without the new type system?

Adding list of geo gives "Input for predicate location_olac of type scalar is uid"

The parallel of this issue with the Go client: dgraph-io/dgo#11, which I have reproduced in the Python client.

I created an index:

location_olac: [geo] @index(geo) .

and now I'm trying to add something like

'location_olac': [
  {
    'type': 'Point',
     'coordinates': [47.96056, -3.83472]
  },
  {
    'type': 'Point',
     'coordinates': [27.23453, -115.83472]
  },
]

I'm getting Input for predicate location_olac of type scalar is uid. If I take out one of the points (such that this is not a list), it works.

None string parameters get ignored

It looks like util.is_string is used to check parameter key and value, but if either are not strings then the query will still be sent with the parameter ignored.

This makes it really hard to debug if the parameter value was accidentally set to something other than a string.

Instead it'll be a lot better if an error was thrown in this situation.

For example

        query = """
            query node($a: int) {
                node(func: eq(myid, $a))
                {
                    expand(_all_)
                }
            }
        """
        variables = {"$a": 1234}
        result = txn.query(query, variables=variables)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.