Pool¶
Module to handle a pool.
-
class
qarnot.pool.Pool(connection, name, profile, instancecount=1, shortname=None)[source]¶ Bases:
objectRepresents a Qarnot pool.
Note
A
Poolmust be created withqarnot.connection.Connection.create_pool()or retrieved withqarnot.connection.Connection.pools()orqarnot.connection.Connection.retrieve_pool().-
__init__(connection, name, profile, instancecount=1, shortname=None)[source]¶ Create a new
Pool.Parameters:
-
classmethod
from_json(connection, json_pool, is_summary=False)[source]¶ Create a Pool object from a json pool.
Parameters: - connection (qarnot.connection.Connection) – the cluster connection
- json_pool (dict) – Dictionary representing the pool
Returns: The created
Pool.
-
submit()[source]¶ Submit pool to the cluster if it is not already submitted.
Raises: - qarnot.exceptions.QarnotGenericException – API general error, see message for details
- qarnot.exceptions.MaxPoolException – Pool quota reached
- qarnot.exceptions.NotEnoughCreditsException – Not enough credits
- qarnot.exceptions.UnauthorizedException – invalid credentials
Note
Will ensure all added files are on the resource bucket regardless of their uploading mode.
-
update(flushcache=False)[source]¶ Update the pool object from the REST Api. The flushcache parameter can be used to force the update, otherwise a cached version of the object will be served when accessing properties of the object. Cache behavior is configurable with
auto_updateandupdate_cache_time.Raises: - qarnot.exceptions.QarnotGenericException – API general error, see message for details
- qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.MissingTaskException – pool does not represent a valid one
-
commit()[source]¶ Replicate local changes on the current object instance to the REST API
Raises: - qarnot.exceptions.QarnotGenericException – API general error, see message for details
- qarnot.exceptions.UnauthorizedException – invalid credentials
This function need to be call to apply the local elastic pool setting modifications. .. note:: When updating buckets’ properties, auto update will be disabled until commit is called.
-
setup_elastic(minimum_total_slots=0, maximum_total_slots=1, minimum_idle_slots=0, minimum_idle_time_seconds=0, resize_factor=1, resize_period=90)[source]¶ Setup the pool elastic properties
Parameters: - minimum_total_slots (int) – Minimum slot number for the pool in elastic mode. Defaults to 0.
- maximum_total_slots (int) – Maximum slot number for the pool in elastic mode. Defaults to 1.
- minimum_idle_slots (int) – Minimum idling slot number. Defaults to 0.
- minimum_idle_time_seconds (int) – Wait time in seconds before closing an unused slot if the number of unused slots are upper than the minimum_idle_slots. Defaults to 0.
- resize_factor (float) – Growing factor of the pool. It must be a number between 0 and 1. Defaults to 1.
- resize_period (int) – Refresh rate of resizing the pool in elastic mode. Defaults to 90.
-
delete(purge_resources=False)[source]¶ Delete this pool on the server.
Parameters: purge_resources (bool) – parameter value is used to determine if the bucket is also deleted. Defaults to False.
Raises: - qarnot.exceptions.QarnotGenericException – API general error, see message for details
- qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.MissingTaskException – pool does not exist
-
close()[source]¶ Close this pool if running.
Raises: - qarnot.exceptions.QarnotGenericException – API general error, see message for details
- qarnot.exceptions.UnauthorizedException – invalid credentials
- qarnot.exceptions.MissingPoolException – pool does not exist
-
uuid¶ Type: strGetter: Returns this pool’s uuid The pool’s uuid.
Automatically set when a pool is submitted.
-
state¶ Type: strGetter: return this pool’s state State of the pool.
- Value is in
- UnSubmitted
- Submitted
- PartiallyDispatched
- FullyDispatched
- PartiallyExecuting
- FullyExecuting
- Closing
- Closed
- Failure
- PendingDelete
Warning
this is the state of the pool when the object was retrieved, call
update()for up to date value.
-
resources¶ Type: list( Bucket)Getter: Returns this pool’s resources bucket Setter: Sets this pool’s resources bucket Represents resource files.
-
name¶ Type: strGetter: Returns this pool’s name Setter: Sets this pool’s name The pool’s name.
Can be set until pool is submitted.
-
shortname¶ Type: strGetter: Returns this pool’s shortname Setter: Sets this pool’s shortname The pool’s shortname, must be DNS compliant and unique, if not provided, will default to
uuid.Can be set until pool is submitted.
Type: :class:list(str) Getter: Returns this pool’s tags Setter: Sets this pool’s tags Custom tags.
-
profile¶ Type: strGetter: Returns this pool’s profile Setter: Sets this pool’s profile The profile to run the pool with.
Can be set until
submit()is called.
-
instancecount¶ Type: intGetter: Returns this pool’s instance count Setter: Sets this pool’s instance count Number of instances needed for the pool.
Can be set until
submit()is called.
-
running_core_count¶ Type: intGetter: Returns this pool’s running core count Number of core running inside the pool.
-
running_instance_count¶ Type: intGetter: Returns this pool’s running instance count Number of instances running inside the pool.
-
errors¶ Type: list( str)Getter: Returns this pool’s error list Error reason if any, empty string if none
-
creation_date¶ Type: strGetter: Returns this pool’s creation date Creation date of the pool (UTC Time)
-
status¶ Type: qarnot.status.StatusGetter: Returns this pool’s status Status of the task
-
auto_update¶ Type: boolGetter: Returns this pool’s auto update state Setter: Sets this pool’s auto update state Auto update state, default to True When auto update is disabled properties will always return cached value for the object and a call to
update()will be required to get latest values from the REST Api.
-
update_cache_time¶ Type: intGetter: Returns this pool’s auto update state Setter: Sets this pool’s auto update state Cache expiration time, default to 5s
-
is_elastic¶ Type: boolGetter: Returns this pool’s is_elastic Setter: Sets this pool’s is_elastic Define if you use a static or an elastic pool.
-
elastic_minimum_slots¶ Type: intGetter: Returns this pool’s elastic_minimum_slots Setter: Sets this pool’s elastic_minimum_slots The minimum slot number of the elastic pool. Define the minimum number of pool instances stay open during the pool execution.
-
elastic_maximum_slots¶ Type: intGetter: Returns this pool’s elastic_maximum_slots Setter: Sets this pool’s elastic_maximum_slots The maximum slot number of the elastic pool. Define the maximum number of pool instances opened during the pool execution.
-
elastic_minimum_idle_slots¶ Type: intGetter: Returns this pool’s elastic_minimum_idle_slots Setter: Sets this pool’s elastic_minimum_idle_slots The minimum idle number of the elastic pool. Define the minimum number of the idle pool instances stay opened during the pool execution. It should be lower to elastic_minimum_slots to be usefull
-
elastic_minimum_idle_time¶ Type: intGetter: Returns this pool’s elastic_minimum_idle_time Setter: Sets this pool’s elastic_minimum_idle_time Wait time in seconds before closing an unused slot if the number of unused slots are upper than the minimum_idle_slots.
-
elastic_resize_factor¶ Type: floatGetter: Returns this pool’s elastic_resize_factor Setter: Sets this pool’s elastic_resize_factor The resize factor of the pool. It represent the resize factor of the slots. It’s a decimal number upper than 0 and and equal or lower the 1
-
elastic_resize_period¶ Type: intGetter: Returns this pool’s elastic_resize_period Setter: Sets this pool’s elastic_resize_period The resize period of the elastic pool in second. This is the refresh rate of resizing the elastic pool.
-
preparation_command_line¶ Type: str:Getter: Returns this pool’s command line. Setter: set the pool’s command line. Update the pool command line if needed The command line is a command running before each task execution.
-
constants¶ Type: dictionary{ str:str}Getter: Returns this pool’s constants dictionary. Setter: set the pool’s constants dictionary. Update the constants if needed Constants are the parametrazer of the profils. Use them to adjust your profile parametter.
-
constraints¶ Type: dictionary{ str:str}Getter: Returns this pool’s constraints dictionary. Setter: set the pool’s constraints dictionary. Update the constraints if needed advance usage
-
tasks_default_wait_for_pool_resources_synchronization¶ Type: boolGetter: Returns this task’s tasks_default_wait_for_pool_resources_synchronization. Setter: set the task’s tasks_default_wait_for_pool_resources_synchronization. Raises: qarnot.exceptions.AttributeError – can’t set this attribute on a launched task
-
auto_delete¶ Autodelete this pool if it is finished and your max number of pool is reach
Can be set until
submit()is called.Type: boolGetter: Returns is this pool must autodelete Setter: Sets this pool’s autodelete Default_value: “False” Raises: AttributeError – if you try to reset the auto_delete after the pool is submit
-
completion_ttl¶ The pool will be auto delete completion_ttl after it is finished
Can be set until
submit()is called.Getter: Returns this pool’s completed time to live. Type: strSetter: Sets this pool’s this pool’s completed time to live. Type: strordatetime.timedeltaDefault_value: “” Raises: AttributeError – if you try to set it after the pool is submitted The completion_ttl must be a timedelta or a time span format string (example: ‘d.hh:mm:ss’ or ‘hh:mm:ss’)
-