33import os
44import sys
55from pathlib import Path
6- from typing import Callable , Dict , List , Optional , Union
6+ from typing import List , Optional , Union
77
88import aind_behavior_services .rig as AbsRig
99import git
1717from clabe .apps import CurriculumSuggestion
1818from clabe .data_mapper import aind_data_schema as ads
1919from clabe .data_mapper import helpers as data_mapper_helpers
20- from clabe .launcher import Launcher
2120
2221from aind_behavior_vr_foraging .rig import AindVrForagingRig
2322from aind_behavior_vr_foraging .task_logic import AindVrForagingTaskLogic
3029class AindSessionDataMapper (ads .AindDataSchemaSessionDataMapper ):
3130 def __init__ (
3231 self ,
33- session_model : AindBehaviorSessionModel ,
34- rig_model : AindVrForagingRig ,
35- task_logic_model : AindVrForagingTaskLogic ,
32+ session : AindBehaviorSessionModel ,
33+ rig : AindVrForagingRig ,
34+ task_logic : AindVrForagingTaskLogic ,
3635 repository : Union [os .PathLike , git .Repo ] = Path ("." ),
3736 script_path : os .PathLike = Path ("./src/main.bonsai" ),
3837 session_end_time : Optional [datetime .datetime ] = None ,
3938 curriculum_suggestion : Optional [CurriculumSuggestion ] = None ,
40- output_parameters : Optional [Dict ] = None ,
4139 ):
42- self .session_model = session_model
43- self .rig_model = rig_model
44- self .task_logic_model = task_logic_model
40+ self .session_model = session
41+ self .rig_model = rig
42+ self .task_logic_model = task_logic
4543 self .repository = repository
4644 if isinstance (self .repository , os .PathLike | str ):
4745 self .repository = git .Repo (Path (self .repository ))
4846 self .script_path = script_path
4947 self ._session_end_time = session_end_time
50- self .output_parameters = output_parameters
5148 self ._mapped : Optional [acquisition .Acquisition ] = None
5249 self .curriculum = curriculum_suggestion
5350
@@ -60,28 +57,6 @@ def session_end_time(self) -> datetime.datetime:
6057 def session_schema (self ):
6158 return self .mapped
6259
63- @classmethod
64- def build_runner (
65- cls ,
66- curriculum_suggestion : Optional [Callable [[], CurriculumSuggestion | None ]] = None ,
67- ) -> Callable [
68- [Launcher [AindVrForagingRig , AindBehaviorSessionModel , AindVrForagingTaskLogic ]], "AindSessionDataMapper"
69- ]:
70- def _new (
71- launcher : Launcher [AindVrForagingRig , AindBehaviorSessionModel , AindVrForagingTaskLogic ],
72- ) -> "AindSessionDataMapper" :
73- new = cls (
74- session_model = launcher .get_session (strict = True ),
75- rig_model = launcher .get_rig (strict = True ),
76- task_logic_model = launcher .get_task_logic (strict = True ),
77- repository = launcher .repository ,
78- curriculum_suggestion = curriculum_suggestion () if curriculum_suggestion is not None else None ,
79- )
80- new .map ()
81- return new
82-
83- return _new
84-
8560 @property
8661 def session_name (self ) -> str :
8762 if self .session_model .session_name is None :
@@ -97,7 +72,7 @@ def mapped(self) -> acquisition.Acquisition:
9772 def is_mapped (self ) -> bool :
9873 return self .mapped is not None
9974
100- def map (self ) -> Optional [ acquisition .Acquisition ] :
75+ def map (self ) -> acquisition .Acquisition :
10176 logger .info ("Mapping aind-data-schema Session." )
10277 try :
10378 self ._mapped = self ._map ()
@@ -120,7 +95,7 @@ def _map(self) -> acquisition.Acquisition:
12095 acquisition_end_time = utcnow (),
12196 acquisition_start_time = self .session_model .date ,
12297 experimenters = self .session_model .experimenter ,
123- acquisition_type = self .session_model .experiment ,
98+ acquisition_type = self .session_model .experiment or self . task_logic_model . name ,
12499 coordinate_system = _make_origin_coordinate_system (),
125100 data_streams = self ._get_data_streams (),
126101 calibrations = self ._get_calibrations (),
@@ -245,7 +220,7 @@ def _get_stimulus_epochs(self) -> List[acquisition.StimulusEpoch]:
245220 stimulus_start_time = self .session_model .date ,
246221 stimulus_end_time = self .session_end_time ,
247222 configurations = stimulus_epoch_configurations ,
248- stimulus_name = self .session_model .experiment ,
223+ stimulus_name = self .session_model .experiment or self . task_logic_model . name ,
249224 stimulus_modalities = stimulus_modalities ,
250225 performance_metrics = performance_metrics ,
251226 curriculum_status = curriculum_status ,
0 commit comments