Datasets:
Download code/evaluation-code/v0.2-0c2690ae/apps/console/server/review_layout.py from VEHwang/cocogni4d: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/apps/console/server/review_layout.py
- Command line
-
hf download hf://datasets/VEHwang/cocogni4d/code/evaluation-code/v0.2-0c2690ae/apps/console/server/review_layout.py
-
curl -L -o review_layout.py https://huggingface.co/datasets/VEHwang/cocogni4d/resolve/main/code/evaluation-code/v0.2-0c2690ae/apps/console/server/review_layout.py
1.36 kB
| """The versioned layout shared by run writers and review readers.""" | |
| import json | |
| from collections.abc import Mapping | |
| from pathlib import Path | |
| RUN_SCHEMA = 'np-run/2' | |
| LAYOUT_VERSION = 2 | |
| IMPORTS_DIR = 'review-imports' | |
| class ReviewLayoutError(ValueError): | |
| code = 'REVIEW_IMPORT_LAYOUT' | |
| def imports_root(run_dir: Path, run: Mapping | None = None) -> Path: | |
| root = Path(run_dir).resolve() | |
| message = f'运行 {root.name} 布局无效;仅支持现行布局,请用当前管线重新生成。' | |
| try: | |
| if run is None: | |
| run = json.loads((root / 'run.json').read_text(encoding='utf-8')) | |
| target = root / IMPORTS_DIR | |
| legacy = root / 'screen3' | |
| if (not isinstance(run, Mapping) or run.get('schema') != RUN_SCHEMA | |
| or type(run.get('layout_version')) is not int or run['layout_version'] != LAYOUT_VERSION | |
| or run.get('review_imports') != IMPORTS_DIR or run.get('id') != root.name | |
| or legacy.exists() or legacy.is_symlink() | |
| or not target.resolve().is_relative_to(root) | |
| or target.exists() and not target.is_dir()): | |
| raise ReviewLayoutError(message) | |
| return target | |
| except (OSError, ValueError) as exc: | |
| if isinstance(exc, ReviewLayoutError): | |
| raise | |
| raise ReviewLayoutError(message) from exc | |