-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from AllenNeuralDynamics:update-to-aind-behavi…
…or-service-09x Update to aind-behavior-services 0.9 and add watchdog
- Loading branch information
Showing
13 changed files
with
583 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "aind-behavior-force-foraging" | ||
description = "A library that defines AIND data schema for the Aind Behavior Force Foraing experiment." | ||
description = "A library that defines AIND data schema for the Aind Behavior Force Foraging experiment." | ||
authors = [ | ||
{ name = "Bruno Cruz", email = "[email protected]" }, | ||
] | ||
|
@@ -19,7 +19,7 @@ readme = "README.md" | |
dynamic = ["version"] | ||
|
||
dependencies = [ | ||
"aind_behavior_services>=0.8, <0.9", | ||
"aind_behavior_services>=0.9, <0.10", | ||
] | ||
|
||
[project.urls] | ||
|
@@ -30,7 +30,7 @@ Changelog = "https://github.com/AllenNeuralDynamics/Aind.Behavior.ForceForaging/ | |
|
||
[project.optional-dependencies] | ||
|
||
launcher = ["aind_behavior_experiment_launcher[aind-services]>=0.2, <0.3"] | ||
launcher = ["aind_behavior_experiment_launcher[aind-services]>=0.3, <0.4"] | ||
|
||
dev = [ | ||
"aind_behavior_force_foraging[launcher]", | ||
|
414 changes: 414 additions & 0 deletions
414
src/DataSchemas/aind_behavior_force_foraging/data_mappers.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import sys | ||
import unittest | ||
from datetime import datetime | ||
from pathlib import Path | ||
from unittest.mock import MagicMock, patch | ||
|
||
from aind_behavior_force_foraging.data_mappers import ( | ||
AindRigDataMapper, | ||
AindSessionDataMapper, | ||
) | ||
from aind_data_schema.core.rig import Rig | ||
from git import Repo | ||
|
||
sys.path.append(".") | ||
from examples.example_roi_trial_type import mock_rig, mock_session, mock_task_logic # isort:skip # pylint: disable=wrong-import-position | ||
|
||
|
||
class TestAindSessionDataMapper(unittest.TestCase): | ||
def setUp(self): | ||
self.session_model = mock_session() | ||
self.rig_model = mock_rig() | ||
self.task_logic_model = mock_task_logic() | ||
self.repository = Repo(Path("./")) | ||
self.script_path = Path("./src/main.bonsai") | ||
self.session_end_time = datetime.now() | ||
self.session_directory = None | ||
|
||
self.mapper = AindSessionDataMapper( | ||
session_model=self.session_model, | ||
rig_model=self.rig_model, | ||
task_logic_model=self.task_logic_model, | ||
repository=self.repository, | ||
script_path=self.script_path, | ||
session_end_time=self.session_end_time, | ||
) | ||
|
||
@patch("aind_behavior_force_foraging.data_mappers.AindSessionDataMapper._map") | ||
def test_mock_map(self, mock_map): | ||
mock_map.return_value = MagicMock() | ||
result = self.mapper.map() | ||
self.assertIsNotNone(result) | ||
self.assertTrue(self.mapper.is_mapped()) | ||
|
||
def test_map(self): | ||
mapped = self.mapper.map() | ||
self.assertIsNotNone(mapped) | ||
|
||
|
||
class TestAindRigDataMapper(unittest.TestCase): | ||
def setUp(self): | ||
self.rig_schema_filename = "rig_schema.json" | ||
self.db_root = MagicMock() | ||
self.session_directory = MagicMock() | ||
self.db_suffix = "test_suffix" | ||
self.mapper = AindRigDataMapper( | ||
rig_schema_filename=self.rig_schema_filename, | ||
db_root=self.db_root, | ||
db_suffix=self.db_suffix, | ||
) | ||
|
||
@patch("pathlib.Path.exists", return_value=True) | ||
@patch("aind_behavior_force_foraging.data_mappers.model_from_json_file") | ||
def test_mock_map(self, mock_model_from_json_file, mock_path_exists): | ||
mock_model_from_json_file.return_value = MagicMock(spec=Rig) | ||
result = self.mapper.map() | ||
self.assertIsNotNone(result) | ||
self.assertTrue(self.mapper.mapped) | ||
self.assertIsInstance(result, Rig) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.