A Python client for the Cluster Arena API
Project description
ClusterArena
ClusterArena is a Python library that provides easy access to the Cluster Arena API. It allows you to manage jobs, add new jobs, and fetch job details seamlessly.
Table of Contents
Installation
To install the ClusterArena package, run the following command:
pip install cluster_arena
Configuration
Before using the ClusterArena library, you need to set up your API key. You can do this by setting the CLUSTER_ARENA_API_KEY environment variable or passing the API key directly when initializing the library.
Usage
Initializing ClusterArena
To use ClusterArena, first import the library and create an instance of the ClusterArena class:
from cluster_arena import ClusterArena
cluster_arena = ClusterArena('your-api-key-here')
Alternatively, you can set the CLUSTER_ARENA_API_KEY environment variable and initialize without passing the API key:
from cluster_arena import ClusterArena
cluster_arena = ClusterArena()
Fetching Jobs
To fetch all jobs, use the get_jobs method:
def fetch_jobs():
try:
jobs = cluster_arena.get_jobs()
print('Jobs:', jobs)
except Exception as error:
print('Error fetching jobs:', str(error))
fetch_jobs()
Adding a Job
To add a new job, use the add_job method. The job data must include a title and description:
from cluster_arena import JobData
def add_new_job():
job_data = JobData(
title='New Job Title',
description='Description of the new job',
# Add more fields as needed
)
try:
new_job = cluster_arena.add_job(job_data)
print('New Job Added:', new_job)
except Exception as error:
print('Error adding job:', str(error))
add_new_job()
Fetching Job Details
To fetch details of a specific job, use the get_job_details method and pass the job ID:
def fetch_job_details(job_id: str):
try:
job_details = cluster_arena.get_job_details(job_id)
print('Job Details:', job_details)
except Exception as error:
print('Error fetching job details:', str(error))
fetch_job_details('job-id-here')
Error Handling
The ClusterArena library raises exceptions when API requests fail or when invalid data is provided. Make sure to handle these exceptions appropriately in your application:
try:
# Your code here
except Exception as error:
print('An error occurred:', str(error))
Contributing
We welcome contributions to the ClusterArena library! If you have suggestions, bug reports, or want to contribute code, please open an issue or submit a pull request on our GitHub repository.
Steps to Contribute
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Make your changes and commit them with a descriptive message.
- Push your changes to your fork.
- Open a pull request on the main repository.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cluster_arena-1.0.2.tar.gz.
File metadata
- Download URL: cluster_arena-1.0.2.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0660165739d02c0edd104b181ffcd63ba51e4d6d3baa961543c779cc15c741bf
|
|
| MD5 |
a435b4aa0ea915f2bb9e230b7a979217
|
|
| BLAKE2b-256 |
bb51769005d087b771765e9060e7216c87b45af92f7f7312fec7b14dbd0f415c
|
File details
Details for the file cluster_arena-1.0.2-py3-none-any.whl.
File metadata
- Download URL: cluster_arena-1.0.2-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e34fdad7aed061ce40dd940c6fd631fbb51697b42fa23b650f8e1057e3923258
|
|
| MD5 |
980b6bf41119be2808c7eacd819c5cdc
|
|
| BLAKE2b-256 |
3749d5f87fe6360af20bdc962faabb9aa77fed2fcda22d110632d694380f8327
|