NEDAS.utils.progress module
- NEDAS.utils.progress.watch_log(logfile: str, keyword: str, timeout: int = 1000, check_dt: int = 1) None[source]
- class NEDAS.utils.progress.Formatter(interactive: bool = True, is_notebook: bool = False, cols=80, anchor=50, tabspace=4, progress_bar_width=10)[source]
Bases:
objectFormatter of the progress display.
- Parameters:
interactive (bool, optional) – Whether the output is interactive (supports ansi escape code). Defaults to True.
anchor (int, optional) – Characters to anchor the left part of status line. Defaults to 50.
tabspace (int, optional) – Number of spaces for one call stack level indentation. Defaults to 4.
progress_bar_width (int, optional) – Width of the progress bar in characters. Defaults to 10.
- indent(level: int, branch: bool = True) str[source]
Generate the indent string to form call stack tree structure in log.
- Parameters:
level (int) – The current call stack level.
branch (bool) – Whether a branch is needed at the end.
- Returns:
The indent string
- Return type:
str
- padding(level: int, name: str) str[source]
Generate the padding string to align the status line.
- Parameters:
level (int) – The current call stack level.
name (str) – The name of the current function or task.
- Returns:
The padding string
- Return type:
str
- progress_bar(task_id: int, ntask: int) str[source]
Generate a progress bar based on task_id and ntask.
- Parameters:
task_id (int) – Current task index, from 0 to ntask-1
ntask (int) – Total number of tasks
- Returns:
The progress bar msg to be shown.
- Return type:
str
Note: Will require the print command with end=”” option so that new line updated is overwritting the old line.
- class NEDAS.utils.progress.Progress(interactive: bool = True, is_notebook: bool = False, cols: int = 80, debug: bool = False, call_stack: list[dict] | None = None, call_stack_max_level: int | None = None, anchor: int = 50, tabspace: int = 4, progress_bar_width: int = 10, io_interval: float = 0.1)[source]
Bases:
objectProgress tracker and displayer. Used by Context.logger to show runtime progress.
- interactive: bool
- debug: bool
- call_stack: list[dict[str, Any]]
- call_stack_max_level: int | None
- property node: dict
- property level: int