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],
/,
) Callable[[Callable[[IT], RT]], Callable[[Tag, T, StateHolder], LazyEval[RT]]][source]

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

  1. (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],
/,
) Callable[[Callable[[IT, Root, LoadOptions], RT]], Callable[[Tag, T, StateHolder], LazyEval[RT]]][source]

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

  1. (IT) - Processor Result

  2. (Root) – Configuration root

  3. (LoadOptions) – A LoadOptions 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,
) EagerIOBinaryFile[source]

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.

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:

EagerIOBinaryFile

granular_configuration_language.yaml.decorators.eager_io.eager_io_binary_loader_interpolates(
value: str,
tag: Tag,
options: LoadOptions,
) EagerIOBinaryFile[source]

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.

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:

EagerIOBinaryFile

granular_configuration_language.yaml.decorators.eager_io.eager_io_text_loader(
value: str,
tag: Tag,
options: LoadOptions,
) EagerIOTextFile[source]

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.

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:

EagerIOTextFile

granular_configuration_language.yaml.decorators.eager_io.eager_io_text_loader_interpolates(
value: str,
tag: Tag,
options: LoadOptions,
) EagerIOTextFile[source]

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.

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:

EagerIOTextFile

class granular_configuration_language.yaml.file_ops.EagerIOBinaryFile(
path: Path,
exists: bool,
data: bytes,
)[source]

Bases: object

Type: frozen dataclass

Added in version 2.3.0.

Encapsulates a file that has been read as binary.

data: bytes

Contents of the file, if the file exists, else an empty bytes

exists: bool

True, if the file exists, else False

path: Path

File path

class granular_configuration_language.yaml.file_ops.EagerIOTextFile(
path: Path,
exists: bool,
data: str,
)[source]

Bases: object

Type: frozen dataclass

Added in version 2.3.0.

Encapsulates a file that has been read as text.

data: str

Contents of the file, if the file exists, else an empty str

exists: bool

True, if the file exists, else False

path: Path

File path