def test_initial(self): for strat, srp in self.rp[['T1w']]: anatomical_image = srp[R('T1w')] file_basename = PythonJob(function=basename) file_basename.path = anatomical_image srp[R('T1w', label='base')] = file_basename.path srp[R('T1w', label='dir')] = file_basename.dirname file_reversed = PythonJob(function=reversed_string) file_reversed.path = file_basename.path srp[R('T1w', label='baserev')] = file_reversed.reversed filename_subject_id = PythonJob(function=subject_id) filename_subject_id.filename = file_basename.path srp[R('T1w', label='sub')] = filename_subject_id.sub file_join_path = PythonJob(function=join_path) file_join_path.dirname = file_basename.dirname file_join_path.base = file_reversed.reversed srp[R('T1w', label='crazypath')] = file_join_path.path for executor in executors[1:]: res_rp = DependencySolver(self.rp).execute(executor=executor()) self.assertIn(R('sub-A00008326_ses-BAS1_label-base_T1w'), res_rp) self.assertEqual(res_rp[R('sub-A00008326_ses-BAS1_label-base_T1w')].content, A00008326_base) self.assertEqual(res_rp[R('sub-A00008326_ses-BAS1_label-baserev_T1w')].content, A00008326_base[::-1]) self.assertEqual(res_rp[R('sub-A00008326_ses-BAS1_label-sub_T1w')].content, 'sub-A00008326') self.assertEqual(res_rp[R('sub-A00008326_ses-BAS1_label-crazypath_T1w')].content, f'{A00008326_dir}/{A00008326_base[::-1]}') self.assertIn(R('sub-A00008399_ses-BAS1_label-base_T1w'), res_rp) self.assertEqual(res_rp[R('sub-A00008399_ses-BAS1_label-base_T1w')].content, A00008399_base) self.assertEqual(res_rp[R('sub-A00008399_ses-BAS1_label-baserev_T1w')].content, A00008399_base[::-1]) self.assertEqual(res_rp[R('sub-A00008399_ses-BAS1_label-sub_T1w')].content, 'sub-A00008399') self.assertEqual(res_rp[R('sub-A00008399_ses-BAS1_label-crazypath_T1w')].content, f'{A00008399_dir}/{A00008399_base[::-1]}')
def test_intermediary(self): for strat, srp in self.rp[[ R('T1w'), ]]: anatomical_image = srp[R('T1w')] file_basename = PythonJob(function=basename) file_basename.path = anatomical_image srp[R('T1w', label='base')] = file_basename.path srp[R('T1w', label='dir')] = file_basename.dirname file_reversed = PythonJob(function=reversed_string) file_reversed.path = file_basename.path filename_subject_id = PythonJob(function=subject_id) filename_subject_id.filename = file_basename.path file_join_path = PythonJob(function=join_path) file_join_path.dirname = file_basename.dirname file_join_path.base = file_reversed.reversed srp[R('T1w', label='crazypath')] = file_join_path.path # Create footprint for file_reversed, filename_subject_id and file_join_path # Since file_join_path is cached, file_reversed and filename_subject_id should not execute # # * Requires a ExecutionLogger # * Maybe this policy could be parametrized res_rp = DependencySolver(self.rp).execute(executor=Execution()) self.assertIn(R('sub-A00008326_ses-BAS1_label-base_T1w'), res_rp) self.assertEqual(res_rp[R('sub-A00008326_ses-BAS1_label-crazypath_T1w')].content, f'{A00008326_dir}/{A00008326_base[::-1]}') self.assertIn(R('sub-A00008399_ses-BAS1_label-base_T1w'), res_rp) self.assertEqual(res_rp[R('sub-A00008399_ses-BAS1_label-crazypath_T1w')].content, f'{A00008399_dir}/{A00008399_base[::-1]}')