Skip to content

fix: add runtime guards in BlockUnit and fix SubInfo bare except#19

Merged
zh1peng merged 5 commits intoTaskBeacon:mainfrom
HugoFara:fix/blockunit-subinfo-guards
Apr 1, 2026
Merged

fix: add runtime guards in BlockUnit and fix SubInfo bare except#19
zh1peng merged 5 commits intoTaskBeacon:mainfrom
HugoFara:fix/blockunit-subinfo-guards

Conversation

@HugoFara
Copy link
Copy Markdown
Contributor

Hi @zh1peng , this PR fixes a few bugs I found in the app.

  • BlockUnit.run_trial(): Raise RuntimeError when run_trial() is called before generate_conditions() (previously crashed with opaque message)
  • BlockUnit.run_trial(): raise TypeError when the trial function returns a non-dict (previously crashed with AttributeError: 'NoneType' object has no attribute 'update')
  • BlockUnit.logging_block_info(): fix .count() call on numpy array (use np.sum() instead) and guard against conditions=None
  • SubInfo.validate(): replace bare except: with except Exception: so KeyboardInterrupt propagates (Ctrl+C was being
    swallowed)

I also included a few tests to check for regressions:

  • tests/test_BlockUnit.py — verifies both guards produce clear error messages
  • tests/test_SubInfo.py — verifies cancel path and KeyboardInterrupt propagation

HugoFara and others added 5 commits March 26, 2026 11:44
- Raise RuntimeError when run_trial() is called before generate_conditions()
- Raise TypeError when trial function returns non-dict
- Fix logging_block_info() calling .count() on numpy array
- Replace bare except: with except Exception: in SubInfo.validate()
- Add test_BlockUnit.py and test_SubInfo.py covering these paths
CI environment does not have numpy installed. Use a plain list instead
of np.array() since enumerate() works on both.
The CI smoke job only installs pyyaml — numpy and psychopy are not
available. Use skipUnless with a try-import guard instead of stubbing
sys.modules, matching the existing pattern in test_cli_root.py.
@zh1peng zh1peng merged commit 22197b3 into TaskBeacon:main Apr 1, 2026
2 checks passed
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