aiolancium


Nameaiolancium JSON
Version 0.2.2 PyPI version JSON
download
home_page
SummaryAsyncIO Client for Lancium
upload_time2022-12-07 10:49:05
maintainer
docs_urlNone
authorManuel Giffels
requires_python>=3.6.2,<4.0.0
licenseMIT
keywords asyncio lancium compute client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Build Status](https://github.com/giffels/aiolancium/actions/workflows/unittests.yaml/badge.svg)](https://github.com/giffels/aiolancium/actions/workflows/unittests.yaml)
[![Verification](https://github.com/giffels/aiolancium/actions/workflows/verification.yaml/badge.svg)](https://github.com/giffels/aiolancium/actions/workflows/verification.yaml)
[![codecov](https://codecov.io/gh/giffels/aiolancium/branch/main/graph/badge.svg)](https://codecov.io/gh/giffels/aiolancium)
[![Documentation Status](https://readthedocs.org/projects/aiolancium/badge/?version=latest)](https://aiolancium.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/aiolancium.svg)](https://badge.fury.io/py/aiolancium)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aiolancium.svg?style=flat-square)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/giffels/aiolancium/blob/master/LICENSE)
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/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](https://lancium.github.io/compute-api-docs/api.html).

## Installation
aiolancium can be installed via [PyPi](https://pypi.org/) using

```bash
pip install aiolancium
```

## How to use aiolancium

```python
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.

```python
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")
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "aiolancium",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6.2,<4.0.0",
    "maintainer_email": "",
    "keywords": "asyncio,lancium,compute client",
    "author": "Manuel Giffels",
    "author_email": "giffels@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/2e/ee/1c4efd2672e61b4811e7a1d727c550958cf1a7b9d1e9332b674965d47004/aiolancium-0.2.2.tar.gz",
    "platform": null,
    "description": "[![Build Status](https://github.com/giffels/aiolancium/actions/workflows/unittests.yaml/badge.svg)](https://github.com/giffels/aiolancium/actions/workflows/unittests.yaml)\n[![Verification](https://github.com/giffels/aiolancium/actions/workflows/verification.yaml/badge.svg)](https://github.com/giffels/aiolancium/actions/workflows/verification.yaml)\n[![codecov](https://codecov.io/gh/giffels/aiolancium/branch/main/graph/badge.svg)](https://codecov.io/gh/giffels/aiolancium)\n[![Documentation Status](https://readthedocs.org/projects/aiolancium/badge/?version=latest)](https://aiolancium.readthedocs.io/en/latest/?badge=latest)\n[![PyPI version](https://badge.fury.io/py/aiolancium.svg)](https://badge.fury.io/py/aiolancium)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aiolancium.svg?style=flat-square)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/giffels/aiolancium/blob/master/LICENSE)\n[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n# aiolancium\n\naiolancium is a simplistic python REST client for the Lancium Compute REST API utilizing asyncio. The client itself has\nbeen developed against the [Lancium Compute REST API documentation](https://lancium.github.io/compute-api-docs/api.html).\n\n## Installation\naiolancium can be installed via [PyPi](https://pypi.org/) using\n\n```bash\npip install aiolancium\n```\n\n## How to use aiolancium\n\n```python\nfrom aiolancium.auth import Authenticator\nfrom aiolancium.client import LanciumClient\n\n# Authenticate yourself against the API and refresh your token if necessary\nauth = Authenticator(api_key=\"<your_api_key>\")\n\n# Initialise the actual client\nclient = LanciumClient(api_url=\"https://portal.lancium.com/api/v1/\", auth=auth)\n\n# List details about the `lancium/ubuntu` container\nawait client.images.list_image(\"lancium/ubuntu\")\n\n# Create your hellow world first job.\njob = {\"job\": {\"name\": \"GridKa Test Job\",\n                   \"qos\": \"high\",\n                   \"image\": \"lancium/ubuntu\",\n                   \"command_line\": 'echo \"Hello World\"',\n                   \"max_run_time\": 600}}\n\nawait client.jobs.create_job(**job)\n\n# Show all your jobs and their status in Lancium compute\njobs = await client.jobs.show_jobs()\n\nfor job in jobs[\"jobs\"]:\n    # Retrieve the stdout/stdin output of your finished jobs\n    await client.jobs.download_job_output(job[\"id\"], \"stdout.txt\")\n    await client.jobs.download_job_output(job[\"id\"], \"stderr.txt\")\n    \n    # or download them to disk\n    await client.download_file_helper(\"stdout.txt\", \"stdout.txt\", job[\"id\"])\n    await client.download_file_helper(\"stderr.txt\", \"stderr.txt\", job[\"id\"])\n\n# Delete all your jobs in Lancium compute\nfor job in jobs[\"jobs\"]:\n    await client.jobs.delete_job(id=job[\"id\"])\n```\n\nIn order to simplify file uploads and downloads to/from the Lancium compute platform, an upload/download helper method \nhas been added to the client. \nThe upload helper takes care of reading a file in binary format and uploading it in 32 MB chunks (default) to the \nLancium persistent storage. The download helper downloads a file from the Lancium persistent storage to the local disks.\nThe download helper also supports the download of jobs outputs (stdout.txt, stderr.txt) to local disk (see example \nabove).\nUnfortunately, streaming of data is not support by the underlying `simple-rest-client`. Thus, the entire file is \ndownloaded to memory before writing to the disk.\n\n```python\nfrom aiolancium.auth import Authenticator\nfrom aiolancium.client import LanciumClient\n\n# Authenticate yourself against the API and refresh your token if necessary\nauth = Authenticator(api_key=\"<your_api_key>\")\n\n# Initialise the actual client\nclient = LanciumClient(api_url=\"https://portal.lancium.com/api/v1/\", auth=auth)\n\n# Upload /bin/bash to /test on the Lancium persistent storage\nawait client.upload_file_helper(path=\"test\", source=\"/bin/bash\")\n\n# Get information about the uploaded file\nawait client.data.get_file_info(\"/test\")\n\n# Download the file again\nawait client.download_file_helper(\"/test\", destination=\"test_downloaded_again\")\n\n# Delete the uploaded file again, the \narg = {\"file-path\": \"/test\"}\nawait client.data.delete_data_item(**arg)\n\n# Alternative approach to delete the uploaded file\nawait client.data.delete_data_item(\"/test\")\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "AsyncIO Client for Lancium",
    "version": "0.2.2",
    "split_keywords": [
        "asyncio",
        "lancium",
        "compute client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "4a0f93c0baf6d5a5dce9813bd1c45a9f",
                "sha256": "4a6fe03f940a134178dcb683066ccab7a68c94ff4d37b20eceee26a9ceb3fa36"
            },
            "downloads": -1,
            "filename": "aiolancium-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4a0f93c0baf6d5a5dce9813bd1c45a9f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6.2,<4.0.0",
            "size": 26125,
            "upload_time": "2022-12-07T10:49:02",
            "upload_time_iso_8601": "2022-12-07T10:49:02.905389Z",
            "url": "https://files.pythonhosted.org/packages/d5/85/4f66da3ffb4b9cc678edf1baf78e2da73a08864f31264b95b7aa7c95b5da/aiolancium-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "c5988d555f424b4000e6c17c3fa05c25",
                "sha256": "01548da7322b57096bee21f2db0b4c550b1b8f22342f452b6932fa2ee31b0c3c"
            },
            "downloads": -1,
            "filename": "aiolancium-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "c5988d555f424b4000e6c17c3fa05c25",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6.2,<4.0.0",
            "size": 24992,
            "upload_time": "2022-12-07T10:49:05",
            "upload_time_iso_8601": "2022-12-07T10:49:05.174187Z",
            "url": "https://files.pythonhosted.org/packages/2e/ee/1c4efd2672e61b4811e7a1d727c550958cf1a7b9d1e9332b674965d47004/aiolancium-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-07 10:49:05",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "aiolancium"
}
        
Elapsed time: 0.01504s