granular_configuration_language
.yaml.decorators.eager_io
- granular_configuration_language.yaml.decorators.eager_io.as_eager_io(
- eager_io_preprocessor: Callable[[T, Tag, LoadOptions], IT],
- /,
Added in version 2.3.0.
This an EagerIO decorator
EagerIO Tags are not fully lazy.
The Tag logic still runs just-in-time, but the IO operations run eagerly:
Load Time: The preprocessor function runs as separate thread. This thread is spawn on load.
Fetch Time: The result of the preprocessor is then passed to tag “Tag” function instead of the YAML value.
Wraps the “Tag” function as EagerIO tag.
Positional Parameters for “Tag” function
(
IT
) - Processor Result
- Parameters:
eager_io_preprocessor (Callable[[T, Tag, LoadOptions]) – EagerIO preprocessor
- Returns:
Decorator Factory to wrap your “Tag” function
- Return type:
Callable[[Callable[[IT], RT]], Callable[[Tag, T, StateHolder], LazyEval[RT]]]
- Example:
@string_tag(Tag("!Tag")) @as_eager_io(eager_io_text_loader_interpolates) def tag(value: EagerIOTextFile) -> Any: ...
- granular_configuration_language.yaml.decorators.eager_io.as_eager_io_with_root_and_load_options(
- eager_io_preprocessor: Callable[[T, Tag, LoadOptions], IT],
- /,
Added in version 2.3.0.
This an EagerIO decorator
EagerIO Tags are not fully lazy.
The Tag logic still runs just-in-time, but the IO operations run eagerly:
Load Time: The preprocessor function runs as separate thread. This thread is spawn on load.
Fetch Time: The result of the preprocessor is then passed to tag “Tag” function instead of the YAML value.
Wraps the “Tag” function as EagerIO tag.
Positional Parameters for “Tag” function
(
IT
) - Processor Result(
Root
) – Configuration root(
LoadOptions
) – ALoadOptions
instance
- Parameters:
eager_io_preprocessor (Callable[[T, Tag, LoadOptions], IT]) – EagerIO preprocessor
- Returns:
Decorator Factory to wrap your “Tag” function
- Return type:
Callable[[Callable[[IT, Root, LoadOptions], RT]], Callable[[Tag, T, StateHolder], LazyEval[RT]]]
- Example:
@string_tag(Tag("!Tag")) @as_eager_io(eager_io_text_loader_interpolates) def tag(value: EagerIOTextFile, root: Root, options: LoadOptions) -> Any: ...
- granular_configuration_language.yaml.decorators.eager_io.eager_io_binary_loader(
- value: str,
- tag: Tag,
- options: LoadOptions,
Added in version 2.3.0.
Used by EagerIO Decorators to eagerly load a binary file.
Reads the YAML string value as the relative file path.
Loads file as an
EagerIOBinaryFile
.
Available EagerIO Decorators
- Parameters:
value (str) – YAML string, read as a relative file path
tag (Tag) – Tag doing this, used for error reporting.
options (LoadOptions) – options from the Tag doing this action, used for tracking chains.
- Returns:
Loaded File
- Return type:
- granular_configuration_language.yaml.decorators.eager_io.eager_io_binary_loader_interpolates(
- value: str,
- tag: Tag,
- options: LoadOptions,
Added in version 2.3.0.
Used by EagerIO Decorators to eagerly load a binary file.
Same as
eager_io_binary_loader()
, except value interpolated first.Interpolates the YAML string
Reads the value as the relative file path.
Loads file as an
EagerIOBinaryFile
.
Available EagerIO Decorators
- Parameters:
value (str) – YAML string, read as a relative file path, after interpolation
tag (Tag) – Tag doing this, used for error reporting.
options (LoadOptions) – options from the Tag doing this action, used for tracking chains.
- Returns:
Loaded File
- Return type:
- granular_configuration_language.yaml.decorators.eager_io.eager_io_text_loader(
- value: str,
- tag: Tag,
- options: LoadOptions,
Added in version 2.3.0.
Used by EagerIO Decorators to eagerly load a text file.
Reads the YAML string value as the relative file path.
Loads file as an
EagerIOTextFile
.
Available EagerIO Decorators
- Parameters:
value (str) – YAML string, read as a relative file path
tag (Tag) – Tag doing this, used for error reporting.
options (LoadOptions) – options from the Tag doing this action, used for tracking chains.
- Returns:
Loaded File
- Return type:
- granular_configuration_language.yaml.decorators.eager_io.eager_io_text_loader_interpolates(
- value: str,
- tag: Tag,
- options: LoadOptions,
Added in version 2.3.0.
Used by EagerIO Decorators to eagerly load a text file.
Same as
eager_io_text_loader()
, except value interpolated first.Interpolates the YAML string
Reads the value as the relative file path.
Loads file as an
EagerIOTextFile
.
Available EagerIO Decorators
- Parameters:
value (str) – YAML string, read as a relative file path, after interpolation
tag (Tag) – Tag doing this, used for error reporting.
options (LoadOptions) – options from the Tag doing this action, used for tracking chains.
- Returns:
Loaded File
- Return type:
- class granular_configuration_language.yaml.file_ops.EagerIOBinaryFile( )[source]
Bases:
object
Type: frozen
dataclass
Added in version 2.3.0.
Encapsulates a file that has been read as binary.
- path: Path
File path