Skip to main content

CLI and SDK tools for interacting with the Shaped API.

Project description

Python SDK

pip install shaped

Rank

import shaped

api_key = 'your_api_key' 
client = shaped.Client(api_key=api_key)

api_response = client.rank(
    model_name="amazon_beauty_product_recommendations",
    user_id="A2FRWMTWYJUK7P",
    return_metadata=True,
    item_ids=['B01AHSUT8M', 'B00GW7H5EY', 'B01GLA54SA', 'B0016PKWK6', 'B00PJD7KPG', 'B00BCI8OP2', 'B004FK7R02'],
)
print(api_response)

Retrieve

import shaped

api_key = 'your_api_key' 
client = shaped.Client(api_key=api_key)

api_response = client.retrieve(
    model_name="amazon_beauty_product_recommendations",
)
print(api_response)

Similar Items

import shaped

api_key = 'your_api_key' 
client = shaped.Client(api_key=api_key)

api_response = client.similar_items(
    model_name="amazon_beauty_product_recommendations", 
    item_id="B000FOI48G",
)
print(api_response)

Similar Users

import shaped

api_key = 'your_api_key' 
client = shaped.Client(api_key=api_key)

api_response = client.similar_users(
    model_name="amazon_beauty_product_recommendations", 
    user_id="A2FRWMTWYJUK7P",
)
print(api_response)

Complement Items

import shaped

api_key = 'your_api_key' 
client = shaped.Client(api_key=api_key)

api_response = client.complement_items(
    model_name="amazon_beauty_product_recommendations", 
    item_ids=['B000URXP6E', 'B0012Y0ZG2'],
)
print(api_response)

Maintainer Notes

To recreate the autogenerated code:

  1. brew install openapi-generator
  2. Copy across openapi.yaml from the shaped-docs repository to /sdk
  3. Navigate to /sdk and run the command:
openapi-generator generate -g python -i openapi.yaml -o python/ -p packageName=shaped.autogen --global-property models,apis,apiDocs=false,modelDocs=false,modelTests=false,apiTests=false,supportingFiles=api_client.py:api_response.py:configuration.py:exceptions.py:rest.py:__init__.py

Testing

pytest sdk/python/tests/test_rank.py --api-key 'api_key'


Shaped CLI

CLI for interactions with the Shaped API.

Installing the Shaped CLI

pip install shaped

Initialize

shaped init --api-key <API_KEY>

Model API

Create Model (File)

shaped create-model --file <PATH_TO_FILE>

Create Model (STDIN)

cat $(PATH_TO_FILE) | shaped create-model

List Models

shaped list-models

View Model

shaped view-model --model-name <MODEL_NAME>

Delete Model

shaped delete-model --model-name <MODEL_NAME>

Dataset API

Create Dataset

shaped create-dataset --file <PATH_TO_FILE>

List Datasets

shaped list-datasets

Dataset Insert

shaped dataset-insert --dataset-name <DATASET_NAME> --file <DATAFRAME_FILE> --type <FILE_TYPE> 

Delete dataset

shaped delete-dataset --dataset-name <DATASET_NAME>

Rank API

Rank

shaped rank --model-name <MODEL_NAME> --user-id <USER_ID>

Similar Items

shaped similar --model-name <MODEL_NAME> --item-id <ITEM_ID>

Similar Users

shaped similar --model-name <MODEL_NAME> --user-id <USER_ID>

Development

Installing the Shaped CLI from Test PyPI

Upon all pushes to main branch, a new version of the CLI is published to Test PyPI. To install the latest version of the CLI from Test PyPI, run the following commands:

conda create -n cli-dev python=3.9
conda activate cli-dev
export PACKAGE_VERSION={} # Specify the version you want to install
pip install --extra-index-url https://test.pypi.org/simple/ shaped-cli==$PACKAGE_VERSION

Releasing a new CLI version to PyPI

To release a new version of the CLI to PyPI, open a PR changing the version of the package in setup.py, following Semantic Versioning principles, e.g. 0.1.1.

CircleCI will generate an approval prompt when this branch is merged to main, and upon approval will publish to PyPI.

Project details


Download files

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

Source Distribution

shaped-0.14.0.tar.gz (56.4 kB view details)

Uploaded Source

Built Distribution

shaped-0.14.0-py3-none-any.whl (162.6 kB view details)

Uploaded Python 3

File details

Details for the file shaped-0.14.0.tar.gz.

File metadata

  • Download URL: shaped-0.14.0.tar.gz
  • Upload date:
  • Size: 56.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for shaped-0.14.0.tar.gz
Algorithm Hash digest
SHA256 62d11ec04d5b5baea0a052b306483003cfda8260211c5694433fc9d364439e70
MD5 8a210d558e83be38beba48ab418233b7
BLAKE2b-256 0ce73c9885ab04ecfe85f0946fb8a3ee4845dc278340afb5b2932312044d1f80

See more details on using hashes here.

File details

Details for the file shaped-0.14.0-py3-none-any.whl.

File metadata

  • Download URL: shaped-0.14.0-py3-none-any.whl
  • Upload date:
  • Size: 162.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for shaped-0.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7480ed11c9183a937340e75329c73f6d705a2a4962e46d7c6093ab7e57200292
MD5 9f6492f0730788992ecce5facd66d08f
BLAKE2b-256 44ef44ab707a2fea0afaf7c13e653c7f1d6efa13405ef62a5b760dd4e46c4752

See more details on using hashes here.

Supported by

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