Skip to main content

Package to interact with the Modulos Platform

Project description

Modulos Client

PyPI version

This tool provides a Programmatic interface to interact with the Modulos platform.

Documentation

The documentation can be found on docs.modulos.ai

Installation

# install from PyPI
pip install modulos-client

API Key

Generate your API key here

Usage

import os
from modulos_client import Modulos

client = Modulos(
    # This is the default and can be omitted
    api_key=os.environ.get("MODULOS_API_KEY"),
)

While you can provide an api_key keyword argument, we recommend using python-dotenv to add MODULOS_API_KEY="My API Key" to your .env file so that your API Key is not stored in source control.

Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of modulos_client.APIConnectionError is raised.

When the API returns a non-success status code (that is, 4xx or 5xx response), a subclass of modulos_client.APIStatusError is raised, containing status_code and response properties.

All errors inherit from modulos_client.APIError.

import modulos_client
from modulos_client import Modulos

client = Modulos()

try:
    metrics = client.testing.logs.get_metrics(project_id)
except modulos_client.APIConnectionError as e:
    print("The server could not be reached")
    print(e.__cause__)  # an underlying Exception, likely raised within httpx.
except modulos_client.APIStatusError as e:
    print("Another non-200-range status code was received")
    print(e.status_code)
    print(e.response)

Error codes are as followed:

Status Code Error Type
400 BadRequestError
401 AuthenticationError
403 PermissionDeniedError
404 NotFoundError
422 UnprocessableEntityError
>=500 InternalServerError
N/A APIConnectionError

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

modulos_client-0.9.0.tar.gz (14.6 kB view hashes)

Uploaded Source

Built Distribution

modulos_client-0.9.0-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

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