class apyfal.host.Host(host_type=None, config=None, host_ip=None, stop_mode=None, host_name_prefix=None, **_)[source]

This is base class for all host classes.

This is also a factory which instantiate host subclass related to specified cases.

  • host_type (str) – Host type.
  • config (apyfal.configuration.Configuration, path-like object or file-like object) – If not set, will search it in current working directory, in current user “home” folder. If none found, will use default configuration values. Path-like object can be path, URL or cloud object URL.
  • host_name_prefix (str) – Prefix to add to host name.
  • host_ip (str) – IP or URL address of an already existing host to use. If not specified, create a new host.
  • stop_mode (str or int) – Define the “stop” method behavior. Default to ‘term’ if new host, or ‘keep’ if already existing host. See “stop_mode” property for more information and possible values.
DOC_URL = ''

Link to host documentation or website

STOP_MODES = {0: 'term', 1: 'stop', 2: 'keep'}

Possible stop_mode int values

TIMEOUT = 420.0

Timeout for host status change in seconds


Return environment to pass to “apyfal.accelerator.AcceleratorClient.start” “csp_env” argument.

Parameters:config_env – Overwrites environment values.
Returns:Configuration environment.
Return type:dict

Name of the current host.

Return type:str

Host type

Returns:Host type
Return type:str

Returns some host information.

Dictionary containing information on
current host.
Return type:dict

Iterates over accelerator hosts of current type.

Parameters:host_name_prefix (bool or str) – If True, use “host_name_prefix” from configuration, if False don’t filter by prefix, if str, uses this str as prefix
Returns:dicts contains attributes values of the host.
Return type:generator of dict
start(accelerator=None, accel_parameters=None, stop_mode=None)[source]

Start host if not already started.

Needs “accel_client” or “accel_parameters”.

  • accelerator (str) – Name of the accelerator.
  • accel_parameters (dict) – Can override parameters from accelerator client.
  • stop_mode (str or int) – See “stop_mode” property for more information.

Stop host accordingly with the current stop_mode. See “stop_mode” property for more information.

Parameters:stop_mode (str or int) – If not None, override current “stop_mode” value.

Define the “stop” method behavior.

Possible values ares:
0: TERM, terminate and delete host. 1: STOP, stop and pause host. 2: KEEP, let host running.
“stop” can be called manually but is also called when:
  • “with” exit if class is used as context manager.
  • On object deletion by garbage collector.
  • On OS signals if “exit_host_on_signal” was set to True on class instantiation.
Returns:stop mode.
Return type:str

URL of the current host.

Return type:str