Metadata-Version: 2.1
Name: shaped
Version: 0.14.1
Summary: CLI and SDK tools for interacting with the Shaped API.
Home-page: https://github.com/shaped-ai/shaped-cli
Author: Shaped Team
Author-email: support@shaped.ai
Keywords: shaped-ai
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Requires-Python: >=3.8, <3.12
Description-Content-Type: text/markdown
Requires-Dist: typer>=0.7.0
Requires-Dist: requests>=2.28.1
Requires-Dist: pydantic>=2.8.2
Requires-Dist: pyyaml>=6.0
Requires-Dist: pyarrow==11.0.0
Requires-Dist: pandas==1.5.3
Requires-Dist: tqdm==4.65.0
Requires-Dist: s3fs==0.4.2
Requires-Dist: fsspec==2023.5.0
Requires-Dist: numpy==1.26.4
Requires-Dist: urllib3<2.1.0,>=1.25.3
Requires-Dist: python-dateutil
Requires-Dist: typing-extensions>=4.7.1
Requires-Dist: pytest>=6.2.5
Requires-Dist: pytest-mock==3.14.0

# Python SDK

## Installation

### Local Development

```sh
pip install -e .
```

### Pip Installation

```sh
pip install shaped
```

## Rank

```python
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
```python
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
```python
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
```python
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
```python
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 `~` 
1. Change `-g python` to the language you want to generate
1. Change `-o python/` to the directory you want to output to
3. Navigate to `~` and run the command:

### Python
```bash
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
```

### Node.js
```bash
openapi-generator generate -i openapi.yaml -g javascript -o nodejs/src -c config.yaml --global-property models,apis,apiDocs=false,modelDocs=false,modelTests=false,apiTests=false,supportingFiles=ApiClient.js
```

## Testing
`pytest python/tests/test_rank.py --api-key 'api_key'`
`npm test`
---

# 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:

```bash
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](https://semver.org) 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.
