|
9 | 9 | from typing import List, Union |
10 | 10 |
|
11 | 11 | import datajoint as dj |
12 | | -from datajoint import FreeTable |
13 | | -from datajoint import config as dj_config |
14 | 12 | from pynwb import NWBHDF5IO |
15 | 13 |
|
16 | 14 | from spyglass.common.common_nwbfile import AnalysisNwbfile, Nwbfile |
17 | | -from spyglass.settings import export_dir, test_mode |
| 15 | +from spyglass.settings import test_mode |
18 | 16 | from spyglass.utils import SpyglassMixin, SpyglassMixinPart, logger |
19 | 17 | from spyglass.utils.dj_graph import RestrGraph |
20 | 18 | from spyglass.utils.dj_helper_fn import ( |
@@ -174,7 +172,6 @@ def list_file_paths(self, key: dict, as_dict=True) -> list[str]: |
174 | 172 | Return as a list of dicts: [{'file_path': x}]. Default True. |
175 | 173 | If False, returns a list of strings without key. |
176 | 174 | """ |
177 | | - file_table = self * self.File & key |
178 | 175 | unique_fp = { |
179 | 176 | *[ |
180 | 177 | AnalysisNwbfile().get_abs_path(p) |
@@ -210,21 +207,26 @@ def _add_externals_to_restr_graph( |
210 | 207 | restr_graph : RestrGraph |
211 | 208 | The updated RestrGraph |
212 | 209 | """ |
213 | | - raw_tbl = self._externals["raw"] |
214 | | - raw_name = raw_tbl.full_table_name |
215 | | - raw_restr = ( |
216 | | - "filepath in ('" + "','".join(self._list_raw_files(key)) + "')" |
217 | | - ) |
218 | | - restr_graph.graph.add_node(raw_name, ft=raw_tbl, restr=raw_restr) |
219 | | - |
220 | | - analysis_tbl = self._externals["analysis"] |
221 | | - analysis_name = analysis_tbl.full_table_name |
222 | | - analysis_restr = ( # filepaths have analysis subdir. regexp substrings |
223 | | - "filepath REGEXP '" + "|".join(self._list_analysis_files(key)) + "'" |
224 | | - ) # regexp is slow, but we're only doing this once, and future-proof |
225 | | - restr_graph.graph.add_node( |
226 | | - analysis_name, ft=analysis_tbl, restr=analysis_restr |
227 | | - ) |
| 210 | + |
| 211 | + if raw_files := self._list_raw_files(key): |
| 212 | + raw_tbl = self._externals["raw"] |
| 213 | + raw_name = raw_tbl.full_table_name |
| 214 | + raw_restr = "filepath in ('" + "','".join(raw_files) + "')" |
| 215 | + restr_graph.graph.add_node(raw_name, ft=raw_tbl, restr=raw_restr) |
| 216 | + restr_graph.visited.add(raw_name) |
| 217 | + |
| 218 | + if analysis_files := self._list_analysis_files(key): |
| 219 | + analysis_tbl = self._externals["analysis"] |
| 220 | + analysis_name = analysis_tbl.full_table_name |
| 221 | + # to avoid issues with analysis subdir, we use REGEXP |
| 222 | + # this is slow, but we're only doing this once, and future-proof |
| 223 | + analysis_restr = ( |
| 224 | + "filepath REGEXP '" + "|".join(analysis_files) + "'" |
| 225 | + ) |
| 226 | + restr_graph.graph.add_node( |
| 227 | + analysis_name, ft=analysis_tbl, restr=analysis_restr |
| 228 | + ) |
| 229 | + restr_graph.visited.add(analysis_name) |
228 | 230 |
|
229 | 231 | restr_graph.visited.update({raw_name, analysis_name}) |
230 | 232 |
|
|
0 commit comments