Skip to content

Commit 4241815

Browse files
authored
Protobuf metadata (#94)
* proto metadata first setup * cleanup * cleanup & structured transaction async response * fix * get protobuf metadata function * adding v2 show results * fix name & filename content disposition regular expressions * txn to txn_file * adding integration tests * cleanup * adding ci workflow * fix yaml * typo * adding check for proto generated code * align python version with README * enable flake8 linter * fix linter * updating readme
1 parent b04b34d commit 4241815

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1074
-287
lines changed

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
ignore = F811, E501
3+
exclude = env,.git,__pycache__,railib/pb,build,dist
4+
max-line-length = 79
5+
max-complexity = 18
6+

.github/workflows/build.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
schedule:
6+
- cron: '30 5 * * *'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Initialize Python 3.7
15+
uses: actions/setup-python@v1
16+
with:
17+
python-version: 3.7
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install flake8
23+
pip install -r requirements.txt
24+
pip install -e ./
25+
26+
- name: Generate Protobuf
27+
run: python -m grpc_tools.protoc -I railib/pb --python_out=./railib/pb railib/pb/*.proto
28+
29+
- name: flake8 linter
30+
run: flake8 .
31+
32+
- name: test
33+
env:
34+
CLIENT_ID: ${{ secrets.CLIENT_ID }}
35+
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
36+
CLIENT_CREDENTIALS_URL: ${{ secrets.CLIENT_CREDENTIALS_URL }}
37+
run: |
38+
python tests/integration.py

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
__pycache__
66
build/
77
dist/
8+
env/
89
rai_sdk.egg-info/

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# The RelationalAI Software Development Kit for Python
22

3+
| Workflow | Status |
4+
| --------------------------- | ---------------------------------------------------------------------- |
5+
| Continuous Integration (CI) | ![build](https://github.com/RelationalAI/rai-sdk-python/actions/workflows/build.yaml/badge.svg) |
6+
| [Publish to PYPI](https://pypi.org/project/rai-sdk/) | ![publish](https://github.com/RelationalAI/rai-sdk-python/actions/workflows/publish.yaml/badge.svg) |
7+
38
The RelationalAI (RAI) SDK for Python enables developers to access the RAI
49
REST APIs from Python.
510

@@ -35,6 +40,7 @@ Install from source in `editable` mode.
3540
```console
3641
$ git clone git@github.com:RelationalAI/rai-sdk-python.git
3742
$ cd rai-sdk-python
43+
$ [sudo] pip install -r requirements.txt
3844
$ [sudo] pip install -e .
3945
```
4046

@@ -79,6 +85,12 @@ config file.
7985

8086
You can copy `config.spec` from the root of this repo and modify as needed.
8187

88+
## Generate python protobuf sources from protobuf specification
89+
90+
```shell
91+
python -m grpc_tools.protoc -I railib/pb --python_out=./railib/pb railib/pb/*.proto
92+
```
93+
8294
## Examples
8395

8496
Each of the example files in the `./examples` folder is standalone and can be

examples/__init__.py

Whitespace-only changes.

examples/cancel_transaction.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ def run(id: str, profile: str):
3030
if __name__ == "__main__":
3131
p = ArgumentParser()
3232
p.add_argument("id", type=str, help="transaction id")
33-
p.add_argument("-p", "--profile", type=str,
34-
help="profile name", default="default")
33+
p.add_argument("-p", "--profile", type=str, help="profile name", default="default")
3534
args = p.parse_args()
3635
try:
3736
run(args.id, args.profile)

examples/clone_database.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License
1414

1515
"""Clone an existing database by creating a new database and setting the
16-
optional api.create_database `source` argument to the name of the database
16+
optional api.create_database `source` argument to the name of the database
1717
to clone."""
1818

1919
from argparse import ArgumentParser
@@ -34,7 +34,6 @@ def run(database: str, source: str, profile: str):
3434
p = ArgumentParser()
3535
p.add_argument("database", type=str, help="database name")
3636
p.add_argument("source", type=str, help="name of database to clone")
37-
p.add_argument("-p", "--profile", type=str,
38-
help="profile name", default="default")
37+
p.add_argument("-p", "--profile", type=str, help="profile name", default="default")
3938
args = p.parse_args()
4039
run(args.database, args.source, args.profile)

examples/create_database.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ def run(database: str, profile: str):
3030
if __name__ == "__main__":
3131
p = ArgumentParser()
3232
p.add_argument("database", type=str, help="database name")
33-
p.add_argument("-p", "--profile", type=str,
34-
help="profile name", default="default")
33+
p.add_argument("-p", "--profile", type=str, help="profile name", default="default")
3534
args = p.parse_args()
3635
try:
3736
run(args.database, args.profile)

examples/create_engine.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ def run(engine: str, size: str, profile: str):
4242
if __name__ == "__main__":
4343
p = ArgumentParser()
4444
p.add_argument("engine", type=str, help="engine name")
45-
p.add_argument("--size", type=str, default="XS",
46-
help="engine size (default: XS)")
47-
p.add_argument("-p", "--profile", type=str,
48-
help="profile name", default="default")
45+
p.add_argument("--size", type=str, default="XS", help="engine size (default: XS)")
46+
p.add_argument("-p", "--profile", type=str, help="profile name", default="default")
4947
args = p.parse_args()
5048
try:
5149
run(args.engine, args.size, args.profile)

examples/create_oauth_client.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ def run(name: str, permissions: List[str], profile: str):
3535
p = ArgumentParser()
3636
p.add_argument("name", type=str, help="OAuth client name")
3737
perms = "', '".join(Permission)
38-
p.add_argument("--permissions", nargs="*",
39-
help="OAuth client permissions. By default it will be "
40-
"assigned the same permissions as the creating entity "
41-
"(user or OAuth client). Available: '{0}'".format(perms))
42-
p.add_argument("-p", "--profile", type=str,
43-
help="profile name", default="default")
38+
p.add_argument(
39+
"--permissions",
40+
nargs="*",
41+
help="OAuth client permissions. By default it will be "
42+
"assigned the same permissions as the creating entity "
43+
"(user or OAuth client). Available: '{0}'".format(perms),
44+
)
45+
p.add_argument("-p", "--profile", type=str, help="profile name", default="default")
4446
args = p.parse_args()
4547
try:
4648
run(args.name, args.permissions, args.profile)

0 commit comments

Comments
 (0)