# tensorplay.distributed.elastic.utils API Source: https://www.tensorplay.cn/docs/api/tensorplay.distributed.elastic.utils.html ## Functions 2 [#](#api-tensorplay.distributed.elastic.utils.get_env_variable_or_raise) ### get_env_variable_or_raise function[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.utils.get_env_variable_or_raise.html) ```python tensorplay.distributed.elastic.utils.get_env_variable_or_raise(env_name: str) → str ``` Return the value of env_name or raise if it is unset/empty. [#](#api-tensorplay.distributed.elastic.utils.get_socket_with_port) ### get_socket_with_port function[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.utils.get_socket_with_port.html) ```python tensorplay.distributed.elastic.utils.get_socket_with_port() → socket ``` Create a socket bound to an ephemeral local port and return it. The caller owns the socket; close it once the port has been consumed. ## Classes 1 [#](#api-tensorplay.distributed.elastic.utils.macros) ### macros class[Full reference ↗](/docs/generated/tensorplay.distributed.elastic.utils.macros.html) ```python class tensorplay.distributed.elastic.utils.macros ``` Substitution variables usable in worker argument templates. Any ${field} token inside the worker argument list is replaced with the concrete value for the worker being launched. Supported fields are the entries of fields. ```python classmethod substitute(args: list[str], local_rank: str | None = None) → list[str] ``` Replace ${field} tokens in args; unknown tokens are kept. ```python classmethod to_map() → dict[str, str] ``` Current macro values from the running process’ environment.