BCDA-APS / mdaviz

Data visualization for mda
https://bcda-aps.github.io/mdaviz/
Other
3 stars 0 forks source link

add command-line options #125

Closed prjemian closed 3 weeks ago

prjemian commented 1 month ago

... such as usage, help, version number, and logging level. https://github.com/BCDA-APS/mdaviz/blob/09937f4d1d31e20a44bcf57a8476c3cae909f337/mdaviz/app.py#L23-L24

prjemian commented 1 month ago

See gemviz for ideas.

rodolakis commented 1 month ago

Moving this to v1.0 since it might be the temporary solution for loading data from the dserv.

Related to #124

rodolakis commented 1 month ago

Need argument -d directory_path, default to pwd

prjemian commented 1 month ago

With commit 3a557f8:

    global logger

    options = command_line_interface()

    logging.basicConfig(level=options.log.upper())
    logger = logging.getLogger(__name__)
    logger.info("Logging level: %s", options.log)

    # set warning log level for (noisy) support packages
    for package in "httpcore httpx PyQt5 tiled".split():
        logging.getLogger(package).setLevel(logging.WARNING)
prjemian commented 1 month ago

Example for directory exists:

    parser.add_argument(
        "directory",
        default=".",
        help=(
            "Directory for the new instrument."
            "  If omitted, use the present working directory"
            f" ({pathlib.Path('.').absolute()})."
            "  The directory will be created if it does not exist."
            "  If the directory exists and it is not empty, this"
            " program will stop before any action is taken."
        ),
        nargs="?",
        type=str,
    )
prjemian commented 1 month ago

with directory option

(bluesky_2024_2) zorinvm@zorin22:~/.../BCDA-APS/mdaviz$ mdaviz -h
usage: mdaviz [-h] [--log {critical,fatal,error,warn,warning,info,debug,notset}] [-v] [directory]

mdaviz: Python Qt5 application to visualize Bluesky data from tiled server.

positional arguments:
  directory             Directory for the new instrument. If omitted, use the present working directory
                        (/home/zorinvm/Documents/projects/BCDA-APS/mdaviz). The directory will be created if it does not
                        exist. If the directory exists and it is not empty, this program will stop before any action is taken.

options:
  -h, --help            show this help message and exit
  --log {critical,fatal,error,warn,warning,info,debug,notset}
                        Provide logging level. Example '--log debug'. Default level: 'warning'
  -v, --version         show program's version number and exit
(bluesky_2024_2) zorinvm@zorin22:~/.../BCDA-APS/mdaviz$