Repository navigation
Fix embedding-only populations (#649) and pickling of described Setups (#650) - #651
Merged
Merged
Conversation
#650) #649: populations_in_report validated the observations with the explainable features only, empty for an embedding-only Setup, so every such report with a group found was refused. It now validates with the other tables' columns when there is no explainable feature, as the report's data check does. #650: ExperimentBlock and TargetSuggestions hold MappingProxyType mappings, which cannot be pickled to worker processes (n_jobs != 1). Both now pickle as plain dicts through __reduce__ and are frozen again on load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VbytvF3Gsa85ix8Ne2yMDW
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.
Fixes #649
Fixes #650
#649: embedding-only reports crash in
populations_in_reportCause.
populations_in_reportvalidated the observations withfeature_cols=setup.columns. Those are the explainable features, and an embedding-only Setup has none, sovalidate_input_tablesrefused every such report in which a group was found. The existing embedding-only tests found no groups and returned early, so they never reached the validation.Fix.
workflows/_populations.pynow validates withlist(setup.columns) or table_columns(setup). In embedding-only mode that is every column of the other tables.embedding_reportalready passes the same list tocheck_tables, and_population_spacesand_one_per_fieldfollow the same pattern. I chose the strict option: all of the table's columns are checked, not just the first. Validation keeps NaN and drops no rows, so the set of marked cells is unchanged. A Setup with explainable features validates exactly as before.Test.
tests/test_populations.py::test_an_embedding_only_report_finds_and_tests_the_populations_of_its_tableuses the_screendata with its 3 features passed as a non-explainable table, with no readout. Before the fix it failed with theValueErrorfrom the issue. Now it shows that:result.enrichmentis identical (assert_frame_equal) toenrichment_testsrun directly on the marks, so the report is correct, not just non-crashing;#650: described Setup with
n_jobs != 1fails with "cannot pickle 'mappingproxy'"Cause. In
described.py,ExperimentBlockis frozen withMappingProxyType: its fields and each of itsrepeat_groups.TargetSuggestions.suggestedand.treatment_keysare frozen the same way.Setup.described(aControlSource) carries the block, and the Setup is pickled to worker processes.Fix.
ExperimentBlock.__reduce__pickles the block as plain dicts and rebuilds it through_frozen_block, so it is read-only again at every level.TargetSuggestions.__reduce__does the same. Types, equality and read-only behaviour are unchanged.Tests (
tests/test_described.py):test_a_described_setup_pickles_with_its_description_unchanged_and_read_only(v10, the reference chain): the round trip gives equal objects, and they are still read-only, nested mappings included.test_a_described_report_in_worker_processes_is_the_serial_report(v03):n_jobs=2gives a full summary text, contrast table and discovery tests/ranking identical ton_jobs=1.Both failed before the fix with
TypeError: cannot pickle 'mappingproxy' object.Same class of bug elsewhere.
MappingProxyTypeis used only indescribed.py. For every golden export (v03, v10, v27, v30, v33), I pickled the described experiment, the Setup afterreportand every entry ofreport.results, and all succeeded. The full summary withn_jobs=2was identical ton_jobs=1for all five (an ad hoc script, not committed).Scientific behaviour
Gate (local; Actions are blocked)
Run on head
0f18c19d1014fea313ace6166bbf804939d9452fin a fresh venv (pip install --no-cache-dir -e ".[dev]", Python 3.13), with noPYTEST_ADDOPTS:python -m ruff check src tests data: All checks passedpython -m ruff format --check src tests data: 536 files already formattedpytest -n 0 tests/test_guards.py tests/test_function_guards.py tests/test_function_tools.py: 102 passedpython tools/audit.py --check-against origin/main: baselines only tightened against origin/mainpytest(whole suite, xdist): 4785 passed, 2 skipped, 6 xfailed, 0 failedGenerated by Claude Code