Skip to content

Move pure filesystem, project, and scoring helpers into bcbench-core - #917

Open
Sun Haoran (haoranpb) wants to merge 2 commits into
core/stack-01-package-skeletonfrom
core/stack-02-pure-utilities
Open

Sun Haoran (haoranpb) wants to merge 2 commits into
core/stack-01-package-skeletonfrom
core/stack-02-pure-utilities

Conversation

@haoranpb

@haoranpb Sun Haoran (haoranpb) commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Stack 2 of the bcbench-core extraction, stacked on #914. Moves the first code into the library: helpers that are free of BC-Bench configuration, logging setup, and benchmark policy. The app imports them directly from bcbench_core; there are no re-export shims.

Core module Moved from Contents
bcbench_core.filesystem operations/filesystem_operations.py (rename) remove_tree, clear_directory, prepare_run_dir
bcbench_core.projects operations/project_operations.py (rename) is_test_project, categorize_projects
bcbench_core.scoring results/metrics.py (split) precision_recall, f_beta_score, f1_score, pass_at_k, pass_hat_k
bcbench_core.stats results/metrics.py (rename) bootstrap_ci

Behavior-preserving changes needed to move:

  • categorize_projects and is_test_project take test identifiers as a parameter defaulting to ("test", "tests") instead of reading app config. Patch collection keeps the config field because it matches identifiers as substrings, not path-component prefixes.
  • projects logs through a standard logging.getLogger(__name__) logger. Its only log is an error, which still reaches the app's root handlers (including GitHub annotations).
  • Core now depends on numpy and scipy for bootstrap_ci. They are imported only by bcbench_core.stats, so bcbench_core.scoring stays dependency-free at import time.

Tests: moved tests live in packages/bcbench-core/tests and run in the same uv run pytest invocation as the app (testpaths covers both), producing one coverage report. I added direct tests for precision_recall, F-beta, remove_tree, and prepare_run_dir, which previously had only indirect coverage; core is at 100% line coverage. Core declares pytest in its own dev group so ty's missing-direct-dependency accepts test imports.

Deferred: git operations need a logging decision first. They log at INFO, but the app only raises the bcbench logger above the root's WARNING level, so INFO logs from bcbench_core.* would be dropped.

Sun Haoran (haoranpb) and others added 2 commits October 2, 2026 13:31
First code to move into the library. These helpers have no dependency on
BC-Bench configuration or policy, so they move with minimal changes and
the app imports them directly from bcbench_core (no re-export shims).

- bcbench_core.filesystem: remove_tree, clear_directory, prepare_run_dir
- bcbench_core.projects: categorize_projects; the AL test-project
  identifiers become DEFAULT_TEST_PROJECT_IDENTIFIERS instead of a
  constant app config field, and collection uses the same constant
- bcbench_core.scoring: precision/recall, F-beta, pass@k, pass^k;
  bootstrap_ci stays in the app because it needs numpy and scipy
- Core tests live in packages/bcbench-core/tests with their own pytest
  configuration (importlib import mode, strict) and run as a separate CI step

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3fa47b3c-f5d6-4c36-9be3-c4fdf2bebe47
…roject

- Run app and core tests in one pytest invocation from the root config;
  uv workspaces manage environments, not test runners, and a single run
  yields one coverage report for both packages
- Move bootstrap_ci into bcbench_core.stats; core now depends on numpy and
  scipy, kept out of bcbench_core.scoring so scoring stays dependency-free
- Make is_test_project public and inline the ("test", "tests") default;
  collection keeps its own substring-based identifiers in app config

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3fa47b3c-f5d6-4c36-9be3-c4fdf2bebe47
@haoranpb
Sun Haoran (haoranpb) marked this pull request as ready for review October 2, 2026 13:03
Copilot AI balanced review requested due to automatic review settings October 2, 2026 13:03
@haoranpb
Sun Haoran (haoranpb) added this pull request to stack #916 October 2, 2026 13:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The public project classifier does not satisfy its documented case-insensitive component-prefix behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Extracts reusable filesystem, project categorization, scoring, and statistical helpers into bcbench-core, updating application consumers and test infrastructure.

Changes:

  • Moves reusable helpers into four core modules.
  • Updates application and notebook imports without compatibility shims.
  • Relocates and expands core tests and CI coverage.
File Description
uv.lock Locks core runtime and test dependencies.
tests/​test_filesystem_operations.py Removes superseded application-level tests.
src/​bcbench/​results/​leaderboard.py Imports scoring and statistics from core.
src/​bcbench/​results/​codereview.py Imports scoring helpers from core.
src/​bcbench/​results/​__init__.py Removes obsolete metric re-exports.
src/​bcbench/​operations/​git_operations.py Uses core filesystem helper.
src/​bcbench/​operations/​bc_operations.py Uses core filesystem helper.
src/​bcbench/​operations/​__init__.py Removes moved helper exports.
src/​bcbench/​evaluate/​testgeneration.py Uses core project categorization.
src/​bcbench/​evaluate/​nl2al.py Uses core tree removal.
src/​bcbench/​evaluate/​dataquery.py Uses core directory clearing.
src/​bcbench/​evaluate/​codereview_judge_calibration.py Uses core precision and recall.
src/​bcbench/​evaluate/​bugfix.py Uses core project categorization.
src/​bcbench/​commands/​evaluate.py Uses core run-directory preparation.
src/​bcbench/​commands/​contamination.py Uses core run-directory preparation.
pyproject.toml Adds core tests to pytest discovery.
packages/​bcbench-core/​tests/​test_stats.py Tests bootstrap confidence intervals.
packages/​bcbench-core/​tests/​test_scoring.py Tests extracted scoring helpers.
packages/​bcbench-core/​tests/​test_projects.py Tests project categorization.
packages/​bcbench-core/​tests/​test_filesystem.py Tests filesystem helpers.
packages/​bcbench-core/​src/​bcbench_core/​stats.py Adds bootstrap statistics.
packages/​bcbench-core/​src/​bcbench_core/​scoring.py Houses dependency-light scoring functions.
packages/​bcbench-core/​src/​bcbench_core/​projects.py Adds configurable project categorization.
packages/​bcbench-core/​src/​bcbench_core/​filesystem.py Houses reusable filesystem helpers.
packages/​bcbench-core/​README.md Documents the core test command.
packages/​bcbench-core/​pyproject.toml Declares dependencies and test linting.
notebooks/​utils.py Updates scoring imports.
notebooks/​test-generation/​altest-comparison.ipynb Updates core helper imports.
notebooks/​bug-fix/​claude-vs-copilot.ipynb Updates statistics import.
notebooks/​bug-fix/​altool-comparison.ipynb Updates core helper imports.
notebooks/​archive/​multi-run.ipynb Updates scoring imports.
CONTRIBUTING.md Documents combined coverage invocation.
.github/​workflows/​CI.yml Includes core in coverage collection.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants