Skip to content

epymorph.log.messaging

Displaying epymorph simulation progress in console (or similar outputs).

EPYMORPH_LIVE_MESSAGING module-attribute

EPYMORPH_LIVE_MESSAGING = declare_setting(
    name="EPYMORPH_LIVE_MESSAGING",
    description="An optional boolean value; true to force 'live' output rendering style, false to disable it. By default, epymorph attempts to auto-detect the appropriate setting.",
    getter=lambda: env_flag("EPYMORPH_LIVE_MESSAGING"),
)

An environment variable for the 'live' messaging setting.

is_live_messaging

is_live_messaging(
    override_setting: bool | None = None,
) -> bool

Computes the setting to use for message rendering style: "live" (dynamic) or "not live" (static).

Certain output elements like progress bars render nicely in an interactive console or a Jupyter Notebook, but render poorly in static documents like Quarto or logging output to a file. Hence this setting, which is used to adjust the way these elements are rendered.

It would be unfortunate to require the user to change their code just to fix rendering for whichever environment that code is going to be run in. Indeed, the user may wish to run their code in many different environments! So this function provides logic to auto-detect an appropriate setting based on environment variables. However the default logic can be overridden explicitly by the user.

Parameters:

  • override_setting (bool | None, default: None ) –

    None to auto-detect the rendering style to use based on the execution environment; True to enable "live" style or False to disable it, regardless of the environment.

Returns:

  • bool

    True to render messages as in a "live" (interactive) environment; False to render messages as in a static environment.

sim_messaging

sim_messaging(
    *, adrio: bool = True, live: bool | None = None
) -> Generator[None, None, None]

Run simulations in this context manager to output (print) progress messages during simulation activity.

Parameters:

  • adrio (bool, default: True ) –

    True to include ADRIO progress updates.

  • live (bool | None, default: None ) –

    An optional override for the rendering style to use in the output. Leave this as None to use the default "liveness" logic. Specify True or False to override the default. See the is_live_messaging() function for more information.

Examples:

1
2
3
with sim_messaging():
    sim = BasicSimulator(rume)
    my_results = sim.run()