diff --git a/disscube/cli.py b/disscube/cli.py index bc21538..1a8fad7 100644 --- a/disscube/cli.py +++ b/disscube/cli.py @@ -125,7 +125,7 @@ def main(argv: list[str] | None = None) -> int: "record": str(report.record), }, indent=2, default=str)) return 0 - except PipelineError as exc: + except (PipelineError, ImportError) as exc: # ImportError: a missing optional extra names itself if is_json: import json print(json.dumps({"status": "error", "error": str(exc)}, indent=2), file=sys.stderr) diff --git a/tests/test_export.py b/tests/test_export.py index be6ece9..710c7d0 100644 --- a/tests/test_export.py +++ b/tests/test_export.py @@ -216,3 +216,14 @@ def test_pipeline_export_records_the_pipeline_and_source_checksums(tmp_path): assert tags["PIPELINE_CHECKSUM"].startswith("sha256:") assert src.tags(1)["SOURCE_CHECKSUM"].startswith("sha256:") assert len(src.tags(1)["CONTENT_HASH"]) >= 32 + + +def test_cli_reports_a_missing_netcdf_backend_without_a_traceback(tmp_path, monkeypatch, capsys): + from disscube.cli import main as cli + + for name in ("h5netcdf", "h5py", "netCDF4"): + monkeypatch.setitem(sys.modules, name, None) + code = cli(["run", str(QUICKSTART), "--workspace", str(tmp_path / "ws"), "-o", str(tmp_path / "q.nc")]) + err = capsys.readouterr().err + assert code == 2 + assert err.startswith("error:") and "disscube[netcdf]" in err and "Traceback" not in err