# ══════════════════════════════════════════════════════════════════════════
# ___ ___ ___ _ _ ___
# / _ \ / __|_ ) | | /_\ | _ )
# | (_) | (__ / / | |__ / _ \| _ \
# \__\_\\___/___| |____/_/ \_\___/
#
# QC2 @ CHALMERS CALIBRATION TOOLKIT
# (c) 2026 Chalmers University of Technology and Project Contributors
# ──────────────────────────────────────────────────────────────────────────
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ──────────────────────────────────────────────────────────────────────────
# CONTRIBUTORS list:
#
# Matteo Robbiati, robbiati@chalmers.se
# Axel Andersson, axean@chalmers.se
# Yanchen Lin, linya@chalmers.se
# ══════════════════════════════════════════════════════════════════════════
"""Command-line entry point for the qc2-show archive browser.
Usage:
qc2-show <archive_dir> [--host 127.0.0.1] [--port 9999] [--traffic-saver-mode]
``<archive_dir>`` is a directory of timestamped ``YYYYMMDD_HHMMSS[_sanitized_name]`` run
folders (e.g. ``calibration_outputs/``). All viewing goes through the archive
browser.
"""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
from bragi_quantum.gui.archive import Archive
[docs]
def main_show(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(
prog="qc2-show",
description="Browse a directory of QC2 calibration run folders.",
)
parser.add_argument(
"path",
type=Path,
help="Path to a directory of timestamped (YYYYMMDD_HHMMSS[_sanitized_name]) run folders.",
)
parser.add_argument("--host", default="127.0.0.1")
parser.add_argument("--port", type=int, default=9999)
parser.add_argument("--log-level", default="info")
parser.add_argument(
"--traffic-saver-mode",
action="store_true",
help=(
"For slow connections: send each plot's half-resolution "
"*_preview.png instead of the full-size image (when one exists), "
"and 16-bit-quantised x/y data for re-analysed plotly figures."
),
)
args = parser.parse_args(argv)
target: Path = args.path.resolve()
if not target.is_dir():
print(f"❌ {target} is not a directory", file=sys.stderr)
return 2
return Archive(target, traffic_saver=args.traffic_saver_mode).serve(
args.host, args.port, args.log_level
)