fenn.core

class fenn.core.Fenn[source]

Bases: object

Base class for a PyFenn application.

Wires together argument parsing, logging, secret storage, and result export into a single entry point. Subclass this or instantiate it directly, register your main logic with entrypoint(), then call run().

Example

>>> app = Fenn()
>>> @app.entrypoint
... def main(args):
...     print(args)
>>> app.run()
__init__()[source]
Return type:

None

property config_file: str

Path to the active YAML configuration file.

disable_disclaimer()[source]

Suppress the startup banner printed before each run.

Return type:

None

entrypoint(entrypoint_fn)[source]

Register the application’s main function.

Use as a decorator. The decorated function receives the parsed configuration dict as its only argument and may return any value, which run() will forward to the caller.

Parameters:

entrypoint_fn (Callable) – The callable to register as the application entry point. Must accept a single args dict argument.

Returns:

The original callable, unchanged (decorator passthrough).

Return type:

Callable

property export_dir: Path

Output directory for run artefacts (logs, models, exports).

get_environ(key)[source]
Parameters:

key (str)

Return type:

str

property parameters: map
run()[source]

Execute the application.

Loads configuration from the YAML file, initialises logging and export directories, then calls the registered entrypoint function. Logging is always stopped cleanly, even if the entrypoint raises.

Returns:

The value returned by the entrypoint function.

Raises:

RuntimeError – If no entrypoint has been registered via entrypoint().

Return type:

Any

set_config_file(config_file)[source]

Override the default YAML configuration file path.

Parameters:

config_file (str) – Path to the YAML file to load on run(). Defaults to "fenn.yaml" in the working directory.

Return type:

None