File size: 973 Bytes
2eee48c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""Resolve a release directory for source-tree and installed-package entrypoints."""
from __future__ import annotations
import os
from pathlib import Path


def dataset_root(root: Path | str | None = None) -> Path:
    """Prefer an explicit root, then its environment setting, then local data."""
    configured = root if root is not None else os.environ.get('MANIPULATIONARENA_ROOT')
    candidates = ([Path(configured)] if configured is not None else
                  [Path(__file__).resolve().parents[1], Path.cwd()])
    markers = ('index/units.jsonl', 'engine/profiles.json', 'environment/manifest.json')
    for candidate in candidates:
        resolved = candidate.expanduser().resolve()
        if all((resolved / marker).is_file() for marker in markers):
            return resolved
    raise ValueError('Dataset root was not found. Pass --root /path/to/ManipulationArena '
                     'or set MANIPULATIONARENA_ROOT to the complete release directory.')