Skip to main content

Module clients.dai_engine.dai_engine_client

Classes

DAIEngineClient

class DAIEngineClient(connection_config: h2o_engine_manager.clients.connection_config.ConnectionConfig, default_workspace_id: str, verify_ssl: bool = True, ssl_ca_cert: Optional[str] = None)

DAIEngineClient manages Driverless AI engines.

Initializes DAIEngineClient. Do not initialize manually, use h2o_engine_manager.login() instead.

Args
connection_config : ConnectionConfig
AIEM connection configuration object.
default_workspace_id : str
The default workspace ID which will client use to manipulate with DAI engines.
verify_ssl
Set to False to disable SSL certificate verification.
ssl_ca_cert
Path to a CA cert bundle with certificates of trusted CAs.

Methods

create_engine

def create_engine(self, engine_id: Optional[str] = None, version: Optional[str] = None, cpu: Optional[int] = None, gpu: Optional[int] = None, memory_bytes: Optional[str] = None, storage_bytes: Optional[str] = None, max_idle_duration: Optional[str] = None, max_running_duration: Optional[str] = None, profile_id: Optional[str] = None, workspace_id: str = '', display_name: str = '', config: Dict[str, str] = , annotations: Dict[str, str] = , validate_only: bool = False, profile: str = '') ‑> h2o_engine_manager.clients.dai_engine.dai_engine.DAIEngine

Creates Driverless AI engine and initiates launch. Immediately returned engine had just begun launching.

Args
engine_id : str, optional

The ID to use for the Driverless AI engine, which will become the final component of the engine's resource name. If left unspecified, the client will generate a random value. This value must:

  • contain 1-63 characters
  • contain only lowercase alphanumeric characters or hyphen ('-')
  • start with an alphabetic character
  • end with an alphanumeric character
version : str, optional
Driverless AI version identifier. For example: "1.10.1" or "latest". If not specified, a default value will be set by server.
cpu : int, optional
The amount of CPU units allocated for the engine. If not specified, a default value will be set by server.
gpu : int, optional
Number of nvidia.com/gpu Kubernetes resource units. If not specified, a default value will be set by server.
memory_bytes : str, optional

Quantity of bytes. If not specified, a default value will be set by server. Example 8G, 16Gi. Detailed syntax:

  • [quantity] = [number][suffix]
  • [suffix] = [binarySI] | [decimalSI]
  • [binarySI] = Ki | Mi | Gi | Ti | Pi
  • [decimalSI] = k | M | G | T | P
storage_bytes : str, optional
Quantity of bytes. Example 250G, 2T. Same syntax applies as memory_bytes parameter. If not specified, a default value will be set by server.
max_idle_duration : str, optional
Maximum time an engine can be idle. When exceeded, the engine will pause. Must be specified as a number with s suffix. Example 3600s. If not specified, a default value will be set by server.
max_running_duration : str, optional
Maximum time na engine can be running. When exceeded, the engine will pause. Must be specified as a number with s suffix. Example 36000s. If not specified, a default value will be set by server.
profile_id : str, optional
Deprecated. Use "profile" instead. The ID of the profile to use for the engine. Profile will be adjusted to fit the workspace contraints. If specified, any unspecified parameters (cpu, gpu, memory_bytes, storage_bytes) will be set to the profile's values.
workspace_id : str, optional
The workspace ID where the engine is to be created. Defaults to DriverlessClients default value (default if not set).
display_name : str
Human-readable name of the DAIEngine. Must contain at most 63 characters. Does not have to be unique.
config : Dict[str, str], optional
Additional Driverless AI configuration. Defaults to .
annotations : Dict[str, str], optional

Additional arbitrary metadata associated with the DAIEngine. Defaults to . Annotations are key/value pairs. The key must:

  • be 63 characters or less
  • begin and end with an alphanumeric character ([a-z0-9A-Z])
  • with dashes (-), underscores (_), dots (.), and alphanumerics between
  • regex used for validation is:
    ^[A-Za-z0-9]([-A-Za-z0-9_.]61[A-Za-z0-9])?$
validate_only : bool, optional
If set to True, server will validate the request, but no engine will be created. Defaults to False.

profile(str, optional): resource name of the DAIEngineProfile that is used by this DAIEngine. Format: "workspace//daiEngineProfiles/".

Returns
DAIEngine
Driverless AI engine.

generate_engine_id

def generate_engine_id(self, display_name: str, workspace_id: str) ‑> str

get_engine

def get_engine(self, engine_id: str, workspace_id: str = '') ‑> h2o_engine_manager.clients.dai_engine.dai_engine.DAIEngine

Returns a specific engine.

Args
engine_id : str
The ID of an engine.
workspace_id : str, optional
ID of the workspace. Defaults to DAIEngineClient's default value (default if not set).
Returns
DAIEngine
Driverless AI engine.

list_adjusted_profiles

def list_adjusted_profiles(self, workspace_id: str = '', page_size: int = 0, page_token: str = '') ‑> h2o_engine_manager.clients.adjusted_dai_profile.adjusted_profile_page.AdjustedDAIProfilesPage

List Adjusted Driverless AI profiles based on specified listing parameters.

Args
workspace_id : str, optional
ID of the workspace. Defaults to DriverlessClients default value (default if not set).
page_size : int, optional
Maximum number of AdjustedDAIProfiles to return in a response. If unspecified (or set to 0), at most 50 AdjustedDAIProfiles will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
page_token : str, optional
Leave unset to receive the initial page. To list any subsequent pages use the value of 'next_page_token' returned from the AdjustedDAIProfilesPage.
Returns
AdjustedDAIProfilesPage
A list of Adjusted Driverless AI profiles together with a next_page_token for the next page.

list_all_adjusted_profiles

def list_all_adjusted_profiles(self, workspace_id: str) ‑> List[h2o_engine_manager.clients.adjusted_dai_profile.adjusted_profile.AdjustedDAIProfile]

Returns a list of all adjusted profiles.

Args
workspace_id : str, optional
ID of the workspace. Defaults to DriverlessClients default value (default if not set).
Returns
List[AdjustedDAIProfile]
A list of Adjusted Driverless AI profiles.

list_all_engines

def list_all_engines(self, workspace_id: str = '', order_by: str = '', filter: str = '') ‑> List[h2o_engine_manager.clients.dai_engine.dai_engine.DAIEngine]

Returns a list of all engines within a parent workspace.

Args
workspace_id : str, optional
ID of the workspace. Defaults to DriverlessClients default value (default if not set).
order_by : str, optional
Identical to the list_engines function order_by parameter.
filter : str, optional
Identical to the list_engines function filter parameter.
Returns
List[DAIEngine]
A list of Driverless AI engines.

list_all_versions

def list_all_versions(self, order_by: str = '', filter: str = '') ‑> List[h2o_engine_manager.clients.dai_version.dai_version.DAIVersion]

List all Driverless AI versions.

Args
order_by : str, optional
Identical to the list_versions function order_by parameter.
filter : str, optional
Identical to the list_version function filter parameter.
Returns
List[DAIVersion]
A list of Driverless AI versions.

list_engines

def list_engines(self, workspace_id: str = '', page_size: int = 0, page_token: str = '', order_by: str = '', filter: str = '') ‑> h2o_engine_manager.clients.dai_engine.dai_engine_page.DAIEnginesPage

Returns a list of engines within a parent workspace.

Args
workspace_id : str, optional
ID of the workspace. Defaults to DAIEngineClient's default value (default if not set).
page_size : int, optional
Maximum number of DAIEngines to return in a response. If unspecified (or set to 0), at most 50 DAIEngines will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
page_token : str, optional
Leave unset to receive the initial page. To list any subsequent pages use the value of 'next_page_token' returned from the DAIEnginesPage.
order_by : str, optional

Used to specify the sorting order. When unset, DAIEngines are ordered by their time of creation in descending order. This is equivalent to "create_time desc". When specified, the value must be a comma separated list of supported fields. The supported fields are:

  • name
  • cpu
  • gpu
  • memory_bytes
  • storage_bytes
  • creator
  • create_time
  • update_time
  • delete_time
  • resume_time
  • display_name
  • max_idle_duration
  • max_running_duration
  • uid

The default sorting order is ascending. For example: "name" and "name asc" are equivalent values. To specify descending order for a field, append a " desc" suffix. For example: "name desc". Redundant space characters are insignificant. For example these values are all equal:

  • " name, cpu desc"
  • "name, cpu desc"
  • "name , cpu desc "

Undefined (empty) time is interpreted as a zero time (0s since epoch, i.e. 1970-01-01T00:00:00Z). Undefined (empty) duration is interpreted as a zero duration (0 seconds).

filter : str, optional

Used to filter DAIEngines. When unset, no filtering is applied. When specified, the filter string must follow this formatting rules:

  • filter expression: [term] AND [term] AND [term] …
  • term: [filter_field] [operator] [value]
  • filter_field: (name|version|state|cpu|gpu|memory_bytes|storage_bytes|creator|create_time|update_time|delete_time|resume_time|reconciling|uid|display_name|max_idle_duration|max_running_duration|uid)
  • operator: (=|!=|<=|<|>=|>)
  • value: ([text]|[string])
  • text: free-form set of characters without whitespace (WS) or . (DOT) within it. (e.g. 28, abc, @5_6_7$)
  • string: a quoted string. Text may contain whitespace (WS) or . (DOT) within it. (e.g. "28", "abc", "@5_6_7$", " foo . ")

Filter expression is case sensitive. Additional constraints:

  • You MUST use separator <space>AND<space> between terms.
  • String value MUST NOT contain <space>AND<space>.

Each field may support only some operators:

  • string fields (name, version, creator, uid) support: =, !=, <=, <, >=, >
  • number fields (cpu, gpu, memory_bytes, storage_bytes) support: =, !=, <=, <, >=, >
  • bool fields (reconciling) support: =, !=
  • enum fields (state) support: =, !=
  • time fields (create_time) support: =, !=, <=, <, >=, >

Each field may expect values in a specified format:

  • string fields expect: text or string. For example foo, "f oo". For example f oo is invalid.
  • number fields expect: numbers (can be wrapped in parentheses). For example: 28, -100, 56.8, "666"
  • integer number fields expect: integers. For example: cpu = 10.5 is invalid.
  • bool fields expect: true or false literals. For example: reconciling = true is valid. reconciling = 1 or reconciling = TRUE is invalid.
  • enum fields expect: enum's string representation. For example state = STATE_RUNNING is valid. state = RUNNING or state = state_running is invalid.
  • time fields expect: RFC-3339 formatted string. UTC offsets are supported. For example 2012-04-21T11:30:00-04:00 is valid. 2012-04-21 is invalid.

Valid filter expression examples:

  • state = STATE_RUNNING AND cpu <= 5 AND gpu != 0 AND create_time > 2012-04-21T11:30:00-04:00
  • state=STATE_RUNNING AND cpu<=5 (there may be no whitespace between term parts: [filter_field][operator][value])

Invalid filter expression examples:

  • state = STATE_RUNNING AND cpu <= 5 (invalid separator between terms)
  • state = STATE_RUNNING OR cpu <= 5 (unsupported logical operator)
  • (state = STATE_RUNNING) AND (cpu <= 5) (unsupported parentheses)
Returns
DAIEnginesPage
A list of Driverless AI engines together with a next_page_token for the next page.

list_versions

def list_versions(self, page_size: int = 0, page_token: str = '', order_by: str = '', filter: str = '') ‑> h2o_engine_manager.clients.dai_version.page.DAIVersionsPage

List Driverless AI versions based on specified listing parameters.

Args
page_size
Maximum number of DAIVersions to return in a response. If unspecified (or set to 0), at most 50 DAIVersions will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
page_token
Leave unset to receive the initial page. To list any subsequent pages use the value of 'next_page_token' returned from the DAIVersionsPage.
order_by
Expression used to specify the sorting order. For example: "version asc". When unset, DAIVersions are ordered by their version name in descending order. This is equivalent to "version desc". The only supported field is 'version'.
filter
Expression used to filter DAIEngines. For example: "version < latest AND version >= 1.10.1". The only supported field is 'version'.
Returns

Page of DAIVersions.

set_default_workspace_id

def set_default_workspace_id(self, default_workspace_id: str)

Sets default workspace for subsequest requests made by the client. Value can be overwritten by optional arguments of individual functions.

Args
default_workspace_id : str
The workspace resource id to be used in subsequent requests.

Feedback