Skip to main content

🧰 pymoai - MontOps moai client for Python

PyPI Interrogate

This repository contains the source code for MontOps 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 MontOps Support here.

Requirements

Python 3.8 or above is required.

Documentation

For the latest documentation, see

Quickstart

Install the library with pip install pymoai

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

email/Password Authentication:

export MOAI_USERNAME=*************
export MOAI_PASSWORD=*************

If you already have a token, use that instead:

export MOAI_TOKEN=*****************************************

Example usage:

import os
import pandas as pd
from pymoai.client import MoaiClient

# If no credentials are supplied, then environment variables are required.
email = "tech@montops.ai"
password = "$montops123"

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

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

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

print("Health: ", health)

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

# Add a dataset to your moai system

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

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

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

Exception handling:

from pymoai.client import MoaiClient
from pymoai.exceptions import ApiResponseError, InvalidTokenError

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

Contributing

We will allow contributing soon!

License

Apache License 2.0

Metadata

Release files for pymoai 0.3.2

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

Source distribution (sdist)

Source distribution for pymoai 0.3.2
File Size Uploaded
pymoai-0.3.2.tar.gz 14.1 kB Details

Built distribution (wheel)

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

Total release size: 29.3 kB

Release files / pymoai-0.3.2.tar.gz

Download URL pymoai-0.3.2.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
107523ee85c43e42d2c2348c45dfb44a957061d6533f0bf61454f2458f28547f
BLAKE2b-256 checksum
How to use checksums
cfe1613b5af306cf9c6402651c3004660878beed49a4fca2e8d6df66e1322cc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.28.2 requests-toolbelt/0.10.1 urllib3/1.26.15 tqdm/4.65.0 importlib-metadata/6.1.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.10

Release files / pymoai-0.3.2-py3-none-any.whl

Download URL pymoai-0.3.2-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a0c83e1cd70ff749b2d7e53c9ab6fb239a9fe8002fa3b35f26b3e2c002ce77a2
BLAKE2b-256 checksum
How to use checksums
0f93eb63b17372720af7e99c6cd6720b2f0fd93e7c91c704985e4f0cba18496e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.6 readme-renderer/37.3 requests/2.28.2 requests-toolbelt/0.10.1 urllib3/1.26.15 tqdm/4.65.0 importlib-metadata/6.1.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

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