environment
safe_env_to_type(variable_name, default_value=None, type_constructor=None)
¶
Converts env variable to specified type, but only if variable is set - otherwise default is returned.
If type_constructor
is not given - value of type str will be returned.
Source code in inference/core/utils/environment.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
safe_split_value(value, delimiter=',')
¶
Splits a separated environment variable into a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
The environment variable value to be split. |
required |
delimiter(str)
|
Delimiter to be used |
required |
Returns:
Type | Description |
---|---|
Optional[List[str]]
|
list or None: The split values as a list, or None if the input is None. |
Source code in inference/core/utils/environment.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
str2bool(value)
¶
Converts an environment variable to a boolean value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str or bool
|
The environment variable value to be converted. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
The converted boolean value. |
Raises:
Type | Description |
---|---|
InvalidEnvironmentVariableError
|
If the value is not 'true', 'false', or a boolean. |
Source code in inference/core/utils/environment.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|