Connection¶
Module describing a connection.
-
class
qarnot.connection.Connection(fileconf=None, client_token=None, cluster_url=None, cluster_unsafe=False, cluster_timeout=None, storage_url=None, storage_unsafe=False, retry_count=5, retry_wait=1.0, cluster_custom_certificate=None, storage_custom_certificate=None)[source]¶ Bases:
objectRepresents the couple cluster/user to which submit tasks.
-
__init__(fileconf=None, client_token=None, cluster_url=None, cluster_unsafe=False, cluster_timeout=None, storage_url=None, storage_unsafe=False, retry_count=5, retry_wait=1.0, cluster_custom_certificate=None, storage_custom_certificate=None)[source]¶ Create a connection to a cluster with given config file, options or environment variables. Available environment variable are QARNOT_CLUSTER_URL, QARNOT_CLUSTER_UNSAFE, QARNOT_CLUSTER_TIMEOUT and QARNOT_CLIENT_TOKEN.
Parameters: - fileconf (str or dict) – path to a qarnot configuration file or a corresponding dict
- client_token (str) – API Token
- cluster_url (str) – (optional) Cluster url.
- cluster_unsafe (bool) – (optional) Disable certificate check
- cluster_timeout (int) – (optional) Timeout value for every request
- storage_url (str) – (optional) Storage service url.
- storage_unsafe (bool) – (optional) Disable certificate check
- retry_count (int) – (optional) ConnectionError retry count. Default to 5.
- retry_wait (float) – (optional) Retry on error wait time, progressive. (wait * (retry_count - retry_num). Default to 1s
Configuration sample:
[cluster] # url of the REST API url=https://localhost # No SSL verification ? unsafe=False [client] # auth string of the client token=login [storage] url=https://storage unsafe=False
-
s3client¶ Pre-configured s3 client object.
Return type: list( S3.Client)Returns: A list of ObjectSummary resources
-
s3resource¶ Pre-configured s3 resource object.
Return type: list( S3.ServiceResource)Returns: A list of ObjectSummary resources
-
user_info¶ Get information of the current user on the cluster.
Return type: Returns: Requested information.
Raises: - qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.QarnotGenericException – API general error, see message for details
-
buckets()[source]¶ Get the list of buckets.
Return type: list(class:~qarnot.bucket.Bucket). Returns: List of buckets
-
pools(summary=True, tags_intersect=None)[source]¶ Get the list of pools stored on this cluster for this user.
Parameters: Return type: List of
Pool.Returns: Pools stored on the cluster owned by the user.
Raises: - qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.QarnotGenericException – API general error, see message for details
-
tasks(tags=None, summary=True, tags_intersect=None)[source]¶ Get the list of tasks stored on this cluster for this user.
Parameters: Return type: List of
Task.Returns: Tasks stored on the cluster owned by the user.
Raises: - qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.QarnotGenericException – API general error, see message for details
-
jobs()[source]¶ Get the list of jobs stored on this cluster for this user.
Raises: - qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.QarnotGenericException – API general error, see message for details
-
retrieve_pool(uuid)[source]¶ Retrieve a
qarnot.pool.Poolfrom its uuidParameters: uuid (str) – Desired pool uuid
Return type: Returns: Existing pool defined by the given uuid
Raises: - qarnot.exceptions.MissingPoolException – pool does not exist
- qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.QarnotGenericException – API general error, see message for details
-
retrieve_task(uuid)[source]¶ Retrieve a
qarnot.task.Taskfrom its uuidParameters: uuid (str) – Desired task uuid
Return type: Returns: Existing task defined by the given uuid
Raises: - qarnot.exceptions.MissingTaskException – task does not exist
- qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.QarnotGenericException – API general error, see message for details
-
retrieve_job(uuid)[source]¶ Retrieve a
qarnot.job.Jobfrom its uuidParameters: uuid (str) – Desired job uuid
Return type: Returns: Existing job defined by the given uuid
Raises: - qarnot.exceptions.MissingJobException – job does not exist
- qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.QarnotGenericException – API general error, see message for details
-
retrieve_or_create_bucket(uuid)[source]¶ Retrieve a
Bucketfrom its description, or create a new one.Parameters: uuid (str) – the bucket uuid (name) Return type: BucketReturns: Existing or newly created bucket defined by the given name
-
retrieve_bucket(uuid)[source]¶ Retrieve a
Bucketfrom its uuid (name)Parameters: uuid (str) – Desired bucket uuid (name) Return type: BucketReturns: Existing bucket defined by the given uuid (name) Raises: botocore.exceptions.ClientError: Bucket does not exist, or invalid credentials
-
create_pool(name, profile, instancecount=1, shortname=None)[source]¶ Create a new
Pool.Parameters: Return type: Returns: The created
Pool.Note
See available profiles with
profiles().
-
create_elastic_pool(name, profile, minimum_total_slots=0, maximum_total_slots=1, minimum_idle_slots=0, minimum_idle_time_seconds=0, resize_factor=1, resize_period=90, shortname=None)[source]¶ Create a new
Pool.Parameters: - name (str) – given name of the pool
- profile (str) – which profile to use with this pool
- minimum_total_slots (int) – minimum number of instances to run for the pool
- maximum_total_slots (int) – maximum number of instances to run for the pool
- minimum_idle_slots (int) – the number of instances that can be idle before considering shrinking the pool
- minimum_idle_time_seconds (int) – the number of seconds before considering shrinking the pool
- resize_factor (float) – the speed with which we grow the pool to meet the demand
- resize_period (int) – the time between the load checks that decide if the pool grows or shrinks
- shortname (str) – optional unique friendly shortname of the pool
Return type: Returns: The created
Pool.Note
See available profiles with
profiles().
-
create_task(name, profile_or_pool=None, instancecount_or_range=1, shortname=None, job=None)[source]¶ Create a new
Task.Parameters: - name (str) – given name of the task
- profile_or_pool (str or
Poolor None) – which profile to use with this task, or which Pool to run task, or which job to attach it to - instancecount_or_range (int or str) – number of instances, or ranges on which to run task. Defaults to 1.
- shortname (str) – optional unique friendly shortname of the task
- job (
Job) – which job to attach the task to
Return type: Returns: The created
Task.Note
See available profiles with
profiles().
-
submit_tasks(tasks)[source]¶ Submit a list of
Task.:param List of
Task. :raises qarnot.exceptions.QarnotGenericException: API general error, see message for detailsNote
Will ensure all added files are on the resource bucket regardless of their uploading mode.
-
profiles()[source]¶ Get list of profiles available on the cluster.
Return type: list of
ProfileRaises: - qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.QarnotGenericException – API general error, see message for details
-
retrieve_profile(name)[source]¶ Get details of a profile from its name.
Return type: Raises: - qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.QarnotGenericException – API general error, see message for details
-
create_bucket(name)[source]¶ Create a new
Bucket. If the bucket already exist, retrieve the existing bucket.Parameters: name (str) – bucket name Return type: qarnot.bucket.BucketReturns: The created or existing Bucket.
-