Skip to main content

OASM SDK for Python

The OASM SDK for Python provides a convenient interface to interact with the OASM (Open API Service Manager) API. This SDK allows you to easily manage workers and communicate with the OASM service.

Features

  • Easy-to-use client for OASM API
  • Functional options pattern for flexible client configuration
  • Built-in retry mechanism for robust API communication
  • Support for worker registration and keep-alive signals
  • Comprehensive error handling with custom exceptions
  • Full type hints for better development experience

Installation

To install the OASM SDK, you can use pip:

pip install oasm-sdk

Or if you have the source code:

pip install .

Requirements

  • Python 3.8 or higher
  • requests>=2.31.0
  • urllib3>=1.26.0

Quick Start

Creating a Client

from oasm_sdk.client import Client, with_api_url, with_api_key

# Create a client with default settings
client = Client()

# Create a client with custom settings
client = Client(
    with_api_url("http://localhost:6276"),  # Replace with your API URL
    with_api_key("your-api-key-here")       # Replace with your API key
)

Health Check

try:
    is_healthy = client.health()
    print(f"API is {'healthy' if is_healthy else 'unhealthy'}")
except Exception as e:
    print(f"Health check failed: {e}")

Worker Management

Joining a Worker

from oasm_sdk.worker import worker_join

try:
    response = worker_join(client)
    print(f"Worker joined with ID: {response.id}")
    print(f"Worker token: {response.token}")
except Exception as e:
    print(f"Failed to join worker: {e}")

Sending Keep-Alive Signal

from oasm_sdk.worker import worker_alive

try:
    token = "your-worker-token"
    response = worker_alive(client, token)
    print(f"Keep-alive response: {response.alive}")
except Exception as e:
    print(f"Keep-alive failed: {e}")

Running the Example

To run the example code:

python examples/main.py

Make sure to update the API URL and API key in the example file before running it.

API Reference

Client

The Client class is the main entry point for interacting with the OASM API.

Constructor

Client(*opts: Option)

Creates a new client instance with the provided options.

Options

  • with_api_url(api_url: str): Sets the base API URL
  • with_api_key(api_key: str): Sets the API key
  • with_session(session: Session): Sets a custom requests session

Methods

  • health() -> bool: Checks the health status of the API

Worker Functions

  • worker_join(client: Client) -> WorkerJoinResponse: Registers a new worker
  • worker_alive(client: Client, token: str) -> WorkerAliveResponse: Sends a keep-alive signal

Exceptions

  • APIError: Raised when the API returns an error response

Development

Running Tests

To run the tests, use:

python -m pytest

Dependencies

To install development dependencies:

pip install -r requirements.txt

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for oasm-sdk 0.1.3

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

Source distribution (sdist)

Source distribution for oasm-sdk 0.1.3
File Size Uploaded
oasm_sdk-0.1.3.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for oasm-sdk 0.1.3
File Interpreter ABI Platform
oasm_sdk-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 17.4 kB

Release files / oasm_sdk-0.1.3.tar.gz

Download URL oasm_sdk-0.1.3.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d9ee58cabfdd63a5358365f9c774661d3eafd4e0be2b049d1870fc41d985addf
BLAKE2b-256 checksum
How to use checksums
686a20faf2ae9fb10799f324a542452353858c0488a9bd752363668e0fe1eed7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.4

Release files / oasm_sdk-0.1.3-py3-none-any.whl

Download URL oasm_sdk-0.1.3-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d70e1c5d77202e0b6b653355a3f62aecc97fd5987955c8046b05b91e41f98e5b
BLAKE2b-256 checksum
How to use checksums
fa1d441dee33ebc0c0339c18500c4403b84dcdcfb3972cd283dde3ef20b28192
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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