flytekit.configuration.file
Directory
Classes
| Class | Description |
|---|---|
ConfigEntry |
A top level Config entry holder, that holds multiple different representations of the config. |
ConfigFile |
|
LegacyConfigEntry |
Creates a record for the config entry. contains. |
YamlConfigEntry |
Creates a record for the config entry. |
Methods
| Method | Description |
|---|---|
bool_transformer() |
|
comma_list_transformer() |
|
get_config_file() |
Checks if the given argument is a file or a configFile and returns a loaded configFile else returns None. |
int_transformer() |
|
read_file_if_exists() |
Reads the contents of the file if passed a path. |
set_if_exists() |
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. |
Variables
| Property | Type | Description |
|---|---|---|
FLYTECTL_CONFIG_ENV_VAR |
str |
|
FLYTECTL_CONFIG_ENV_VAR_OVERRIDE |
str |
Methods
bool_transformer()
def bool_transformer(
config_val: typing.Any,
) -> bool| Parameter | Type | Description |
|---|---|---|
config_val |
typing.Any |
comma_list_transformer()
def comma_list_transformer(
config_val: typing.Any,
)| Parameter | Type | Description |
|---|---|---|
config_val |
typing.Any |
get_config_file()
def get_config_file(
c: typing.Union[str, ConfigFile, None],
) -> typing.Optional[ConfigFile]Checks if the given argument is a file or a configFile and returns a loaded configFile else returns None
| Parameter | Type | Description |
|---|---|---|
c |
typing.Union[str, ConfigFile, None] |
int_transformer()
def int_transformer(
config_val: typing.Any,
)| Parameter | Type | Description |
|---|---|---|
config_val |
typing.Any |
read_file_if_exists()
def read_file_if_exists(
filename: typing.Optional[str],
encoding = None,
) -> 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.
set_if_exists()
def set_if_exists(
d: dict,
k: str,
v: typing.Any,
) -> dictGiven 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 |
flytekit.configuration.file.ConfigEntry
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
Parameters
class ConfigEntry(
legacy: LegacyConfigEntry,
yaml_entry: typing.Optional[YamlConfigEntry] = None,
transform: typing.Optional[typing.Callable[[str], typing.Any]] = None,
)| Parameter | Type | Description |
|---|---|---|
legacy |
LegacyConfigEntry |
|
yaml_entry |
typing.Optional[YamlConfigEntry] |
|
transform |
typing.Optional[typing.Callable[[str], typing.Any]] |
Methods
| Method | Description |
|---|---|
read() |
Reads the config Entry from the various sources in the following order, #. |
read()
def read(
cfg: typing.Optional[ConfigFile] = None,
) -> 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] |
flytekit.configuration.file.ConfigFile
Parameters
class ConfigFile(
location: str,
)Load the config from this location
| Parameter | Type | Description |
|---|---|---|
location |
str |
Properties
| Property | Type | Description |
|---|---|---|
legacy_config |
configparser.ConfigParser |
|
yaml_config |
typing.Dict[str, typing.Any] |
Methods
| Method | Description |
|---|---|
get() |
get()
def get(
c: typing.Union[LegacyConfigEntry, YamlConfigEntry],
) -> typing.Any| Parameter | Type | Description |
|---|---|---|
c |
typing.Union[LegacyConfigEntry, YamlConfigEntry] |
flytekit.configuration.file.LegacyConfigEntry
Creates a record for the config entry. contains
Parameters
class LegacyConfigEntry(
section: str,
option: str,
type_: typing.Type = str,
)| 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 |
Methods
| Method | Description |
|---|---|
get_env_name() |
|
read_from_env() |
Reads the config entry from environment variable, the structure of the env var is current FLYTE_{SECTION}_{OPTION} all upper cased. |
read_from_file() |
get_env_name()
def get_env_name()read_from_env()
def read_from_env(
transform: typing.Optional[typing.Callable] = None,
) -> 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] |
read_from_file()
def read_from_file(
cfg: ConfigFile,
transform: typing.Optional[typing.Callable] = None,
) -> typing.Optional[typing.Any]| Parameter | Type | Description |
|---|---|---|
cfg |
ConfigFile |
|
transform |
typing.Optional[typing.Callable] |
flytekit.configuration.file.YamlConfigEntry
Creates a record for the config entry.
Parameters
class YamlConfigEntry(
switch: str,
config_value_type: typing.Type = str,
)| 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 |
Methods
| Method | Description |
|---|---|
read_from_file() |
read_from_file()
def read_from_file(
cfg: ConfigFile,
transform: typing.Optional[typing.Callable] = None,
) -> typing.Optional[typing.Any]| Parameter | Type | Description |
|---|---|---|
cfg |
ConfigFile |
|
transform |
typing.Optional[typing.Callable] |