OSCAR API for python
Project description
Python OSCAR API
Contents
Sample usage
- Sample code that creates a client and gets information about the cluster
from oscar_python.client import Client
client = Client("cluster-id","https://cluster-endpoint", "username", "password", True)
# get the cluster information
info = client.get_cluster_info()
print(info.text)
- Sample code to create a simple service with the cowsay example and afterwards make a synchronous invocation.
from oscar_python.client import Client
client = Client("cluster-id","https://cluster-endpoint", "username", "password", True)
err = client.create_service("/somepath/cowsay.yaml")
if not err:
res = client.run_service("cowsay", '{"message": "Hi there"}')
if res.status_code == 200:
print(res.text)
API methods
Cluster methods
get_cluster_info
# get the cluster information
info = client.get_cluster_info() # returns an http response
get_cluster_config
# get the cluster config
config = client.get_cluster_config() # returns an http response
Service methods
get_service
# get the definition of a service
service = client.get_service("service_name") # returns an http response
list_services
# get a list of all the services deployed
services = client.list_services() # returns an http response
create_service
# create a service
err = client.create_service("path_to_fdl") # returns nothing if the service is created or an error if something goes wrong
update_service
# update a service
err = client.update_service("service_name","path_to_fdl") # returns nothing if the service is created or an error if something goes wrong
remove_service
# remove a service
response = client.remove_service("service_name") # returns an http response
run_service
The input
parameter may not be passed if the function doesn't require an input.
# make a synchronous execution
response = client.run_service("service_name", input="input") # returns an http response
Logs methods
get_job_logs
# get logs of a job
logs = client.get_job_logs("service_name", "job_id") # returns an http response
list_jobs
# get a list of jobs in a service
log_list = client.list_jobs("service_name") # returns an http response
remove_job
# remove a job of a service
response = client.remove_job("service_name", "job_id") # returns an http response
remove_all_jobs
# remove all jobs in a service
response = client.remove_all_jobs("service_name") # returns an http response
Storage usage
You can create a storage object to operate over the different storage providers defined on a service with the method create_storage_client
as it follows:
storage_service = client.create_storage_client("service_name") # returns a storage object
Note : The
storage_provider
parameter on the storage methods follows the format:["storage_provider_type"].["storage_provider_name"]
wherestorage_provider_type
is one of the suported storage providers (minIO, S3, Onedata or webdav) andstorage_provider_name
is the identifier (ex: minio.default)
list_files_from_path
This method returns a json with the info except for Onedata, which returns an http response.
# get a list of the files of one of the service storage provider
files = storage_service.list_files_from_path("storage_provider") # returns json
upload_file
# upload a file from a local path to a remote path
response = storage_service.upload_file("storage_provider", "local_path", "remote_path")
download_file
# download a file from a remote path to a local path
response = storage_service.download_file("storage_provider", "local_path", "remote_path")
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
Hashes for oscar_python-1.0.1b2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a5a21ce6c12e4d7232fdbb5aff79cc991ec3bc17fbbc8607fd19a55c903c953 |
|
MD5 | 6b6649dc3b190ec4cd702bf2bf7bf423 |
|
BLAKE2b-256 | 6db75155f982020b1ef665c3afa0912868e6f036e59f922ed4ef4f3ebb17abc7 |