mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 18:17:53 -06:00
refactor: share frontend_identity with core_probe
This commit is contained in:
1 parent
4f6bb08e2a
commit
922d60807f
2 files changed
+7
-19
No files matched your search
@@ -49,7 +49,8 @@ if sys.version_info < (3, 9):
|
||||
f"this is {sys.version.split()[0]}"
|
||||
)
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
SCRIPT_PATH = Path(__file__).resolve()
|
||||
ROOT = SCRIPT_PATH.parent.parent
|
||||
MIN_BENCH_REPETITIONS = 5
|
||||
DEFAULT_WORK_DIR = ROOT / "tmp" / "core_probe"
|
||||
BASE_OBSERVABLES = ("frame_sha1", "video_sha1", "audio_sha1", "state_sha1")
|
||||
@@ -668,8 +669,9 @@ def host_identity() -> dict:
|
||||
}
|
||||
|
||||
|
||||
def frontend_identity() -> dict:
|
||||
script = Path(__file__).resolve()
|
||||
def frontend_identity(script: Path = SCRIPT_PATH,
|
||||
label: str = "scripts/core_probe.py") -> dict:
|
||||
"""The commit a measurement came from, and whether its script differs from it."""
|
||||
commit: str | None = None
|
||||
dirty: bool | None = None
|
||||
try:
|
||||
@@ -680,7 +682,7 @@ def frontend_identity() -> dict:
|
||||
dirty = bool(status.strip())
|
||||
except (OSError, subprocess.CalledProcessError) as exc:
|
||||
print(f"WARNING: frontend commit unknown, git failed: {exc}", file=sys.stderr)
|
||||
return {"script": "scripts/core_probe.py", "commit": commit, "script_modified": dirty,
|
||||
return {"script": label, "commit": commit, "script_modified": dirty,
|
||||
"script_sha256": file_digest(script, "sha256")}
|
||||
|
||||
|
||||
|
||||
@@ -476,20 +476,6 @@ def run_variant(args: argparse.Namespace, emu: Emulator, tree: Path, oracle: dic
|
||||
"flags": flags, "verdict": verdict, "verdict_evidence": evidence}
|
||||
|
||||
|
||||
def frontend_identity() -> dict:
|
||||
script = Path(__file__).resolve()
|
||||
commit = dirty = None
|
||||
try:
|
||||
commit = subprocess.run(["git", "rev-parse", "HEAD"], cwd=ROOT, capture_output=True, text=True,
|
||||
check=True).stdout.strip()
|
||||
dirty = bool(subprocess.run(["git", "status", "--porcelain", "--", str(script)], cwd=ROOT,
|
||||
capture_output=True, text=True, check=True).stdout.strip())
|
||||
except (OSError, subprocess.CalledProcessError) as exc:
|
||||
print(f"WARNING: frontend commit unknown, git failed: {exc}", file=sys.stderr)
|
||||
return {"script": SCRIPT, "commit": commit, "script_modified": dirty,
|
||||
"script_sha256": cp.file_digest(script, "sha256")}
|
||||
|
||||
|
||||
def emulator_oracle(emu: Emulator, path: Path, content_sha1: str) -> dict:
|
||||
"""The oracle core_probe reads (tests/campaign/oracle.yml), looked up by
|
||||
the content's sha1 and the emulator's name, with the emulator's own
|
||||
@@ -566,7 +552,7 @@ def _probe(args: argparse.Namespace, emu: Emulator) -> int:
|
||||
"core": {"file": meta["name"], "sha256": meta["sha256"], "repo": f"https://github.com/{meta['repo']}",
|
||||
"commit": None, "build_command": None, "compiler": None, "library_name": emu.name,
|
||||
"library_version": meta["tag"], "artifact": meta["url"]},
|
||||
"frontend": frontend_identity(),
|
||||
"frontend": cp.frontend_identity(Path(__file__).resolve(), SCRIPT),
|
||||
"host": {**cp.host_identity(), "load_before": load_before, "load_after": load_after,
|
||||
"max_load": max_load},
|
||||
"inputs": {
|
||||
|
||||
Reference in new issue
Block a user