Skip to main content

Ople Client

Table of Contents

  1. Overview
  2. Installation and Setup
  3. Python Client
  4. Terminal Client

Overview

Ople has created two clients to simplify the integration with your codebase and help you be more productive. You can use the python client to connect to your Ople models with your python code. You can also leverage the ople-client command to make predictions directly from the terminal.

Installation and Setup

  1. Install python3
  2. Run pip3 install ople (If it doesnt work run python3 -m pip install ople)
  3. Setup ENV variables to make the workflow easier
    1. Run export OPLE_KEY="<YOUR OPLE_KEY>"
    2. Run export OPLE_SECRET="<YOUR OPLE_SECRET>"
    3. Run export OPLE_MODEL_ID="<YOUR OPLE_MODEL_ID>"
  4. If you want to use S3 to get data then you need to setup aws
    1. Run export AWS_KEY="<YOUR AWS_KEY>"
    2. Run export AWS_SECRET="<YOUR AWS_SECRET>"

Python Client

Use the python code snippet below. All you need to update is the code for getting the input. The client handles the following inputs:

  • Dictionary with S3 information: '{"bucket": "", "path": ""}'`
  • Path to Local CSV File
  • String in CSV format
  • Dictioanry in Ople Format: '{"columns": [<YOUR COLUMNS>], "rows": [[<YOUR ROW>]]}'
  • Pandas DataFrame

Here is the code snippet:

from ople.client import OpleClient
import os

# ****************************************************

input = "<YOUR CODE TO GET INPUT>"

# ****************************************************

# Specify what model to run
ople_key = os.environ['OPLE_KEY']
ople_secret = os.environ['OPLE_SECRET']
ople_model_id = os.environ['OPLE_MODEL_ID']


# OPTIONAL Parameters to use S3 to upload
aws_key = os.environ['AWS_KEY']
aws_secret = os.environ['AWS_SECRET']

# Connect to Specified Model
if aws_key or aws_key:
    model = OpleClient(ople_key, ople_secret, ople_model_id)
else:
    model = OpleClient(ople_key, ople_secret, ople_model_id, aws_key, aws_secret)

# Specify Prediction Parameters
shap = False
global_shap = False
allow_unknown_categories = True

# Make a Prediction with model
result = model.predict(input,
              shap=shap,
              global_shap=global_shap,
              allow_unknown_categories=allow_unknown_categories)

Terminal Client

To run the terminal client you need to follow the installation and setup steps above. After that you will be able to run the ople-client command. Here are the parameters you can specify:

  • '-s', '--shap': This flag returns the shap values for each predictions
  • '-g', '--global_shap': This flag returns the Global Shap values for each predictions
  • '-u', '--allow_unknown_categories': This flag
  • '-K', '--key': This will set the ople key to whatever comes after it
  • '-S', '--secret': : This will set the ople secret to whatever comes after it
  • '-ID', '--model_id': : This will set the model_id to whatever comes after it
  • '-AS', '--aws_secret': : This will set the AWS secret to whatever comes after it
  • '-AK', '--aws_key': : This will set the AWS key to whatever comes after it

Here are some examples of how to run the command:

ople-client -u -s -g '<YOUR FILE PATH>/<FILENAME>'

ople-client -u -s -g '{"bucket": "<YOUR BUCKET>", "path": "<YOUR S3 FILEPATH>"}'

ople-client -u -s -g '<YOUR CSV STRING>'

ople-client -u -s -g '{"columns": [<YOUR COLUMNS>], "rows": [[<YOUR ROW>]]}'

Release files for ople 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for ople 1.0.1
File Interpreter ABI Platform
ople-1.0.1-py3-none-any.whl Python 3 none any Details

Release files / ople-1.0.1-py3-none-any.whl

Download URL ople-1.0.1-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5a192e03f4bb8124267fb24343e37525ce4c3020d50af8d1ee3dbf526ed2575
BLAKE2b-256 checksum
How to use checksums
0b1b7e811af651a5878eb45e9bc1bc48fae9a9c6d8e40f118331f3b52e664af6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page