Clients¶
ImagesClient
¶
-
class
puddle.client.
ImagesClient
(cloud, server_address=None, authorizer=None)¶ Bases:
puddle.client.base_client.BaseCloudClient
Client used to query images in Puddle.
-
__init__
(cloud, server_address=None, authorizer=None)¶ Creates new instance of this client tied to specified cloud provider.
- Parameters
server_address (
Optional
[str
]) – Address of the backend.cloud (
CloudProvider
) – cloud which should be used by this client.authorizer (
Optional
[Authorizer
]) – optional, Authorizer to use, if not set, then the default Authorizer which reads credentials from env is used.
- Return type
- Returns
BaseAuthorizer used by this client
-
list_available
()¶ - Return type
List
[Image
]- Returns
List of all available Images for authenticated user.
-
property
server_address
¶ - Returns
Backend address.
-
property
user
¶ - Return type
LoginUser
- Returns
Currently logged in user, might be None.
-
InstanceTypesClient
¶
-
class
puddle.client.
InstanceTypesClient
(cloud, server_address=None, authorizer=None)¶ Bases:
puddle.client.base_client.BaseCloudClient
Client used to query instance types in Puddle.
-
__init__
(cloud, server_address=None, authorizer=None)¶ Creates new instance of this client tied to specified cloud provider.
- Parameters
server_address (
Optional
[str
]) – Address of the backend.cloud (
CloudProvider
) – cloud which should be used by this client.authorizer (
Optional
[Authorizer
]) – optional, Authorizer to use, if not set, then the default Authorizer which reads credentials from env is used.
- Return type
- Returns
BaseAuthorizer used by this client
-
list_available
()¶ - Return type
List
[InstanceType
]- Returns
List of all available InstanceTypes for authenticated user.
-
property
server_address
¶ - Returns
Backend address.
-
property
user
¶ - Return type
LoginUser
- Returns
Currently logged in user, might be None.
-
SystemsClient
¶
-
class
puddle.client.
SystemsClient
(cloud, server_address=None, authorizer=None)¶ Bases:
puddle.client.base_client.BaseCloudClient
Client used to manage the systems in Puddle.
-
DEFAULT_DISK_SIZE
= 256¶ Default disk size in GB.
-
DEFAULT_IDLE_TIMEOUT_MIN
= 60¶ Default idle timeout in minutes.
-
POLL_INTERVAL_S
= 5¶ Polling interval in seconds.
-
POLL_TIMEOUT_MINUTES
= 20¶ Timeout in minutes to wait till operation (such as system start) is completed.
-
__init__
(cloud, server_address=None, authorizer=None)¶ Creates new instance of this client tied to specified cloud provider.
- Parameters
server_address (
Optional
[str
]) – Address of the backend.cloud (
CloudProvider
) – cloud which should be used by this client.authorizer (
Optional
[Authorizer
]) – optional, Authorizer to use, if not set, then the default Authorizer which reads credentials from env is used.
- Return type
- Returns
BaseAuthorizer used by this client
-
create
(name, disk_size_gb=256, image=None, product=None, version=None, instance_type=None, instance_type_name=None, idle_interval=60, tags=None)¶ Creates new system with specified parameters. This function returns without waiting for the cloud operation to finish. To wait use the wait_for_system_started function.
- Parameters
name (
str
) – Name of the system. Must be unique, must contain only lowercase alphanumeric characters, numbers and hyphens and cannot be longer than 64 chars.disk_size_gb (
int
) – Size of disk in GB. Defaults to SystemsClient.DEFAULT_DISK_SIZE. Must be between 256 and 1024.image (
Optional
[Image
]) – Image to be used by this system. If not set, then product and version must be set.product (
Optional
[Product
]) – Product id to be used by this system. If not set, then image must be set.version (
Optional
[str
]) – Version of product to be used by this system. If not set then image must be set.instance_type (
Optional
[InstanceType
]) – Instance type to be used by this system. If not set then instance_type_name must be set.instance_type_name (
Optional
[str
]) – instance type name to be used by this system. If not set then instance_type must be set.idle_interval (
int
) – Idle timeout interval. System will be stopped if idle for this number of minutes. Defaults to SystemsClient.DEFAULT_IDLE_TIMEOUT_MIN. Must be <= than 240 (4 * 60) minutes.tags (
Optional
[List
[TagData
]]) – List of TagData.
- Return type
System
- Returns
Newly created System.
- Raise
ValidationFailedError if any of the validations fails.
-
fail
(system_id)¶ Marks the system with specified system id as failed. This function does not wait for the operation to finish. To wait use the wait_for_system_failed function.
- Parameters
system_id (
str
) – Id of the system which should be marked as failed.- Raise
PreconditionFailedError if system cannot be marked as failed, for example because the option to manually mark the system as failed is not available at this moment. To check if it is possible to manually mark this system as failed use the can_fail property of the relevant System instance.
-
find_by_name
(name)¶ Returns system with specified name or None if no such system exists.
- Parameters
name (
str
) – Name of the required system.- Return type
Optional
[System
]- Returns
System with specified name or None if no such system exists.
-
get
(system_id)¶ Gets a system with specified system_id. Could be used to refresh a loaded system.
- Parameters
system_id – Id of the required system.
- Return type
Optional
[System
]- Returns
New System created from data returned by backend.
-
get_cu_consumption_info
()¶ - Return type
CUConsumptionInfo
- Returns
current cu consumption info. Useful to check how much CU is currently available and what is the current CU consumption of your systems.
-
list
()¶ - Return type
List
[System
]- Returns
List of all non-terminated systems for current user.
-
refresh_idle_timeout
(system_id)¶ Refreshes idle timeout for the system with specified id.
- Parameters
system_id (
str
) – Id of the system which should refresh its idle timeout.- Raise
PreconditionFailedError if the idle timeout cannot be refreshed, for example because the system is not started.
-
restart
(system_id)¶ Restarts the system with specified system id. This function does not wait for the cloud operation to finish. To wait use the wait_for_system_started function.
- Parameters
system_id (
str
) – Id of the system which should be restarted.- Raise
PreconditionFailedError if system cannot be restarted, for example because it’s not in started state.
-
property
server_address
¶ - Returns
Backend address.
-
start
(system_id)¶ Starts the system with specified system id. This function does not wait for the cloud operation to finish. To wait use the wait_for_system_started function.
- Parameters
system_id (
str
) – Id of the system which should be started.- Raise
PreconditionFailedError if system cannot be started, for example because it’s not in stopped state.
-
stop
(system_id)¶ Stops the system with specified system id. This function does not wait for the cloud operation to finish. To wait use the wait_for_system_stopped function.
- Parameters
system_id (
str
) – Id of the system which should be stopped.- Raise
PreconditionFailedError if system cannot be stopped, for example because it’s not in started nor in failed state.
-
terminate
(system_id)¶ Terminates the system with specified system id. This function does not wait for the cloud operation to finish. To wait use the wait_for_system_terminated function. This operation cannot be reverted.
- Parameters
system_id (
str
) – Id of the system which should be terminated.- Raise
PreconditionFailedError if system cannot be terminated, for example because it’s not in started nor in failed nor in stopped state.
-
update_config_toml
(system_id, config_toml)¶ Updates DriverlessAI config.toml of the system with specified id. System has to be restarted in order for this new config.toml to be applied. This function does not wait for the config.toml to be uploaded. To wait for the upload to be completed, use the wait_for_config_toml_uploaded function.
- Parameters
system_id (
str
) – Id of the system which config.toml should be updated.config_toml (
str
) – str containing the new config.toml content.
- Raise
PreconditionFailedError if the config.toml cannot be updated, for example because the system is not started.
-
property
user
¶ - Return type
LoginUser
- Returns
Currently logged in user, might be None.
-
wait_for_config_toml_uploaded
(system_id)¶ Waits for config.toml to be uploaded. This times out after SystemsClient.POLL_TIMEOUT_MINUTES minutes. This operation will also fail if the system’s config.toml status enters failed state while waiting.
- Parameters
system_id (
str
) – Id of the system to wait for.
-
wait_for_system_failed
(system_id)¶ Waits for the system with specified id to be failed. This times out after SystemsClient.POLL_TIMEOUT_MINUTES minutes.
- Parameters
system_id (
str
) – Id of the system to wait for.
-
wait_for_system_started
(system_id)¶ Waits for the system with specified id to be started. This times out after SystemsClient.POLL_TIMEOUT_MINUTES minutes. This operation will also fail if the system enters failed state while waiting.
- Parameters
system_id (
str
) – Id of the system to wait for.
-
wait_for_system_stopped
(system_id)¶ Waits for the system with specified id to be stopped. This times out after SystemsClient.POLL_TIMEOUT_MINUTES minutes. This operation will also fail if the system enters failed state while waiting.
- Parameters
system_id (
str
) – Id of the system to wait for.
-
wait_for_system_terminated
(system_id)¶ Waits for the system with specified id to be terminated. This times out after SystemsClient.POLL_TIMEOUT_MINUTES minutes. This operation will also fail if the system enters failed state while waiting.
- Parameters
system_id (
str
) – Id of the system to wait for.
-
TagsClient
¶
-
class
puddle.client.
TagsClient
(server_address=None, authorizer=None)¶ Bases:
puddle.client.base_client.BasePuddleClient
Client used to query the tags in Puddle.
-
__init__
(server_address=None, authorizer=None)¶ Creates new instance of this client.
- Parameters
server_address (
Optional
[str
]) – Optional, address of the backend. If not set then it is read from PUDDLE_SERVER_ADDRESS environment variable. If even this variable is not set, than a ValueError is risen.authorizer (
Optional
[Authorizer
]) – optional, Authorizer to use, if not set, then the default Authorizer which reads credentials from env is used.
- Return type
- Returns
BaseAuthorizer used by this client
-
list
()¶ - Returns
List of all Tag object.
-
property
server_address
¶ - Returns
Backend address.
-
tag_data_to_pb_tag_data
(tags)¶ Translation method between puddle.client.models.tag_data.TagData and puddle.client.proto.v2.system_service_pb2.TagData.
- Parameters
tags (
List
[TagData
]) – Source list of puddle.client.models.tag_data.TagData- Return type
Optional
[List
[TagData
]]- Returns
List of puddle.client.proto.v2.system_service_pb2.TagData created from the tags.
-
property
user
¶ - Return type
LoginUser
- Returns
Currently logged in user, might be None.
-