hypso.ac.adapters.base#
Running an external atmospheric-correction tool in its own process (ACRunError, run_subprocess_driver), used by hypso.processing.atmospheric.
Why a subprocess: Polymer’s v1 (HYPSO-SRF-patched) and v2 (stock) builds ship different, incompatible versions of the same-named top-level packages (confirmed live: v2’s core needs core.process.blockwise, absent from v1’s core checkout), and Python’s sys.modules import cache pins whichever version is imported first for the rest of the process’s lifetime - unsafe if a long-lived process ever runs a v1 correction and a v2 correction. A fresh subprocess per run sidesteps this, and contains crashes in the tools’ native code.
Exceptions#
A subprocess-isolated AC tool run failed. Carries the subprocess's raw |
Functions#
|
Run driver_module (a hypso.ac.adapters._*_driver module with a |
Module Contents#
- exception hypso.ac.adapters.base.ACRunError(tool, returncode, stdout, stderr, error_type=None, message=None)[source]#
Bases:
RuntimeErrorA subprocess-isolated AC tool run failed. Carries the subprocess’s raw stdout/stderr and, if its driver script produced a structured result.json before failing, that error’s type/message/traceback from the tool’s own process - so a caller sees why (e.g. “eoread not on this interpreter’s path”) instead of just “subprocess exited 1”.
Initialize self. See help(type(self)) for accurate signature.
- hypso.ac.adapters.base.run_subprocess_driver(python_path, driver_module, config, tool_name, extra_env=None)[source]#
Run driver_module (a hypso.ac.adapters._*_driver module with a python -m-invocable __main__ block) in a fresh subprocess under python_path, passing it config as JSON and reading back its JSON result. Config/result files live in a per-call TemporaryDirectory (not a shared/fixed path) so concurrent runs never collide - the exact class of bug hypso-processing-pipeline had to work around by hand for OC-SMART’s staging directory.
python_path defaults to sys.executable at the call site (the same interpreter this process is running under) when the caller doesn’t need a genuinely separate environment - that interpreter must have hypso importable for any driver whose tool resolves a hook by dotted string name back into this package (e.g. Polymer’s srf_getter).
extra_env, if given, is merged into the subprocess’s environment (on top of this process’s own os.environ) - the mechanism for passing secrets (e.g. ACOLITE’s EARTHDATA credentials) to a driver WITHOUT writing them into config.json, which lives on disk (even briefly, even in a private TemporaryDirectory) for the run’s duration.
Raises ACRunError on any failure (non-zero exit, missing/unparseable result.json, or a result.json reporting status != “ok”); returns the parsed result dict on success.