dacbench.container.container_utils
Module Contents
Classes
Json Encoder to save tuple and or numpy arrays | numpy floats / integer. |
|
Adapted from: https://github.com/automl/HPOBench/blob/master/hpobench/util/container_utils.py |
Functions
|
|
|
|
|
Wait for a UNIX socket to be created. |
|
Taken from https://gist.github.com/butla/2d9a4c0f35ea47b7452156c96a4e7b12 |
- class dacbench.container.container_utils.Encoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
Bases:
json.JSONEncoderJson Encoder to save tuple and or numpy arrays | numpy floats / integer. Adapted from: https://github.com/automl/HPOBench/blob/master/hpobench/util/container_utils.py Serializing tuple/numpy array may not work. We need to annotate those types, to reconstruct them correctly.
- static hint(item)
- encode(self, obj)
Return a JSON string representation of a Python data structure.
>>> from json.encoder import JSONEncoder >>> JSONEncoder().encode({"foo": ["bar", "baz"]}) '{"foo": ["bar", "baz"]}'
- static encode_space(space_obj: gym.Space)
- class dacbench.container.container_utils.Decoder(*args, **kwargs)
Bases:
json.JSONDecoderAdapted from: https://github.com/automl/HPOBench/blob/master/hpobench/util/container_utils.py
- object_hook(self, obj: Any) Union[Union[tuple, numpy.ndarray, float, float, int], Any]
- decode_space(self, space_dict: Dict) gym.Space
- dacbench.container.container_utils.deserialize_random_state(random_state_dict: Dict) numpy.random.RandomState
- dacbench.container.container_utils.serialize_random_state(random_state: numpy.random.RandomState) Tuple[int, List, int, int, int]
- dacbench.container.container_utils.wait_for_unixsocket(path: str, timeout: float = 10.0) None
Wait for a UNIX socket to be created.
- Parameters
path – path to the socket
timeout – timeout in seconds
- Returns
- dacbench.container.container_utils.wait_for_port(port, host='localhost', timeout=5.0)
Taken from https://gist.github.com/butla/2d9a4c0f35ea47b7452156c96a4e7b12 Wait until a port starts accepting TCP connections.
- Parameters
port (int) – Port number to check.
host (str) – Host to check.
timeout (float) – Timeout in seconds.
Raises –
------ –
TimeoutError (The port isn’t accepting connection after time specified in timeout.) –