Read the records at their configured paths in the review header, replay, chunk-pr, score-outcomes, reading-cost and metric-bench
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
usage: metric-bench [history]
|
||||
|
||||
history defaults to docs/comprehension-history.md in the checkout it runs in, and the bench reads
|
||||
the checkout that holds the history. For each scoring run in it, those a fall called inside a paired
|
||||
history defaults to the docs/comprehension-history.md the project's config names, and the bench
|
||||
reads the checkout that holds the history, or the one it runs in where the config puts the history outside it. For each scoring run in it, those a fall called inside a paired
|
||||
ruling included, at the commit the panel read, it measures each module-level function and each
|
||||
method of a module-level class in the Python files git tracks, leaving out test_*.py, *_test.py and
|
||||
anything under a tests/ folder:
|
||||
@@ -40,6 +40,7 @@ from review_rules.comprehension_history import entries, Entry
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import git
|
||||
from metric_bench.python_units import measured, python_units, Unit
|
||||
from project_config.main import project
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
@@ -70,7 +71,12 @@ def read_history(given: pathlib.Path | None) -> tuple[str, pathlib.Path, str] |
|
||||
found = git("rev-parse", "--show-toplevel", cwd=str(given.parent) if given else None)
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
history = given or pathlib.Path(found.strip(), "docs", "comprehension-history.md")
|
||||
if given:
|
||||
history = given
|
||||
elif isinstance(config := project(), Failure):
|
||||
return config
|
||||
else:
|
||||
history = config.paths["comprehension-history"]
|
||||
if not given and not history.exists():
|
||||
return Failure(f"no comprehension history at {history}; larv-review writes one at a project's first paired ruling or scoring run")
|
||||
try:
|
||||
|
||||
@@ -15,6 +15,7 @@ from review_rules.comprehension_history import entries, Place
|
||||
from failure import Failure
|
||||
from test_env import isolated_env
|
||||
from metric_bench.main import scored_runs
|
||||
from project_config.test_project_config import write_config
|
||||
|
||||
TOOL = pathlib.Path(__file__).resolve().parents[1] / "metric-bench"
|
||||
|
||||
@@ -211,7 +212,9 @@ class BlackBox(unittest.TestCase):
|
||||
return top
|
||||
|
||||
def run_tool(self, top: str, *args: str) -> subprocess.CompletedProcess:
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], cwd=top, capture_output=True, text=True, env=isolated_env())
|
||||
home = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
|
||||
write_config(home, pathlib.Path(top))
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], cwd=top, capture_output=True, text=True, env={**isolated_env(), "HOME": str(home)})
|
||||
|
||||
def test_prints_each_metrics_score_on_each_run_and_the_medians(self):
|
||||
top = self.project("# Comprehension history\n\n## 2026-10-08T12:50:49Z, PR #1 at COMMIT\n\nJunior A, hardest first:\n\n- `a.py:1` `hard`\n")
|
||||
|
||||
Reference in New Issue
Block a user