mafw.ui.console_user_interface
The console user interface.
The module provides a simple, still efficient user interface ideal for code execution of a headless system where it is not possible to observe the output in real-time. Nevertheless, important messages are logged via the logging library and thus it is also possible to save them to a file, if a proper logging handler is set up.
Classes
A console user interface. |
- class mafw.ui.console_user_interface.ConsoleInterface[source]
Bases:
UserInterfaceBaseA console user interface.
Ideal for execution in a headless environment.
Messages are sent via the logging system, so they can also be saved to a file is a logging handler is properly set up in the execution framework.
- change_of_processor_status(processor_name: str, old_status: ProcessorStatus, new_status: ProcessorStatus) None[source]
Log a processor status change.
This method logs when a processor changes its status, using debug level logging.
- Parameters:
processor_name (str) – The name of the processor whose status changed.
old_status (ProcessorStatus) – The previous status of the processor.
new_status (ProcessorStatus) – The new status of the processor.
- create_task(task_name: str, task_description: str = '', completed: int = 0, increment: int | None = None, total: int | None = None, **kwargs: Any) None[source]
Create a new task.
- Parameters:
task_name (str) – A unique identifier for the task. You cannot have more than 1 task with the same name in the whole execution. If you want to use the processor name, it is recommended to use the
unique_name.task_description (str, Optional) – A short description for the task. Defaults to None.
completed (int, Optional) – The amount of task already completed. Defaults to None.
increment (int, Optional) – How much of the task has been done since last update. Defaults to None.
total (int, Optional) – The total amount of task. Defaults to None.
- display_progress_message(message: str, i_item: int, n_item: int | None, frequency: float) None[source]
Display a progress message with item counter.
This method displays progress information at specified intervals based on the frequency parameter. It formats the message with a counter showing the current item and total items.
- Parameters:
message (str) – The progress message to display.
i_item (int) – The current item number (0-based index).
n_item (int | None) – The total number of items, or None if unknown.
frequency (float) – The frequency at which messages should be displayed (in seconds).
- prompt_question(question: str, **kwargs: Any) Any[source]
Prompt the user with a question and return their input.
This method displays a question to the user and waits for their input. Additional keyword arguments can be passed through to the underlying input function.
Added in version v2.0.0.
- Parameters:
question (str) – The question to display to the user.
kwargs – Additional keyword arguments to pass to the input function.
- Returns:
The user’s input.
- Return type:
Any
- update_task(task_name: str, completed: int | None = None, increment: int | None = None, total: int | None = None, **kwargs: Any) None[source]
Update an existing task.
- Parameters:
task_name (str) – A unique identifier for the task. You cannot have more than one task with the same name in the whole execution. If you want to use the processor name, it is recommended to use the
replica_name.completed (int, Optional) – The amount of task already completed. Defaults to None.
increment (int, Optional) – How much of the task has been done since last update. Defaults to None.
total (int, Optional) – The total amount of task. Defaults to None.
- name = 'console'
The name of the interface