Skip to content

Resolving progressbar appearance selection #1980

@Lestropie

Description

@Lestropie

In both C++ and Python, a decision is made as to whether the terminal output generated by a progress bar should be one of dynamic updates (i.e. repeatedly update one line with a progress percentage, and optionally update the message), or whether it should be a simplified display intended for piping to a file, which constructs a progress bar that appears as "[=====]" (which doesn't require line feeds).

Currently, the selection of which of these appearances a progress bar will take is slightly different between the two languages. In C++, it's based on whether or not stderr is detected as being a regular file. In Python, function sys.stderr.isatty() is used. It's possible that there may be some instances in which the behaviour between these two functions may be different.

It's also possible that other factors may influence how these two mechanisms behave, and therefore what the best decision logic is. For instance, most recently I have been running Singularity containers on an HPC, where the main script is running against the MRtrix3 Python API. There, any MRtrix3 commands invoked via run.command() attempt to display the full updating progress bar, even though with SLURM jobs the stderr contents are written to a file.

So there'd be a bit of testing necessary to set up all of the different scenarios and figure out exactly how that decision should be made.

I did come across this C++ snippet which could be used if the TTY test turns out to be preferable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions