Skip to content

Utils

exit_app()

Gracefully exits the app.

Source code in evaluator/backend/miscellaneous.py
6
7
8
def exit_app() -> NoReturn:
    """Gracefully exits the app."""
    misc_functions.graceful_exit(0)

log_state(state, state_type)

Logs the app state.

Parameters:

Name Type Description Default
state AppState or RunState

The state to log.

required
state_type app or run

The type of state being logged.

required
Source code in evaluator/backend/miscellaneous.py
def log_state(state: AppState | RunState, state_type: Literal["app", "run"]) -> None:
    """Logs the app state.

    Parameters
    ----------
    state : AppState or RunState
        The state to log.
    state_type : "app" or "run"
        The type of state being logged.
    """
    app_state_flag = True if state_type.lower().strip() == "app" else False
    log_str = "App state:\n" if app_state_flag else "Run state:\n"

    if app_state_flag:
        app_state = cast(AppState, state)
        app_key: AppStateKey
        for app_key in get_args(AppStateKey):
            if app_key == "logger":
                continue
            log_str += f"\t{app_key}: {app_state[app_key]}\n"
    else:
        run_state = cast(RunState, state)
        run_key: RunStateKey
        for run_key in get_args(RunStateKey):
            if run_key in {
                "generated_domain",
                "human_curated_domain",
                "reference_nodes",
                "param_set",
                "logger",
                "eval_data"
            }:
                continue
            log_str += f"\t{run_key}: {run_state[run_key]}\n"

    state["logger"].info(log_str)