Skip to main content

Build Status Verification codecov Documentation Status PyPI version PyPI - Python Version License: MIT Black

aiolancium

aiolancium is a simplistic python REST client for the Lancium Compute REST API utilizing asyncio. The client itself has been developed against the Lancium Compute REST API documentation.

Installation

aiolancium can be installed via PyPi using

pip install aiolancium

How to use aiolancium

from aiolancium.auth import Authenticator
from aiolancium.client import LanciumClient

# Authenticate yourself against the API and refresh your token if necessary
auth = Authenticator(api_key="<your_api_key>")

# Initialise the actual client
client = LanciumClient(api_url="https://portal.lancium.com/api/v1/", auth=auth)

# List details about the `lancium/ubuntu` container
await client.images.list_image("lancium/ubuntu")

# Create your hellow world first job.
job = {"job": {"name": "GridKa Test Job",
                   "qos": "high",
                   "image": "lancium/ubuntu",
                   "command_line": 'echo "Hello World"',
                   "max_run_time": 600}}

await client.jobs.create_job(**job)

# Show all your jobs and their status in Lancium compute
jobs = await client.jobs.show_jobs()

for job in jobs["jobs"]:
    # Retrieve the stdout/stdin output of your finished jobs
    await client.jobs.download_job_output(job["id"], "stdout.txt")
    await client.jobs.download_job_output(job["id"], "stderr.txt")
    
    # or download them to disk
    await client.download_file_helper("stdout.txt", "stdout.txt", job["id"])
    await client.download_file_helper("stderr.txt", "stderr.txt", job["id"])

# Delete all your jobs in Lancium compute
for job in jobs["jobs"]:
    await client.jobs.delete_job(id=job["id"])

In order to simplify file uploads and downloads to/from the Lancium compute platform, an upload/download helper method has been added to the client. The upload helper takes care of reading a file in binary format and uploading it in 32 MB chunks (default) to the Lancium persistent storage. The download helper downloads a file from the Lancium persistent storage to the local disks. The download helper also supports the download of jobs outputs (stdout.txt, stderr.txt) to local disk (see example above). Unfortunately, streaming of data is not support by the underlying simple-rest-client. Thus, the entire file is downloaded to memory before writing to the disk.

from aiolancium.auth import Authenticator
from aiolancium.client import LanciumClient

# Authenticate yourself against the API and refresh your token if necessary
auth = Authenticator(api_key="<your_api_key>")

# Initialise the actual client
client = LanciumClient(api_url="https://portal.lancium.com/api/v1/", auth=auth)

# Upload /bin/bash to /test on the Lancium persistent storage
await client.upload_file_helper(path="test", source="/bin/bash")

# Get information about the uploaded file
await client.data.get_file_info("/test")

# Download the file again
await client.download_file_helper("/test", destination="test_downloaded_again")

# Delete the uploaded file again, the 
arg = {"file-path": "/test"}
await client.data.delete_data_item(**arg)

# Alternative approach to delete the uploaded file
await client.data.delete_data_item("/test")

Metadata

Release files for aiolancium 0.2.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 aiolancium 0.2.2
File Size Uploaded
aiolancium-0.2.2.tar.gz 25.0 kB Details

Built distribution (wheel)

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

Total release size: 51.1 kB

Release files / aiolancium-0.2.2.tar.gz

Download URL aiolancium-0.2.2.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
01548da7322b57096bee21f2db0b4c550b1b8f22342f452b6932fa2ee31b0c3c
BLAKE2b-256 checksum
How to use checksums
2eee1c4efd2672e61b4811e7a1d727c550958cf1a7b9d1e9332b674965d47004
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.11.0 Darwin/21.6.0

Release files / aiolancium-0.2.2-py3-none-any.whl

Download URL aiolancium-0.2.2-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a6fe03f940a134178dcb683066ccab7a68c94ff4d37b20eceee26a9ceb3fa36
BLAKE2b-256 checksum
How to use checksums
d5854f66da3ffb4b9cc678edf1baf78e2da73a08864f31264b95b7aa7c95b5da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.11.0 Darwin/21.6.0

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

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