Preserve offline geometry, marking, replay and evaluation pipelines with source manifests and synthetic tests. Research qualification does not activate these methods as production navigation.
43 lines
1.0 KiB
Python
43 lines
1.0 KiB
Python
"""Artifact-scoped I/O for the offline qualification only."""
|
|
from pathlib import Path
|
|
import json, os, hashlib, shutil
|
|
|
|
RUN = Path('/run')
|
|
ORTHO = Path('/ortho')
|
|
SURVEY = ORTHO / 'survey'
|
|
SCENE = os.environ.get('ORTHO_SCENE', '')
|
|
MODEL = os.environ.get('MV_MODEL', 'mapillary')
|
|
|
|
|
|
def read(path):
|
|
return json.loads(Path(path).read_text())
|
|
|
|
|
|
def write(path, value):
|
|
path = Path(path)
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
temporary = path.with_suffix(path.suffix + '.tmp')
|
|
temporary.write_text(json.dumps(value, indent=2, allow_nan=False))
|
|
temporary.replace(path)
|
|
|
|
|
|
def digest(path):
|
|
h = hashlib.sha256()
|
|
with Path(path).open('rb') as stream:
|
|
for block in iter(lambda: stream.read(1024 * 1024), b''):
|
|
h.update(block)
|
|
return h.hexdigest()
|
|
|
|
|
|
def guard():
|
|
if shutil.disk_usage(RUN).free < 8 * 2**30:
|
|
raise RuntimeError('Qualification free-disk floor reached')
|
|
|
|
|
|
def record(message):
|
|
print(json.dumps(message, allow_nan=False), flush=True)
|
|
|
|
|
|
def config():
|
|
return read(RUN / 'config.json')
|