Skip to content

Commit

Permalink
fix cryptic error msgs for bpod + frame2ttl (#479)
Browse files Browse the repository at this point in the history
* fix cryptic error msgs for bpod + frame2ttl

fixes #478

* flake8

* add helpful msg for rotary encoder at null port

* fix directory for CI unit-tests

* use pip cache for CI

* commit of shame

* and another one

* commit of shame, vol 2

* it's never ending

* perhaps?

* -

* --

* ---

* this one's gonna work for sure

* Update test_scripts.py

* create setting files

* added project_extraction

* Update main.yaml

* Update test_scripts.py

* Update main.yaml

* Update main.yaml

* Update main.yaml

* Update main.yaml

* ###

* Update main.yaml

* ¯\_(ツ)_/¯

* Update main.yaml

* giving up for today

* actually ...?

* Update main.yaml

* Update main.yaml

* Update main.yaml

* Update main.yaml

* Update installation.rst

---------

Co-authored-by: olivier <[email protected]>
  • Loading branch information
bimac and oliche authored Sep 11, 2023
1 parent 02c3b82 commit 6da0a84
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 21 deletions.
28 changes: 18 additions & 10 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ jobs:
steps:
- name: Checkout iblrig repo
uses: actions/checkout@v3
with:
path: iblrig

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/requirements*.txt'

- name: flake8
run: |
pip install --upgrade pip
pip install flake8 --quiet
cd iblrig
python -m flake8
- name: iblrig and iblpybpod requirements
shell: bash -l {0}
run: |
pip install --editable iblrig
pip install -r iblrig/requirements.txt
pip install -r requirements.txt
- name: Install audio library (Ubuntu only)
if: matrix.os == 'ubuntu-latest'
Expand All @@ -45,17 +45,25 @@ jobs:
if: matrix.os == 'windows-latest'
shell: pwsh -l {0}
run: |
cd iblrig\Bonsai
cd Bonsai
powershell.exe .\install.ps1
- name: Create config files (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
cp settings/hardware_settings_template.yaml settings/hardware_settings.yaml
cp settings/iblrig_settings_template.yaml settings/iblrig_settings.yaml
- name: Create config files (Windows)
if: matrix.os == 'windows-latest'
run: |
copy settings\hardware_settings_template.yaml settings\hardware_settings.yaml
copy settings\iblrig_settings_template.yaml settings\iblrig_settings.yaml
- name: iblrig unit tests
shell: bash -l {0}
run: |
cd iblrig
cd test
python -m unittest discover
cd test_tasks
python -m unittest discover
python -m unittest discover -s ./iblrig/test -t .
- name: Generate requirements_frozen.txt
run: pip freeze > requirements_frozen.txt
Expand Down
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Install iblrigv8
pip install -r requirements.txt
4. Install additional tasks and extractors
4. Install additional tasks and extractors for personal projects (optional)

.. code-block:: powershell
Expand Down
13 changes: 13 additions & 0 deletions iblrig/base_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@ def stop_mixin_bpod(self):
self.bpod.close()

def start_mixin_bpod(self):
if self.hardware_settings['device_bpod']['COM_BPOD'] is None:
raise ValueError("The value for device_bpod:COM_BPOD in "
"settings/hardware_settings.yaml is null. Please "
"provide a valid port name.")
self.bpod = Bpod(self.hardware_settings['device_bpod']['COM_BPOD'])
self.bpod.define_rotary_encoder_actions()

Expand Down Expand Up @@ -688,6 +692,10 @@ def init_mixin_frame2ttl(self, *args, **kwargs):
def start_mixin_frame2ttl(self):
# todo assert calibration
# todo release port on failure
if self.hardware_settings['device_frame2ttl']['COM_F2TTL'] is None:
raise ValueError("The value for device_frame2ttl:COM_F2TTL in "
"settings/hardware_settings.yaml is null. Please "
"provide a valid port name.")
self.frame2ttl = frame2TTL.frame2ttl_factory(self.hardware_settings['device_frame2ttl']['COM_F2TTL'])
try:
self.frame2ttl.set_thresholds(
Expand All @@ -714,6 +722,11 @@ def init_mixin_rotary_encoder(self, *args, **kwargs):
)

def start_mixin_rotary_encoder(self):
if self.hardware_settings['device_rotary_encoder']['COM_ROTARY_ENCODER'] is None:
raise ValueError(
"The value for device_rotary_encoder:COM_ROTARY_ENCODER in "
"settings/hardware_settings.yaml is null. Please "
"provide a valid port name.")
try:
self.device_rotary_encoder.connect()
except serial.serialutil.SerialException as e:
Expand Down
16 changes: 15 additions & 1 deletion iblrig/test/test_base_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import ibllib.io.session_params as ses_params

from iblrig.test.base import TASK_KWARGS
from iblrig.base_tasks import SoundMixin, RotaryEncoderMixin, BaseSession, BpodMixin, ValveMixin
from iblrig.base_tasks import (SoundMixin, RotaryEncoderMixin, BaseSession, BpodMixin,
ValveMixin, Frame2TTLMixin)
from iblrig.base_choice_world import BiasedChoiceWorldSession
from ibllib.io.session_params import read_params
from iblrig.misc import _get_task_argument_parser, _post_parse_arguments
Expand Down Expand Up @@ -62,6 +63,17 @@ def test_rotary_encoder_mixin(self):
-2: 'RotaryEncoder1_3',
2: 'RotaryEncoder1_4'
}
with self.assertRaises(ValueError):
RotaryEncoderMixin.start_mixin_rotary_encoder(session)

def test_frame2ttl_mixin(self):
"""
Instantiates a bare session with the frame2ttl mixin
"""
session = self.session
Frame2TTLMixin.init_mixin_frame2ttl(session)
with self.assertRaises(ValueError):
Frame2TTLMixin.start_mixin_frame2ttl(session)

def test_sound_card_mixin(self):
"""
Expand All @@ -75,6 +87,8 @@ def test_bpod_mixin(self):
session = self.session
BpodMixin.init_mixin_bpod(session)
assert hasattr(session, 'bpod')
with self.assertRaises(ValueError):
BpodMixin.start_mixin_bpod(session)

def test_valve_mixin(self):
session = self.session
Expand Down
10 changes: 2 additions & 8 deletions iblrig/test/test_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@

import scripts.transfer_rig_data as transfer_rig_data
from scripts.ibllib.purge_rig_data import purge_local_data, session_name

OPENALYX_PARAMETERS = {
"base_url": "https://openalyx.internationalbrainlab.org",
"username": "intbrainlab",
"password": "international",
"silent": True
}
from ibllib.tests import TEST_DB


class TestScripts(unittest.TestCase):
Expand All @@ -29,7 +23,7 @@ def test_purge_rig_data(self):
local_data = root.joinpath('iblrig_data', 'Subjects')
local_data.mkdir(parents=True)
# Need to add a username/password to the ONE call for the test to function
one = ONE(**OPENALYX_PARAMETERS)
one = ONE(**TEST_DB)
# Find a session with at least 5 or so datasets and touch those files
sessions = one.search(lab='cortex')
session = next(x for x in sessions if len(one.list_datasets(x, collection='raw*')) > 5)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ pywin32; sys_platform == "win32"
PySocks
PyYAML
scipy
sounddevice
sounddevice

0 comments on commit 6da0a84

Please sign in to comment.