Skip to content

Document and test-isolate GRAPHTAGE_BATCH_BACKEND - #200

Merged
ESultanik merged 2 commits into
masterfrom
batch-backend-env-var
Sep 16, 2026
Merged

ESultanik merged 2 commits into
masterfrom
batch-backend-env-var

Conversation

@ESultanik

Copy link
Copy Markdown
Collaborator

GRAPHTAGE_BATCH_BACKEND pins the batch Levenshtein backend that #195 introduced. Two things about it need
attention before it is named in the 0.5.0 release notes.

The variable broke the test suite for anyone who used it

Two tests assert that a batch reaches the numpy backend when nothing pins a backend. Both read the ambient
environment, so exporting the variable made them fail:

$ GRAPHTAGE_BATCH_BACKEND=python pytest -q
FAILED test/test_batch_distance.py::TestBackendSelection::test_environment_variable_overrides_the_automatic_choice
FAILED test/test_batch_distance.py::TestCostOracle::test_one_big_pair_goes_to_a_vectorized_backend
2 failed, 270 passed

The product was correct in both cases — the variable did exactly what it promises. The tests simply could not
observe the unpinned baseline they were written to check, so anyone setting the variable to exercise the other
backend saw two spurious failures from tests that never mention it.

A new no_backend_pin() helper removes the variable for the span that watches the automatic choice, leaving the
halves that pin a backend explicitly alone.

It was documented only in a module docstring

rg GRAPHTAGE_BATCH_BACKEND hit only graphtage/batch_distance.py and its test. The README now carries an
"Environment Variables" section alongside the rest of the command line surface.

Testing

Both tests were checked against deliberate breaks rather than assumed to still bite:

Mutation Result
Ignore the variable at both read sites in batch_distance.py test_environment_variable_overrides_the_automatic_choice fails
Raise VECTORIZED_MIN_CELLS to 10^9 test_one_big_pair_goes_to_a_vectorized_backend fails

The suite passes with the variable set to python, set to numpy, and unset — 272 passed, 1770 subtests, in each
case. Ruff clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01F2sHz5c5TvMs9tFn2HhwaC

ESultanik and others added 2 commits September 16, 2026 12:05
Two tests in test_batch_distance.py assert that a batch reaches the numpy
backend when nothing pins a backend. Both read the ambient environment, so
exporting GRAPHTAGE_BATCH_BACKEND=python made them fail:

    FAILED TestBackendSelection::test_environment_variable_overrides_the_automatic_choice
    FAILED TestCostOracle::test_one_big_pair_goes_to_a_vectorized_backend

The product was correct in both cases -- the variable did exactly what it
promises. The tests simply could not observe the unpinned baseline they were
written to check, so anyone exercising the other backend saw two spurious
failures from tests that never mention the variable.

A new no_backend_pin() helper removes the variable for the span that watches
the automatic choice, leaving the halves that pin a backend explicitly alone.

Verified against both mutations: ignoring the variable at its two read sites
in batch_distance.py still fails the first test, and raising
VECTORIZED_MIN_CELLS still fails the second. The suite now passes with the
variable set to python, set to numpy, and unset.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F2sHz5c5TvMs9tFn2HhwaC
The variable pins the batch Levenshtein backend, but it was documented only in
the graphtage.batch_distance module docstring. The 0.5.0 release notes point
users at it, so it needs an entry where the rest of the command line surface is
documented.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F2sHz5c5TvMs9tFn2HhwaC
@ESultanik
ESultanik merged commit 7bedd14 into master Sep 16, 2026
12 checks passed
@ESultanik
ESultanik deleted the batch-backend-env-var branch September 16, 2026 17:16
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.

1 participant