Skip to content

Commit

Permalink
Issue #514 - Fix for error when calling transfer_data without a local…
Browse files Browse the repository at this point in the history
… path
  • Loading branch information
k1o0 committed Sep 29, 2023
1 parent 351f7a2 commit 90b06c9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Changelog

-------------------------------

8.10.2
------
* hot-fix parsing of path args in transfer_data

8.10.1
------
* more reliable way to check for dirty repository
Expand Down
2 changes: 1 addition & 1 deletion iblrig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# 3) Check CI and eventually wet lab test
# 4) Pull request to iblrigv8
# 5) git tag the release in accordance to the version number below (after merge!)
__version__ = '8.10.1'
__version__ = '8.10.2'

# The following method call will try to get post-release information (i.e. the number of commits since the last tagged
# release corresponding to the one above), plus information about the state of the local repository (dirty/broken)
Expand Down
9 changes: 7 additions & 2 deletions iblrig/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ def transfer_data(local_path=None, remote_path=None, dry=False):
"""
Copies the behavior data from the rig to the local server if the session has more than 42 trials
If the hardware settings file contains MAIN_SYNC=True, the number of expected devices is set to 1
:param local_path: local path to the subjects folder
:param weeks:
:param local_path: local path to the subjects folder, otherwise uses the local_data_folder key in
the iblrig_settings.yaml file, or the iblrig_data directory in the home path.
:param dry:
:return:
"""
# If paths not passed, uses those defined in the iblrig_settings.yaml file
rig_paths = get_local_and_remote_paths(local_path=local_path, remote_path=remote_path)
local_path = rig_paths.local_subjects_folder
remote_path = rig_paths.remote_subjects_folder
assert isinstance(local_path, Path) # get_local_and_remote_paths should always return Path obj

hardware_settings = load_settings_yaml('hardware_settings.yaml')
number_of_expected_devices = 1 if hardware_settings.get('MAIN_SYNC', True) else None

Expand Down
11 changes: 11 additions & 0 deletions iblrig/test/test_transfers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import random
import tempfile
import unittest
from unittest import mock

from ibllib.io import session_params

Expand Down Expand Up @@ -63,6 +64,16 @@ def test_behavior_copy_complete_session(self):
remote_subjects_folder=session.paths.REMOTE_SUBJECT_FOLDER)
self.assertEqual(sc.state, 3)

# Check that the settings file is used when no path passed
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as td:
session = _create_behavior_session(td, ntrials=50, hard_crash=hard_crash)
session.paths.SESSION_FOLDER.joinpath('transfer_me.flag').touch()
with mock.patch('iblrig.path_helper.load_settings_yaml', return_value=session.iblrig_settings):
iblrig.commands.transfer_data()
sc = BehaviorCopier(session_path=session.paths.SESSION_FOLDER,
remote_subjects_folder=session.paths.REMOTE_SUBJECT_FOLDER)
self.assertEqual(sc.state, 3)

def test_behavior_do_not_copy_dummy_sessions(self):
"""
Here we test the case when an aborted session or a session with less than 42 trials attempts to be copied
Expand Down

0 comments on commit 90b06c9

Please sign in to comment.