v5: CRD toolbox self-vendored from PyPI 0.1.2 in fresh containers
Browse files1183 unmodified lines11841185118611871188118911901191119211931183 unmodified linesdef _crd_import():import syscrd_path = os.environ.get("CRD_PKG_PATH", _CRD_PKG_PATH)if crd_path not in sys.path:sys.path.insert(0, crd_path)from conformal_region_designer.conformity_optimizer import ConformalRegionfrom conformal_region_designer.shapes import hyperrectangle as _hrif not getattr(_hr, "_orca_patched", False):_orig_hr_fit = _hr.HyperrectangleTemplate.fit_shape1183 unmodified lines11841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171183 unmodified linesdef _crd_import():import systry:from conformal_region_designer.conformity_optimizer import (ConformalRegion,)except ImportError:# vendored install of the official toolbox (pinned 0.1.2): PyPI wheel# extracted to a temp dir (deps are numpy/scipy/scikit-learn only)import jsonimport urllib.requestimport zipfiledest = os.environ.get("CRD_PKG_DIR", "/tmp/crd_pkg")if not os.path.exists(os.path.join(dest, "conformal_region_designer", "conformity_optimizer.py")):os.makedirs(dest, exist_ok=True)with urllib.request.urlopen("https://pypi.org/pypi/conformal-region-designer/0.1.2/json",timeout=60) as r:meta = json.load(r)whl_url = next(u["url"] for u in meta["urls"]if u["filename"].endswith("py3-none-any.whl"))whl = os.path.join(dest, os.path.basename(whl_url))print(f"[crd] downloading {whl_url}", flush=True)urllib.request.urlretrieve(whl_url, whl)with zipfile.ZipFile(whl) as zf:zf.extractall(dest)if dest not in sys.path:sys.path.insert(0, dest)from conformal_region_designer.conformity_optimizer import (ConformalRegion,)from conformal_region_designer.shapes import hyperrectangle as _hrif not getattr(_hr, "_orca_patched", False):_orig_hr_fit = _hr.HyperrectangleTemplate.fit_shape
code/run_full.py+28-4