Repository navigation
feat: backfill TowersBlock.reward_scale as float from ViRMEn logs - #186
Merged
Merged
Conversation
reward_scale was declared tinyint, so ViRMEn's fractional reward scales (0.2 steps) were collapsed to integers on insert. After widening the column to float, scripts/backfill_reward_scale.py re-reads the behavior logs and updates only that column, leaving TowersBlock.Trial untouched. Each block is verified before writing: the stored value must be the rounded or truncated file value and first_trial must agree. Logs found outside the recorded path (via --search-dir or --path-map) must match the session's subject and start time. Read-only unless --commit is passed. Also syncs the Python mirrors of acquisition and behavior with the MATLAB definitions: adds SessionBlock/SessionBlockTrial, new_remote_path_behavior_file, missing Session/TowersBlock attributes, and extstorage blobs on TowersBlock.Trial.
…scalefactor-float-7a480f
master moved to a stricter ruff.toml (line-length 88, more rule sets) after this branch was cut. Reformat, and fix the new findings: - Report searched log files that fail to load instead of silently skipping them, so an unresolved session isn't blamed on the identity check alone (S112). - Mark the naive datetimes as intentional: the ViRMEn clock vector and the MySQL datetime it is compared against are both rig-local (DTZ001). - Parenthesize an implicit string concatenation, use min() over sorted()[0].
uv audit fails on master's lock file: - dnspython 2.8.0 -> 2.9.0 (GHSA-45c3-73f7-pv4m) - msgpack 1.2.2 -> 1.2.4 (GHSA-j586-36cw-2gc2) - tornado 6.5.10 -> 6.6 (GHSA-pw9p-v7r6-gx4p, GHSA-r4j5-9xpp-3985, GHSA-pcg2-g6cj-q92c) Dependabot's #183 covers only the first two. tornado 6.6 (2026-10-21) is now outside the 14-day exclude-newer window. No other locked versions change.
…o claude/towerblocks-scalefactor-float-7a480f # Conflicts: # uv.lock
This was referenced Nov 25, 2026
tabedzki
added a commit
that referenced
this pull request
Nov 25, 2026
…Session #186 added stimulus_set to acquisition.Session, but the live u19_acquisition.session table has no such column and MATLAB never fills it, so every insert or fetch of Session fails. behavior.TowersSession.stimulus_set is a real column and stays. Add DB-free tests for both. Assisted-by: ClaudeCode:claude-sonnet-5-5
tabedzki
added a commit
that referenced
this pull request
Nov 25, 2026
…Session #186 added stimulus_set to acquisition.Session, but the live u19_acquisition.session table has no such column and MATLAB never fills it. Reads were unaffected, because DataJoint takes an existing table's heading from the database; the definition was just wrong. behavior.TowersSession's stimulus_set is a real column and stays. Add DB-free tests for both. Assisted-by: ClaudeCode:claude-sonnet-5-5
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.
Summary
behavior.TowersBlock.reward_scalewastinyint, but ViRMEn moves the reward scale in 0.2 steps (processKeypress.m,autoAdjustReward.m), so 1.2 and 1.8 were stored as integers. Once the column is widened tofloat(done separately in the DB), this script restores the real values. It updates only that one column. It does not delete and repopulate, which would cascade intoTowersBlock.Trialand its extstorage blobs.The checking logic is in
u19_pipeline/utils/reward_scale_backfill.py, which doesn't need a DB, so it can be tested.This PR also brings the Python mirrors in line with the MATLAB definitions, which Python ingestion will eventually need:
Evidence
pytest tests/utils→ImportError: cannot import name 'reward_scale_backfill'After:
71 passed; full suite on the merge with master:695 passed, 6 skipped(skips are missingsuite2p/sklearn). Covers rounding at .5 and negatives, 0 as a fallback vs. a valid truncation, None/NaN/inf/empty/multi-element scalars, single-block and single-trial logs squeezed to dicts,first_trialmismatches, two sessions on the same day separated by start time, missing identity fields, duplicate basenames, and the CSV round trip.Not verified: there's no DB access from the dev host, so the script hasn't run against real data, and
resolve_loghas no tests (importing the script needs a DB config). First real run should be--user <id> --limit 20as an audit.Open question: Python's
TowersBlock.Trialmay resolve to a different MySQL table name than MATLAB'sTowersBlockTrial. Check withSHOW TABLES FROM u19_behavior LIKE '%towers_block%'. The script doesn't touch Trial.Merge Danger
Door: two-way
Merging writes nothing. The script is read-only unless you pass
--commit. The definition changes only affect Python reads, because DataJoint 0.14 loads the heading for an existing table from the DB.Blast Radius: low
Python code that inserts through these definitions now gets MATLAB's defaults. The
Trialblobs would go to extstorage instead of MySQL.