Skip to main content

Mosaics AI Python Client

Project description

🧰 pymsx - Mosaics AI MSX Client for Python

PyPI Interrogate

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.

Requirements

Python 3.8 or above is required.

Documentation

For the latest documentation, see

Quickstart

Install the library with pip install pymsx

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

email/Password Authentication:

export MSX_USERNAME=*************
export MSX_PASSWORD=*************

If you already have a token, use that instead:

export MSX_TOKEN=*****************************************

Example usage:

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:

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

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

pymsx-0.2.1.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymsx-0.2.1-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file pymsx-0.2.1.tar.gz.

File metadata

  • Download URL: pymsx-0.2.1.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using 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.14 tqdm/4.64.1 importlib-metadata/6.0.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.10

File hashes

Hashes for pymsx-0.2.1.tar.gz
Algorithm Hash digest
SHA256 68e397f533cb2cd720337bd9a1f09e6f29748bd8e50ba472c8d79e045b3aba6d
MD5 5a079335286c8a4c9928e2e329fba3bc
BLAKE2b-256 63534f6041d40f1f52b9e7dc1d8e49f0fd1c5122762835d7ed46d7872c2c1d16

See more details on using hashes here.

File details

Details for the file pymsx-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pymsx-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using 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.14 tqdm/4.64.1 importlib-metadata/6.0.0 keyring/23.13.1 rfc3986/2.0.0 colorama/0.4.6 CPython/3.10.10

File hashes

Hashes for pymsx-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a86ca19dc91e446432f35c2bbc20b80a9dc22b548ca0784863ced95416d7ff1
MD5 022a530ea21c5cdfe8efc25ebaaa854d
BLAKE2b-256 150f3b564d3daccf77ed27aa6ce7dab5c622198f2653ac2d4e5e83d02677abad

See more details on using hashes here.

Supported by

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