Metadata-Version: 2.1
Name: protopia
Version: 0.1.0
Summary: Python agent for protopia
Home-page: https://github.com/protopia-ai/py-agent
Author: Alan Synn
Author-email: alan@protopia.ai
License: UNKNOWN
Download-URL: https://githur.com/protopia-ai/py-agent/archive/1.0.tar.gz
Keywords: protopia,protopia-agent
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3
Description-Content-Type: text/markdown

# Python Protopia Agent

This is a Python implementation of the Protopia Agent.

## Install via Pypi

```shell script
pip install protopia
```

## Usage via Pypi

```python
import protopia

client = protopia.Agent()
client.get_option()
# returns will be
# > PROTOPIA_CLOUD_URL is set to api.stage-01.stage.protopia.ai:443
# > TOKEN_URL is set to https://protopia-cloud-stage-01.auth.us-east-1.amazoncognito.com/oauth2/token
# > SCOPES is set to ['https://api.stage-01.protopia.ai/noise:read']
# > OIDC_CLIENT_ID is set to None
# > OIDC_CLIENT_SECRET is set to None

client.set_client(client_id, client_secret)
# returns will be (See below to retrieve client_id and client_secret)
# > OIDC_CLIENT_ID is set to client_id
# > OIDC_CLIENT_SECRET is set to client_secret

client.connect()
# returns will be
# > successfully connected to staging cloud API

dist = client.get_noise_distribution(nnid)
# returns will be encrypted noise distribution
```
## Prerequisites
Install the following programs:

* Python version 3.9+
* Run `pip3 install -r requirements.txt`
* `protoc`
  * In MacOS this can be installed by running `brew install protoc`

## Running the agent
The following environment variables must be exported prior to running the agent:

- `OIDC_CLIENT_ID` the client ID of the agent issued by Cognito.
- `OIDC_CLIENT_SECRET` the client secret of the agent issued by Cognito.

A demo agent is created with credentials uploaded to LastPass. Access is granted to `hadi@protopia.ai`. The credentials can be retrieved from AWS console / Conginto.

Once the above environment variables are exposed, the agent can be run by running the following command:

```shell script
python3 agent.py
```

## Generting Python From ProtocolBuffer
A script is provided to generate Python code from the [ProtocolBuffer defintion of the gRPC protocol](../../api/protos/protopia/api/noise/v1beta1/distribution.proto) exposed by Protopia Cloud. To re-generate Python code from the ProtocolBuffer definition, run:
```shell script
make protoc
```


