{"id":24653393,"url":"https://github.com/hypermodeinc/pydgraph","last_synced_at":"2025-05-14T13:05:48.663Z","repository":{"id":9565723,"uuid":"62349251","full_name":"hypermodeinc/pydgraph","owner":"hypermodeinc","description":"Official Dgraph Python client","archived":false,"fork":false,"pushed_at":"2025-04-03T21:34:06.000Z","size":1123,"stargazers_count":279,"open_issues_count":1,"forks_count":86,"subscribers_count":32,"default_branch":"main","last_synced_at":"2025-04-12T14:17:01.069Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hypermodeinc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-06-30T23:52:36.000Z","updated_at":"2025-04-03T21:24:12.000Z","dependencies_parsed_at":"2023-11-06T13:46:08.875Z","dependency_job_id":"d871757d-5256-46eb-8b65-5c20ed150cf4","html_url":"https://github.com/hypermodeinc/pydgraph","commit_stats":{"total_commits":301,"total_committers":45,"mean_commits":6.688888888888889,"dds":0.7940199335548173,"last_synced_commit":"5537373d6fb5ad827952bc9eb7d364fd621742a5"},"previous_names":["hypermodeinc/pydgraph","dgraph-io/pydgraph"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypermodeinc%2Fpydgraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypermodeinc%2Fpydgraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypermodeinc%2Fpydgraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hypermodeinc%2Fpydgraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hypermodeinc","download_url":"https://codeload.github.com/hypermodeinc/pydgraph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254149919,"owners_count":22022851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-25T21:00:26.955Z","updated_at":"2025-05-14T13:05:48.634Z","avatar_url":"https://github.com/hypermodeinc.png","language":"Python","readme":"# pydgraph\n\nThis is the official Dgraph database client implementation for Python (Python \u003e= v3.7), using\n[gRPC][grpc].\n\n[grpc]: https://grpc.io/\n\nThis client follows the [Dgraph Go client][goclient] closely.\n\n[goclient]: https://github.com/dgraph-io/dgo\n\nBefore using this client, we highly recommend that you read the the product documentation at\n[dgraph.io/docs].\n\n[dgraph.io/docs]: https://dgraph.io/docs\n\n## Table of contents\n\n- [pydgraph](#pydgraph)\n  - [Table of contents](#table-of-contents)\n  - [Install](#install)\n  - [Supported Versions](#supported-versions)\n  - [Quickstart](#quickstart)\n  - [Using a client](#using-a-client)\n    - [Creating a Client](#creating-a-client)\n    - [Login into a Namespace](#login-into-a-namespace)\n    - [Connecting To Dgraph Cloud](#connecting-to-dgraph-cloud)\n    - [Altering the Database](#altering-the-database)\n    - [Creating a Transaction](#creating-a-transaction)\n    - [Running a Mutation](#running-a-mutation)\n    - [Running a Query](#running-a-query)\n    - [Query with RDF response](#query-with-rdf-response)\n    - [Running an Upsert: Query + Mutation](#running-an-upsert-query--mutation)\n    - [Running a Conditional Upsert](#running-a-conditional-upsert)\n    - [Committing a Transaction](#committing-a-transaction)\n    - [Cleaning Up Resources](#cleaning-up-resources)\n    - [Setting Metadata Headers](#setting-metadata-headers)\n    - [Setting a timeout](#setting-a-timeout)\n    - [Async methods](#async-methods)\n  - [Examples](#examples)\n  - [Development](#development)\n    - [Setting up environment](#setting-up-environment)\n    - [Build from source](#build-from-source)\n    - [Running tests](#running-tests)\n\n## Install\n\nInstall using pip:\n\n```sh\npip install pydgraph\n```\n\n## Supported Versions\n\nDepending on the version of Dgraph that you are connecting to, you will have to use a different\nversion of this client.\n\n| Dgraph version | pydgraph version |\n| :------------: | :--------------: |\n|    21.03.x     |    _21.03.x_     |\n|    23.0.x+     |     _23.0.x_     |\n\n## Quickstart\n\nBuild and run the [simple project][simple] in the `examples` folder, which contains an end-to-end\nexample of using the Dgraph python client. For additional details, follow the instructions in the\nproject's [README](./examples/simple/README.md).\n\n[simple]: ./examples/simple\n\n## Using a client\n\n### Creating a Client\n\nYou can initialize a `DgraphClient` object by passing it a list of `DgraphClientStub` clients as\nvariadic arguments. Connecting to multiple Dgraph servers in the same cluster allows for better\ndistribution of workload.\n\nThe following code snippet shows just one connection.\n\n```python3\nimport pydgraph\n\nclient_stub = pydgraph.DgraphClientStub('localhost:9080')\nclient = pydgraph.DgraphClient(client_stub)\n```\n\n### Using Dgraph Connection Strings\n\nThe pydgraph package supports connecting to a Dgraph cluster using connection strings. Dgraph\nconnections strings take the form `dgraph://{username:password@}host:port?args`.\n\n`username` and `password` are optional. If username is provided, a password must also be present. If\nsupplied, these credentials are used to log into a Dgraph cluster through the ACL mechanism.\n\nValid connection string args:\n\n| Arg         | Value                           | Description                                                                                                                                                   |\n| ----------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| apikey      | \\\u003ckey\\\u003e                         | a Dgraph Cloud API Key                                                                                                                                        |\n| bearertoken | \\\u003ctoken\\\u003e                       | an access token                                                                                                                                               |\n| sslmode     | disable \\| require \\| verify-ca | TLS option, the default is `disable`. If `verify-ca` is set, the TLS certificate configured in the Dgraph cluster must be from a valid certificate authority. |\n\nNote the `sslmode=require` pair is not supported and will throw an Exception if used. Python grpc\ndoes not support traffic over TLS that does not fully verify the certificate and domain. Developers\nshould use the existing stub/client initialization steps for self-signed certs as demonstrated in\n/examples/tls/tls_example.py\n\nSome example connection strings:\n\n| Value                                                                                                        | Explanation                                                                         |\n| ------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- |\n| dgraph://localhost:9080                                                                                      | Connect to localhost, no ACL, no TLS                                                |\n| dgraph://sally:supersecret@dg.example.com:443?sslmode=verify-ca                                              | Connect to remote server, use ACL and require TLS and a valid certificate from a CA |\n| dgraph://foo-bar.grpc.us-west-2.aws.cloud.dgraph.io:443?sslmode=verify-ca\u0026apikey=\\\u003cyour-api-connection-key\\\u003e | Connect to a Dgraph Cloud cluster                                                   |\n| dgraph://foo-bar.grpc.hypermode.com:443?sslmode=verify-ca\u0026bearertoken=\\\u003csome access token\\\u003e                  | Connect to a Dgraph cluster protected by a secure gateway                           |\n\nUsing the `Open` function with a connection string:\n\n```go\n// open a connection to an ACL-enabled, non-TLS cluster and login as groot\nclient = pydgraph.open(\"dgraph://groot:password@localhost:8090\")\n\n// Use the client\n...\n\nclient.close()\n```\n\n### Login into a Namespace\n\nIf your server has Access Control Lists enabled (Dgraph v1.1 or above), the client must be logged in\nfor accessing data. If you didn't use the `open` function with credentials, use the `login`\nendpoint.\n\nCalling `login` will obtain and remember the access and refresh JWT tokens. All subsequent\noperations via the logged in client will send along the stored access token.\n\n```python3\nclient.login(\"groot\", \"password\")\n```\n\nIf your server additionally has namespaces (Dgraph v21.03 or above), use the `login_into_namespace`\nAPI.\n\n```python3\nclient.login_into_namespace(\"groot\", \"password\", \"123\")\n```\n\n### Connecting To Dgraph Cloud\n\nIf you want to connect to Dgraph running on [Dgraph Cloud](https://cloud.dgraph.io) instance, then\nget the gRPC endpoint of your cluster that you can find in the\n[Settings section](https://cloud.dgraph.io/_/settings) of Dgraph Cloud console and obtain a Client\nor Admin API key (created in the [API key tab](https://cloud.dgraph.io/_/settings?tab=api-keys) of\nthe Setting section). Create the `client_stub` using the gRPC endpoint and the API key:\n\n```python3\nclient_stub = pydgraph.DgraphClientStub.from_cloud(\n    \"https://morning-glade.grpc.us-east-1.aws.cloud.dgraph.io:443\", \"\u003capi-key\u003e\")\nclient = pydgraph.DgraphClient(client_stub)\n```\n\nAlternatively, you can simply use a Dgraph connection string with the `open` function. For example:\n\n```python\nconn_str = \"dgraph://foo-bar.grpc.us-west-2.aws.cloud.dgraph.io:443?sslmode=verify-ca\u0026apikey=\u003cyour-api-connection-key\u003e\"\nclient = pydgraph.open(conn_str)\n\n# some time later...\nclient.close()\n```\n\nThe `DgraphClientStub.from_slash_endpoint()` method has been removed v23.0. Please use\n`DgraphClientStub.from_cloud()` instead.\n\n### Altering the Database\n\n#### Set the Dgraph types schema\n\nTo set the Dgraph types schema (aka DQL schema), create an `Operation` object, set the schema and\npass it to `DgraphClient#alter(Operation)` method.\n\n```python3\nschema = 'name: string @index(exact) .'\nop = pydgraph.Operation(schema=schema)\nclient.alter(op)\n```\n\nIndexes can be computed in the background. You can set the `run_in_background` field of\n`pydgraph.Operation` to `True` before passing it to the `Alter` function. You can find more details\n[here](https://docs.dgraph.io/master/query-language/#indexes-in-background).\n\n**Note** To deploy the GraphQL schema in python you have to use GraphQL client such as\n[python-graphql-client](https://github.com/prodigyeducation/python-graphql-client) to invoke the\nGraphQL admin mutation\n[updateGQLSchema](https://dgraph.io/docs/graphql/admin/#using-updategqlschema-to-add-or-modify-a-schema)\n\n```python3\nschema = 'name: string @index(exact) .'\nop = pydgraph.Operation(schema=schema, run_in_background=True)\nclient.alter(op)\n```\n\n#### Drop data\n\nTo drop all data and schema:\n\n```python3\n# Drop all data including schema from the Dgraph instance. This is a useful\n# for small examples such as this since it puts Dgraph into a clean state.\nop = pydgraph.Operation(drop_all=True)\nclient.alter(op)\n```\n\n**Note** If the Dgraph cluster contains a GraphQL Schema, it will also be deleted by this operation.\n\nTo drop all data and preserve the DQL schema:\n\n```python3\n# Drop all data from the Dgraph instance. Keep the DQL Schema.\nop = pydgraph.Operation(drop_op=\"DATA\")\nclient.alter(op)\n```\n\nTo drop a predicate:\n\n```python3\n# Drop the data associated to a predicate and the predicate from the schema.\nop = pydgraph.Operation(drop_op=\"ATTR\", drop_value=\"\u003cpredicate_name\u003e\")\nclient.alter(op)\n```\n\nthe same result is obtained using\n\n```python3\n# Drop the data associated to a predicate and the predicate from the schema.\nop = pydgraph.Operation(drop_attr=\"\u003cpredicate_name\u003e\")\nclient.alter(op)\n```\n\nTo drop a type definition from DQL Schema:\n\n```python3\n# Drop a type from the schema.\nop = pydgraph.Operation(drop_op=\"TYPE\", drop_value=\"\u003cpredicate_name\u003e\")\nclient.alter(op)\n```\n\n**Note** `drop_op=\"TYPE\"` just removes a type definition from the DQL schema. No data is removed\nfrom the cluster. The operation does not drop the predicates associated with the type.\n\n### Creating a Transaction\n\nTo create a transaction, call the `DgraphClient#txn()` method, which returns a new `Txn` object.\nThis operation incurs no network overhead.\n\nIt is good practice to call `Txn#discard()` in a `finally` block after running the transaction.\nCalling `Txn#discard()` after `Txn#commit()` is a no-op and you can call `Txn#discard()` multiple\ntimes with no additional side-effects.\n\n```python3\ntxn = client.txn()\ntry:\n  # Do something here\n  # ...\nfinally:\n  txn.discard()\n  # ...\n```\n\nTo create a read-only transaction, call `DgraphClient#txn(read_only=True)`. Read-only transactions\nare ideal for transactions which only involve queries. Mutations and commits are not allowed.\n\n```python3\ntxn = client.txn(read_only=True)\ntry:\n  # Do some queries here\n  # ...\nfinally:\n  txn.discard()\n  # ...\n```\n\nTo create a read-only transaction that executes best-effort queries, call\n`DgraphClient#txn(read_only=True, best_effort=True)`. Best-effort queries are faster than normal\nqueries because they bypass the normal consensus protocol. For this same reason, best-effort queries\ncannot guarantee to return the latest data. Best-effort queries are only supported by read-only\ntransactions.\n\n### Running a Mutation\n\n`Txn#mutate(mu=Mutation)` runs a mutation. It takes in a `Mutation` object, which provides two main\nways to set data: JSON and RDF N-Quad. You can choose whichever way is convenient.\n\n`Txn#mutate()` provides convenience keyword arguments `set_obj` and `del_obj` for setting JSON\nvalues and `set_nquads` and `del_nquads` for setting N-Quad values. See examples below for usage.\n\nWe define a person object to represent a person and use it in a transaction.\n\n```python3\n# Create data.\np = { 'name': 'Alice' }\n\n# Run mutation.\ntxn.mutate(set_obj=p)\n\n# If you want to use a mutation object, use this instead:\n# mu = pydgraph.Mutation(set_json=json.dumps(p).encode('utf8'))\n# txn.mutate(mu)\n\n# If you want to use N-Quads, use this instead:\n# txn.mutate(set_nquads='_:alice \u003cname\u003e \"Alice\" .')\n```\n\n```python3\n# Delete data\n\nquery = \"\"\"query all($a: string)\n {\n   all(func: eq(name, $a))\n    {\n      uid\n    }\n  }\"\"\"\nvariables = {'$a': 'Bob'}\n\nres = txn.query(query, variables=variables)\nppl = json.loads(res.json)\n\n# For a mutation to delete a node, use this:\ntxn.mutate(del_obj=person)\n```\n\nFor a complete example with multiple fields and relationships, look at the [simple project][simple]\nin the `examples` folder.\n\nSometimes, you only want to commit a mutation, without querying anything further. In such cases, you\ncan set the keyword argument `commit_now=True` to indicate that the mutation must be immediately\ncommitted.\n\nA mutation can be executed using `txn.do_request` as well.\n\n```python3\nmutation = txn.create_mutation(set_nquads='_:alice \u003cname\u003e \"Alice\" .')\nrequest = txn.create_request(mutations=[mutation], commit_now=True)\ntxn.do_request(request)\n```\n\n### Running a Query\n\nYou can run a query by calling `Txn#query(string)`. You will need to pass in a\n[DQL](https://dgraph.io/docs/query-language/) query string. If you want to pass an additional\ndictionary of any variables that you might want to set in the query, call\n`Txn#query(string, variables=d)` with the variables dictionary `d`.\n\nThe query response contains the `json` field, which returns the JSON response. Let’s run a query\nwith a variable `$a`, deserialize the result from JSON and print it out:\n\n```python3\n# Run query.\nquery = \"\"\"query all($a: string) {\n  all(func: eq(name, $a))\n  {\n    name\n  }\n}\"\"\"\nvariables = {'$a': 'Alice'}\n\nres = txn.query(query, variables=variables)\n\n# If not doing a mutation in the same transaction, simply use:\n# res = client.txn(read_only=True).query(query, variables=variables)\n\nppl = json.loads(res.json)\n\n# Print results.\nprint('Number of people named \"Alice\": {}'.format(len(ppl['all'])))\nfor person in ppl['all']:\n  print(person)\n```\n\nThis should print:\n\n```console\nNumber of people named \"Alice\": 1\nAlice\n```\n\nYou can also use `txn.do_request` function to run the query.\n\n```python3\nrequest = txn.create_request(query=query)\ntxn.do_request(request)\n```\n\n### Query with RDF response\n\nYou can get query result as a RDF response by calling `Txn#query(string)` with `resp_format` set to\n`RDF`. The response would contain a `rdf` field, which has the RDF encoded result.\n\n**Note:** If you are querying only for `uid` values, use a JSON format response.\n\n```python3\nres = txn.query(query, variables=variables, resp_format=\"RDF\")\nprint(res.rdf)\n```\n\n### Running an Upsert: Query + Mutation\n\nThe `txn.do_request` function allows you to use upsert blocks. An upsert block contains one query\nblock and one or more mutation blocks, so it lets you perform queries and mutations in a single\nrequest. Variables defined in the query block can be used in the mutation blocks using the `uid` and\n`val` functions implemented by DQL.\n\nTo learn more about upsert blocks, see the\n[Upsert Block documentation](https://dgraph.io/docs/mutations/upsert-block/).\n\n```python3\nquery = \"\"\"{\n  u as var(func: eq(name, \"Alice\"))\n}\"\"\"\n\nnquad = \"\"\"\n  uid(u) \u003cname\u003e \"Alice\" .\n  uid(u) \u003cage\u003e \"25\" .\n\"\"\"\n\nmutation = txn.create_mutation(set_nquads=nquad)\nrequest = txn.create_request(query=query, mutations=[mutation], commit_now=True)\ntxn.do_request(request)\n```\n\n### Running a Conditional Upsert\n\nThe upsert block also allows specifying a conditional mutation block using an `@if` directive. The\nmutation is executed only when the specified condition is true. If the condition is false, the\nmutation is silently ignored.\n\nSee more about Conditional Upserts [here](https://docs.dgraph.io/mutations/#conditional-upsert).\n\n```python3\nquery = \"\"\"\n  {\n    user as var(func: eq(email, \"wrong_email@dgraph.io\"))\n  }\n\"\"\"\n\ncond = \"@if(eq(len(user), 1))\"\nnquads = \"\"\"\n  uid(user) \u003cemail\u003e \"correct_email@dgraph.io\" .\n\"\"\"\n\nmutation = txn.create_mutation(cond=cond, set_nquads=nquads)\nrequest = txn.create_request(mutations=[mutation], query=query, commit_now=True)\ntxn.do_request(request)\n```\n\n### Committing a Transaction\n\nA transaction can be committed using the `Txn#commit()` method. If your transaction consist solely\nof `Txn#query` or `Txn#queryWithVars` calls, and no calls to `Txn#mutate`, then calling\n`Txn#commit()` is not necessary.\n\nAn error is raised if another transaction(s) modify the same data concurrently that was modified in\nthe current transaction. It is up to the user to retry transactions when they fail.\n\n```python3\ntxn = client.txn()\ntry:\n  # ...\n  # Perform any number of queries and mutations\n  # ...\n  # and finally...\n  txn.commit()\nexcept pydgraph.AbortedError:\n  # Retry or handle exception.\nfinally:\n  # Clean up. Calling this after txn.commit() is a no-op\n  # and hence safe.\n  txn.discard()\n```\n\n### Cleaning Up Resources\n\nTo clean up resources, you have to call `DgraphClientStub#close()` individually for all the\ninstances of `DgraphClientStub`.\n\n```python3\nSERVER_ADDR1 = \"localhost:9080\"\nSERVER_ADDR2 = \"localhost:9080\"\n\n# Create instances of DgraphClientStub.\nstub1 = pydgraph.DgraphClientStub(SERVER_ADDR1)\nstub2 = pydgraph.DgraphClientStub(SERVER_ADDR2)\n\n# Create an instance of DgraphClient.\nclient = pydgraph.DgraphClient(stub1, stub2)\n\n# Use client\n...\n\n# Clean up resources by closing all client stubs.\nstub1.close()\nstub2.close()\n```\n\n### Setting Metadata Headers\n\nMetadata headers such as authentication tokens can be set through the metadata of gRPC methods.\nBelow is an example of how to set a header named \"auth-token\".\n\n```python3\n# The following piece of code shows how one can set metadata with\n# auth-token, to allow Alter operation, if the server requires it.\n# metadata is a list of arbitrary key-value pairs.\nmetadata = [(\"auth-token\", \"the-auth-token-value\")]\ndg.alter(op, metadata=metadata)\n```\n\n### Setting a timeout\n\nA timeout value representing the number of seconds can be passed to the `login`, `alter`, `query`,\nand `mutate` methods using the `timeout` keyword argument.\n\nFor example, the following alters the schema with a timeout of ten seconds:\n`dg.alter(op, timeout=10)`\n\n### Async methods\n\nThe `alter` method in the client has an asynchronous version called `async_alter`. The async methods\nreturn a future. You can directly call the `result` method on the future. However. The DgraphClient\nclass provides a static method `handle_alter_future` to handle any possible exception.\n\n```python3\nalter_future = self.client.async_alter(pydgraph.Operation(schema=\"name: string @index(term) .\"))\nresponse = pydgraph.DgraphClient.handle_alter_future(alter_future)\n```\n\nThe `query` and `mutate` methods int the `Txn` class also have async versions called `async_query`\nand `async_mutation` respectively. These functions work just like `async_alter`.\n\nYou can use the `handle_query_future` and `handle_mutate_future` static methods in the `Txn` class\nto retrieve the result. A short example is given below:\n\n```python3\ntxn = client.txn()\nquery = \"query body here\"\nfuture = txn.async_query()\nresponse = pydgraph.Txn.handle_query_future(future)\n```\n\nKeep in mind that due to the nature of async calls, the async functions cannot retry the request if\nthe login is invalid. You will have to check for this error and retry the login (with the function\n`retry_login` in both the `Txn` and `Client` classes). A short example is given below:\n\n```python3\nclient = DgraphClient(client_stubs) # client_stubs is a list of gRPC stubs.\nalter_future = client.async_alter()\ntry:\n    response = alter_future.result()\nexcept Exception as e:\n  # You can use this function in the util package to check for JWT\n    # expired errors.\n    if pydgraph.util.is_jwt_expired(e):\n        # retry your request here.\n```\n\n## Examples\n\n[tls]: ./examples/tls\n[parse_datetime]: ./examples/parse_datetime\n\n- [simple][]: Quickstart example of using pydgraph.\n- [tls][]: Quickstart example that uses TLS.\n- [parse_datetime]: Demonstration of converting Dgraph's DateTime strings to native python datetime.\n\n## Development\n\n### Setting up environment\n\nThere are many ways to set up your local Python environment. We suggest some sane defaults here.\n\n- Use [pyenv](https://github.com/pyenv/pyenv) to manage your Python installations.\n- Most recent versions of Python should work, but the version of Python officially supported is\n  located in `.python-version`\n- Create a Python virtual environment using `python -m venv .venv`\n- Activate virtual environment via `source .venv/bin/activate`\n\n### Build from source\n\nTo build and install pydgraph locally, run\n\n```sh\npip install -e \".[dev]\"\n```\n\nIf you have made changes to the `pydgraph/proto/api.proto` file, you need need to regenerate the\nsource files generated by Protocol Buffer tools. To do that, install the\n[grpcio-tools][grpcio-tools] library and then run the following command:\n\n[grpcio-tools]: https://pypi.python.org/pypi/grpcio-tools\n\n```sh\npython scripts/protogen.py\n```\n\n### Running tests\n\nTo run the tests in your local machine, run:\n\n```bash\nbash scripts/local-test.sh\n```\n\nYou can run a specific test suite:\n\n```bash\nbash scripts/local-test.sh -v tests/test_connect.py::TestOpen\n```\n\nor an individual test:\n\n```bash\nbash scripts/local-test.sh -v tests/test_connect.py::TestOpen::test_connection_with_auth\n```\n\nThe test script requires that `docker` and `docker compose` are installed on your machine.\n\nThe script will take care of bringing up a Dgraph cluster and bringing it down after the tests are\nexecuted. The script connects to randomly selected ports for HTTP and gRPC requests to prevent\ninterference with clusters running on the default port. Docker and docker-compose need to be\ninstalled before running the script. Refer to the official\n[Docker documentation](https://docs.docker.com/) for instructions on how to install those packages.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypermodeinc%2Fpydgraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypermodeinc%2Fpydgraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypermodeinc%2Fpydgraph/lists"}