Skip to content

Commit e04cb98

Browse files
committed
cleanup repo
1 parent 323a877 commit e04cb98

File tree

10 files changed

+79
-88
lines changed

10 files changed

+79
-88
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111
## [v21.03.0] - 2020-04-09
1212

1313
### Added
14-
- Logging in to namespace
14+
- Login to a namespace
1515
- Add response type
1616
- Hash to response and txn context.
1717
- Deprecation messaged for Slash Endpoint [168]

README.md

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,37 @@ This client follows the [Dgraph Go client][goclient] closely.
1010

1111
Before using this client, we highly recommend that you read the [Dgraph Python
1212
Client docs](https://dgraph.io/docs/clients/python/), as well as reviewing
13-
the product documentation at [docs.dgraph.io].
13+
the product documentation at [dgraph.io/docs].
1414

15-
[docs.dgraph.io]:https://docs.dgraph.io
15+
[dgraph.io/docs]:https://dgraph.io/docs
1616

1717
## Table of contents
1818

19-
- [Install](#install)
20-
- [Supported Versions](#supported-versions)
21-
- [Quickstart](#quickstart)
22-
- [Using a Client](#using-a-client)
23-
- [Creating a Client](#creating-a-client)
24-
- [Altering the Database](#altering-the-database)
25-
- [Creating a Transaction](#creating-a-transaction)
26-
- [Running a Mutation](#running-a-mutation)
27-
- [Committing a Transaction](#committing-a-transaction)
28-
* [Running a Query](#running-a-query)
29-
* [Running an Upsert: Query + Mutation](#running-an-upsert-query--mutation)
30-
* [Running a Conditional Upsert](#running-a-conditional-upsert)
31-
- [Cleaning up Resources](#cleaning-up-resources)
32-
- [Setting Metadata Headers](#setting-metadata-headers)
33-
- [Examples](#examples)
34-
- [Development](#development)
35-
- [Building the source](#building-the-source)
36-
- [Running tests](#running-tests)
19+
- [pydgraph](#pydgraph)
20+
- [Table of contents](#table-of-contents)
21+
- [Install](#install)
22+
- [Supported Versions](#supported-versions)
23+
- [Quickstart](#quickstart)
24+
- [Using a client](#using-a-client)
25+
- [Creating a Client](#creating-a-client)
26+
- [Altering the Database](#altering-the-database)
27+
- [Creating a Transaction](#creating-a-transaction)
28+
- [Running a Mutation](#running-a-mutation)
29+
- [Committing a Transaction](#committing-a-transaction)
30+
- [Running a Query](#running-a-query)
31+
- [Running an Upsert: Query + Mutation](#running-an-upsert-query--mutation)
32+
- [Running a Conditional Upsert](#running-a-conditional-upsert)
33+
- [Cleaning Up Resources](#cleaning-up-resources)
34+
- [Setting Metadata Headers](#setting-metadata-headers)
35+
- [Setting a timeout](#setting-a-timeout)
36+
- [Passing credentials](#passing-credentials)
37+
- [Authenticating to a reverse TLS proxy](#authenticating-to-a-reverse-tls-proxy)
38+
- [Async methods](#async-methods)
39+
- [Examples](#examples)
40+
- [Development](#development)
41+
- [Setting up environment](#setting-up-environment)
42+
- [Build from source](#build-from-source)
43+
- [Running tests](#running-tests)
3744

3845
## Install
3946

@@ -463,7 +470,7 @@ except Exception as e:
463470

464471
### Setting up environment
465472

466-
There are many ways to set up your local Python environment. We suggest some sane defaults here.
473+
There are many ways to set up your local Python environment. We suggest some sane defaults here.
467474

468475
- Use [pyenv](https://github.com/pyenv/pyenv) to manage your Python installations.
469476
- Most recent versions of Python should work, but the version of Python officially supported is located in
@@ -506,7 +513,7 @@ To run the tests in your local machine, run:
506513
bash scripts/local-test.sh
507514
```
508515

509-
This script assumes dgraph is located on your path. Dgraph release binaries can
516+
This script assumes dgraph is located on your path. Dgraph release binaries can
510517
be found [here](https://github.com/dgraph-io/dgraph/releases).
511518
The test script also requires that `docker` and `docker compose` are installed on
512519
your machine.

examples/parse_datetime/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
# Parse DateTime automatically
2-
3-
Simple demonstration on how to automatically convert DGraph's DateTime strings to native python datetime objects. This example expands on the `simple.py` demonstration. It uses a JSON custom [object hook](https://docs.python.org/3/library/json.html#encoders-and-decoders) which iterates over the return object. You can explore the source code in the `parse_datetime.py` file.
1+
# Parse DateTime Automatically
42

3+
Simple demonstration on how to automatically convert DGraph's DateTime strings to native python
4+
datetime objects. This example expands on the `simple.py` demonstration. It uses a JSON custom
5+
[object hook](https://docs.python.org/3/library/json.html#encoders-and-decoders) which iterates
6+
over the return object. You can explore the source code in the `parse_datetime.py` file.
57

68
## Running
79

8-
The conditions for running this example are the same as described in the [simple example](https://github.com/dgraph-io/pydgraph/tree/master/examples/simple).
10+
The conditions for running this example are the same as described in the
11+
[simple example](https://github.com/dgraph-io/pydgraph/tree/master/examples/simple).

examples/parse_datetime/parse_datetime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def set_schema(client):
4949
type Person {
5050
name
5151
friend
52-
married
52+
married
5353
loc
5454
dob
5555
}
@@ -75,7 +75,7 @@ def create_data(client):
7575
'type': 'Point',
7676
'coordinates': [1.1, 2],
7777
},
78-
78+
7979
'friend': [
8080
{
8181
'uid': '_:bob',

examples/simple/README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,32 @@ Simple project demonstrating the use of [pydgraph], the official python client f
88

99
### Start Dgraph
1010

11-
Start by spinning up a Dgraph cluster locally. Run `docker compose up -d`.
12-
Note that the security flag uses a blanket whitelist. This is for convenience when testing locally.
11+
Start by spinning up a Dgraph cluster locally. Run `docker compose up -d`.
12+
Note that the security flag uses a blanket whitelist. This is for convenience when testing locally.
1313
Do not use this in a production environment.
1414

15+
Store the following content in `docker-compose.yml`. Then, run `docker-compose up` to
16+
set up the Dgraph cluster:
17+
18+
```yml
19+
version: "3.2"
20+
services:
21+
zero:
22+
image: dgraph/dgraph:latest
23+
restart: on-failure
24+
command: dgraph zero --my=zero:5080
25+
server:
26+
image: dgraph/dgraph:latest
27+
ports:
28+
- 8080:8080
29+
- 9080:9080
30+
restart: on-failure
31+
command: dgraph alpha --my=server:7080 --zero=zero:5080 --security "whitelist=${WHITELISTED}"
32+
```
33+
The "WHITELISTED" environment variable can be intiialized as described
34+
[in this post](https://discuss.dgraph.io/t/suggestion-for-how-to-add-docker-compose-network-to-whitelist/9600).
35+
We need to whitelist these IPs because the docker container runs with it's own IP address.
36+
1537
## Install the Dependencies
1638
1739
```sh
@@ -24,4 +46,4 @@ pip install -r requirements.txt
2446
python simple.py
2547
```
2648

27-
You can explore the source code in the `simple.py` file. Run `docker compose down` to tear down the cluster.
49+
You can explore the source code in the `simple.py` file. Run `docker compose down` to tear down the cluster.

examples/tls/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ services:
5959
labels:
6060
cluster: test
6161
service: alpha
62-
command: dgraph alpha --port_offset 0 --my=alpha1:7080 --zero=zero1:5080 --expose_trace --trace ratio=1.0 --profile_mode block --block_rate 10 --logtostderr -v=2 --security whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 --acl secret-file=/dgraph-acl/hmac-secret;access-ttl=3s;refresh-ttl=5s --tls client-auth-type=REQUIREANDVERIFY;ca-cert=/dgraph-tls/ca.crt;server-cert=/dgraph-tls/node.crt;server-key=/dgraph-tls/node.key
62+
command: dgraph alpha --port_offset 0 --my=alpha1:7080 --zero=zero1:5080 --expose_trace --trace ratio=1.0 --profile_mode block --block_rate 10 --logtostderr -v=2 --security whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 --acl secret-file=/dgraph-acl/hmac-secret;access-ttl=3s;refresh-ttl=5s --tls "client-auth-type=REQUIREANDVERIFY;ca-cert=/dgraph-tls/ca.crt;server-cert=/dgraph-tls/node.crt;server-key=/dgraph-tls/node.key"
6363

6464
alpha2:
6565
image: dgraph/dgraph:latest
@@ -82,7 +82,7 @@ services:
8282
labels:
8383
cluster: test
8484
service: alpha
85-
command: dgraph alpha --port_offset 2 --my=alpha2:7082 --zero=zero1:5080 --expose_trace --trace ratio=1.0 --profile_mode block --block_rate 10 --logtostderr -v=2 --security whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 --acl secret-file=/dgraph-acl/hmac-secret;access-ttl=3s;refresh-ttl=5s --tls client-auth-type=REQUIREANDVERIFY;ca-cert=/dgraph-tls/ca.crt;server-cert=/dgraph-tls/node.crt;server-key=/dgraph-tls/node.key
85+
command: dgraph alpha --port_offset 2 --my=alpha2:7082 --zero=zero1:5080 --expose_trace --trace ratio=1.0 --profile_mode block --block_rate 10 --logtostderr -v=2 --security whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 --acl secret-file=/dgraph-acl/hmac-secret;access-ttl=3s;refresh-ttl=5s --tls "client-auth-type=REQUIREANDVERIFY;ca-cert=/dgraph-tls/ca.crt;server-cert=/dgraph-tls/node.crt;server-key=/dgraph-tls/node.key"
8686

8787
alpha3:
8888
image: dgraph/dgraph:latest
@@ -105,4 +105,4 @@ services:
105105
labels:
106106
cluster: test
107107
service: alpha
108-
command: dgraph alpha --port_offset 3 --my=alpha3:7083 --zero=zero1:5080 --expose_trace --trace ratio=1.0 --profile_mode block --block_rate 10 --logtostderr -v=2 --security whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 --acl secret-file=/dgraph-acl/hmac-secret;access-ttl=3s;refresh-ttl=5s --tls client-auth-type=REQUIREANDVERIFY;ca-cert=/dgraph-tls/ca.crt;server-cert=/dgraph-tls/node.crt;server-key=/dgraph-tls/node.key
108+
command: dgraph alpha --port_offset 3 --my=alpha3:7083 --zero=zero1:5080 --expose_trace --trace ratio=1.0 --profile_mode block --block_rate 10 --logtostderr -v=2 --security whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 --acl secret-file=/dgraph-acl/hmac-secret;access-ttl=3s;refresh-ttl=5s --tls "client-auth-type=REQUIREANDVERIFY;ca-cert=/dgraph-tls/ca.crt;server-cert=/dgraph-tls/node.crt;server-key=/dgraph-tls/node.key"

pydgraph/client_stub.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ def close(self):
8787
del self.channel
8888
del self.stub
8989

90-
# from_slash_endpoint is deprecated and will be removed in v21.07 release.
91-
# Use from_cloud method to connect to dgraph cloud backend.
92-
@staticmethod
93-
def from_slash_endpoint(cloud_endpoint, api_key):
94-
return from_cloud(cloud_endpoint, api_key)
95-
9690
# Usage:
9791
# import pydgraph
9892
# client_stub = pydgraph.DgraphClientStub.from_cloud("cloud_endpoint", "api-key")

pydgraph/errors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,3 @@ class TransactionError(Exception):
5050
"""Error thrown when the transaction is invalid (e.g trying to mutate in read-only mode)."""
5151
def __init__(self, msg):
5252
super(TransactionError, self).__init__(msg)
53-

pydgraph/proto/api.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ message Metrics {
152152
}
153153

154154
message NQuad {
155-
reserved 5; // This was used for label
155+
reserved 5; // This was used for label.
156156
string subject = 1;
157157
string predicate = 2;
158158
string object_id = 3;

tests/docker-compose.yml

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
# Auto-generated with: [compose -a 3 -z 3 --port_offset=0 --expose_ports=false --acl --names=false --local=false --tag=master]
2-
#
31
version: "3.5"
42
services:
53
alpha1:
6-
image: dgraph/dgraph:master
4+
image: dgraph/dgraph:latest
75
working_dir: /data/alpha1
8-
labels:
9-
cluster: test
106
ports:
117
- "8080"
128
- "9080"
@@ -18,15 +14,10 @@ services:
1814
command: dgraph alpha --my=alpha1:7080 --zero=zero1:5080 --logtostderr -v=2 --raft
1915
"idx=1; group=1" --security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;"
2016
--acl "secret-file=/secret/hmac;"
21-
deploy:
22-
resources:
23-
limits:
24-
memory: 32G
17+
2518
alpha2:
26-
image: dgraph/dgraph:master
19+
image: dgraph/dgraph:latest
2720
working_dir: /data/alpha2
28-
labels:
29-
cluster: test
3021
ports:
3122
- "8080"
3223
- "9080"
@@ -38,15 +29,10 @@ services:
3829
command: dgraph alpha --my=alpha2:7080 --zero=zero1:5080 --logtostderr -v=2 --raft
3930
"idx=2; group=1" --security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;"
4031
--acl "secret-file=/secret/hmac;"
41-
deploy:
42-
resources:
43-
limits:
44-
memory: 32G
32+
4533
alpha3:
46-
image: dgraph/dgraph:master
34+
image: dgraph/dgraph:latest
4735
working_dir: /data/alpha3
48-
labels:
49-
cluster: test
5036
ports:
5137
- "8080"
5238
- "9080"
@@ -58,54 +44,34 @@ services:
5844
command: dgraph alpha --my=alpha3:7080 --zero=zero1:5080 --logtostderr -v=2 --raft
5945
"idx=3; group=1" --security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;"
6046
--acl "secret-file=/secret/hmac;"
61-
deploy:
62-
resources:
63-
limits:
64-
memory: 32G
47+
6548
zero1:
66-
image: dgraph/dgraph:master
49+
image: dgraph/dgraph:latest
6750
working_dir: /data/zero1
68-
labels:
69-
cluster: test
7051
ports:
7152
- "5080"
7253
- "6080"
7354
command: dgraph zero --raft='idx=1' --my=zero1:5080 --replicas=3 --logtostderr
7455
-v=2 --bindall
75-
deploy:
76-
resources:
77-
limits:
78-
memory: 32G
56+
7957
zero2:
80-
image: dgraph/dgraph:master
58+
image: dgraph/dgraph:latest
8159
working_dir: /data/zero2
8260
depends_on:
8361
- zero1
84-
labels:
85-
cluster: test
8662
ports:
8763
- "5080"
8864
- "6080"
8965
command: dgraph zero --raft='idx=2' --my=zero2:5080 --replicas=3 --logtostderr
9066
-v=2 --peer=zero1:5080
91-
deploy:
92-
resources:
93-
limits:
94-
memory: 32G
67+
9568
zero3:
96-
image: dgraph/dgraph:master
69+
image: dgraph/dgraph:latest
9770
working_dir: /data/zero3
9871
depends_on:
9972
- zero2
100-
labels:
101-
cluster: test
10273
ports:
10374
- "5080"
10475
- "6080"
10576
command: dgraph zero --raft='idx=3' --my=zero3:5080 --replicas=3 --logtostderr
10677
-v=2 --peer=zero1:5080
107-
deploy:
108-
resources:
109-
limits:
110-
memory: 32G
111-
volumes: {}

0 commit comments

Comments
 (0)