flytekit.configuration.file
| Property |
Type |
Description |
FLYTECTL_CONFIG_ENV_VAR |
str |
|
FLYTECTL_CONFIG_ENV_VAR_OVERRIDE |
str |
|
def bool_transformer(
config_val: typing.Any,
) -> bool
| Parameter |
Type |
Description |
config_val |
typing.Any |
|
def comma_list_transformer(
config_val: typing.Any,
)
| Parameter |
Type |
Description |
config_val |
typing.Any |
|
def int_transformer(
config_val: typing.Any,
)
| Parameter |
Type |
Description |
config_val |
typing.Any |
|
def read_file_if_exists(
filename: typing.Optional[str],
encoding,
) -> typing.Optional[str]
Reads the contents of the file if passed a path. Otherwise, returns None.
| Parameter |
Type |
Description |
filename |
typing.Optional[str] |
The file path to load |
encoding |
|
The encoding to use when reading the file. |
Returns: The contents of the file as a string or None.
def set_if_exists(
d: dict,
k: str,
v: typing.Any,
) -> dict
Given a dict d sets the key k with value of config v, if the config value v is set
and return the updated dictionary.
The input dictionary d will be mutated.
| Parameter |
Type |
Description |
d |
dict |
|
k |
str |
|
v |
typing.Any |
|
A top level Config entry holder, that holds multiple different representations of the config.
Legacy means the INI style config files. YAML support is for the flytectl config file, which is there by default
when flytectl starts a sandbox
class ConfigEntry(
legacy: LegacyConfigEntry,
yaml_entry: typing.Optional[YamlConfigEntry],
transform: typing.Optional[typing.Callable[[str], typing.Any]],
)
| Parameter |
Type |
Description |
legacy |
LegacyConfigEntry |
|
yaml_entry |
typing.Optional[YamlConfigEntry] |
|
transform |
typing.Optional[typing.Callable[[str], typing.Any]] |
|
| Method |
Description |
read() |
Reads the config Entry from the various sources in the following order,. |
def read(
cfg: typing.Optional[ConfigFile],
) -> typing.Optional[typing.Any]
Reads the config Entry from the various sources in the following order,
#. First try to read from the relevant environment variable,
#. If missing, then try to read from the legacy config file, if one was parsed.
#. If missing, then try to read from the yaml file.
The constructor for ConfigFile currently does not allow specification of both the ini and yaml style formats.
| Parameter |
Type |
Description |
cfg |
typing.Optional[ConfigFile] |
|
class ConfigFile(
location: str,
)
Load the config from this location
| Parameter |
Type |
Description |
location |
str |
|
| Property |
Type |
Description |
legacy_config |
configparser.ConfigParser |
|
yaml_config |
typing.Dict[str, typing.Any] |
|
def get(
c: typing.Union[LegacyConfigEntry, YamlConfigEntry],
) -> typing.Any
| Parameter |
Type |
Description |
c |
typing.Union[LegacyConfigEntry, YamlConfigEntry] |
|
Creates a record for the config entry. contains
class LegacyConfigEntry(
section: str,
option: str,
type_: typing.Type,
)
| Parameter |
Type |
Description |
section |
str |
section the option should be found under |
option |
str |
the option str to lookup |
type_ |
typing.Type |
Expected type of the value |
def read_from_env(
transform: typing.Optional[typing.Callable],
) -> typing.Optional[typing.Any]
Reads the config entry from environment variable, the structure of the env var is current
FLYTE_{SECTION}_{OPTION} all upper cased. We will change this in the future.
| Parameter |
Type |
Description |
transform |
typing.Optional[typing.Callable] |
|
def read_from_file(
cfg: ConfigFile,
transform: typing.Optional[typing.Callable],
) -> typing.Optional[typing.Any]
| Parameter |
Type |
Description |
cfg |
ConfigFile |
|
transform |
typing.Optional[typing.Callable] |
|
Creates a record for the config entry.
class YamlConfigEntry(
switch: str,
config_value_type: typing.Type,
)
| Parameter |
Type |
Description |
switch |
str |
dot-delimited string that should match flytectl args. Leaving it as dot-delimited instead of a list of strings because it’s easier to maintain alignment with flytectl. |
config_value_type |
typing.Type |
Expected type of the value |
def read_from_file(
cfg: ConfigFile,
transform: typing.Optional[typing.Callable],
) -> typing.Optional[typing.Any]
| Parameter |
Type |
Description |
cfg |
ConfigFile |
|
transform |
typing.Optional[typing.Callable] |
|