Document and test-isolate GRAPHTAGE_BATCH_BACKEND - #200
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GRAPHTAGE_BATCH_BACKENDpins the batch Levenshtein backend that #195 introduced. Two things about it needattention 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
numpybackend when nothing pins a backend. Both read the ambientenvironment, so exporting the variable made them fail:
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 thehalves that pin a backend explicitly alone.
It was documented only in a module docstring
rg GRAPHTAGE_BATCH_BACKENDhit onlygraphtage/batch_distance.pyand 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:
batch_distance.pytest_environment_variable_overrides_the_automatic_choicefailsVECTORIZED_MIN_CELLSto 10^9test_one_big_pair_goes_to_a_vectorized_backendfailsThe suite passes with the variable set to
python, set tonumpy, and unset — 272 passed, 1770 subtests, in eachcase. Ruff clean.
🤖 Generated with Claude Code
https://claude.ai/code/session_01F2sHz5c5TvMs9tFn2HhwaC