Metadata-Version: 2.1
Name: pymsx
Version: 0.3.0
Summary: Mosaics AI Python Client
Home-page: https://www.mosaics.ai/
License: Apache-2.0
Keywords: AIOps,MLOps,ML Model Registry,ML Model Store,ML Monitoring
Author: mosaics.ai
Author-email: info@mosaics.ai
Requires-Python: >=3.8.1,<3.10
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: boto3 (>=1.26.74,<2.0.0)
Requires-Dist: dacite (>=1.8.0,<2.0.0)
Requires-Dist: dataconf (>=2.1.3,<3.0.0)
Requires-Dist: numpy (>=1.24.2,<2.0.0)
Requires-Dist: pandas (>=1.5.3,<2.0.0)
Requires-Dist: pydantic (>=1.10.5,<2.0.0)
Requires-Dist: requests (>=2.28.2,<3.0.0)
Requires-Dist: requests-toolbelt (>=0.10.1,<0.11.0)
Requires-Dist: urllib3 (==1.25.11)
Project-URL: Repository, https://github.com/Mosaics-ai/pymsx
Description-Content-Type: text/markdown

# 🧰  pymsx - Mosaics AI MSX Client for Python

[![PyPI](https://img.shields.io/pypi/v/pymsx?style=flat-square)](https://pypi.org/project/pymsx/)
[![Interrogate](https://raw.githubusercontent.com/Mosaics-ai/pymsx/main/assets/interrogate_badge.svg)](https://github.com/Mosaics-AI/pymsx)

This repository contains the source code for Mosaics AI's official python client. This client is currently in pre-alpha version, so feedback is always welcome!

You are welcome to file an issue here for general use cases. You can also contact Mosaics Support [here](help.mosaics.ai).

## Requirements

Python 3.8 or above is required.

## Documentation

For the latest documentation, see

- [Mosaics AI](https://www.mosaics.ai)

## Quickstart

Install the library with `pip install pymsx`

Note: Don't hard-code authentication secrets into your Python. Use environment variables

email/Password Authentication:

```bash
export MSX_USERNAME=*************
export MSX_PASSWORD=*************
```

If you already have a token, use that instead:

```bash
export MSX_TOKEN=*****************************************
```

Example usage:
```python
import os
import pandas as pd
from pymsx.client import MsxClient

# If no credentials are supplied, then environment variables are required.
email = "help@mosaics.ai"
password = "$mosaics123"

# ...or try using an active token.
# This may fail, see exception handling below.
token = None

# First create client with active token or credentials
msx = MsxClient(
    # ...using email/password
    email=email,
    password=password,
    # ...or if using token, token will take priority
    token=token
)

# Check the health of your server
health = msx.health().dict()

print("Health: ", health)

assert health is not None and health['status'] == 'live'

# Add a dataset to your msx system

# From a DataFrame
path = "/path/to/dataset/data.csv"
df = pd.DataFrame(path)
result = msx.datasets.add(df=df)

# Or pass in a string path to read from fs directly
result = msx.datasets.add(path=path)

if result.ok:
    print("DataFrame uploaded: ", result.details)
else
    print("Upload failed: ", result.error)
```

Exception handling:
```python
from pymsx.client import MsxClient
from pymsx.exceptions import ApiResponseError, InvalidTokenError

try:
    try:
        # An InvalidToken error is raised if the token is expired or incorrect
        msx = MsxClient(
            token=token
        )
    except InvalidTokenError:
        print(f"Token invalid, logging in instead.")
        # Catch all other errors using ApiResponseErrors
        msx = MsxClient(
            email=email,
            password=password
        )
except ApiResponseError as e:
    print(f"Could not create msx client: {e.error}")
    return
```

## Contributing

We will allow contributing soon!

## License

[Apache License 2.0](LICENSE)

