Skip to main content

Python agent for protopia

Project description

Python Protopia Agent

This is a Python implementation of the Protopia Agent.

Install via Pypi

pip install protopia

Usage via Pypi

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

Development

Prerequisites

Install the following programs:

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

Preconfiguration

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.

You will get the predefined agent in AWS cognito console New user creation is described in the cloud/example/nose_store/upload

Installation for local package

Once above is set then you can install the package by following command

pip install .

Build the package

You can execute the following line to build the package

python setup.py bdist_wheel

Upload the package to Pypi

You'll need twine to upload the package

pip install twine

Then you'll need ID and Password for Pypi. contact alan@protopia.ai to get it.

twine upload dist/{build location from above}
# ex twine upload dist/protopia-0.1.0-py3-none-any.whl

Generting Python From ProtocolBuffer

A script is provided to generate Python code from the ProtocolBuffer defintion of the gRPC protocol exposed by Protopia Cloud. To re-generate Python code from the ProtocolBuffer definition, run:

make protoc

This will be executed in the cloud repo

Then copy cloud/protos/protopia-api/api in cloud repo and paste to py-agent/protopia/api

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

protopia-0.3.2-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

Details for the file protopia-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: protopia-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 39.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for protopia-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3fd9c4e55bfc23192a661387306cacfe262e50c465a77037cc7c178ee88c34e0
MD5 84b4742503fbd6e5ee051204b0fa63d1
BLAKE2b-256 2465b1092842f04dd63bde0fc63f3a6633f04bddc4b65cee23c28224b7d2607f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page