Skip to content

Commit 9996b27

Browse files
committed
rerun based on pykilosort version in log
1 parent 442dd4a commit 9996b27

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

ibllib/pipes/ephys_preprocessing.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from collections import OrderedDict
66
import traceback
77
from pathlib import Path
8+
import packaging.version
89

910
import numpy as np
1011
import pandas as pd
@@ -243,6 +244,14 @@ def _fetch_pykilosort_version(repo_path):
243244
pass
244245
return f"pykilosort_{version}"
245246

247+
@staticmethod
248+
def _fetch_pykilosort_run_version(log_file):
249+
with open(log_file) as fid:
250+
line = fid.readline()
251+
version = re.search('version (.*), output', line).group(1)
252+
253+
return f"pykilosort_{version}"
254+
246255
@staticmethod
247256
def _fetch_ks2_commit_hash(repo_path):
248257
command2run = f"git --git-dir {repo_path}/.git rev-parse --verify HEAD"
@@ -283,10 +292,13 @@ def _run_pykilosort(self, ap_file):
283292
sorter_dir = self.session_path.joinpath("spike_sorters", self.SPIKE_SORTER_NAME, label)
284293
FORCE_RERUN = False
285294
if not FORCE_RERUN:
286-
if sorter_dir.joinpath(f"spike_sorting_{self.SPIKE_SORTER_NAME}.log").exists():
287-
_logger.info(f"Already ran: spike_sorting_{self.SPIKE_SORTER_NAME}.log"
288-
f" found in {sorter_dir}, skipping.")
289-
return sorter_dir
295+
log_file = sorter_dir.joinpath(f"spike_sorting_{self.SPIKE_SORTER_NAME}.log")
296+
if log_file.exists():
297+
run_version = self._fetch_pykilosort_run_version(log_file)
298+
if packaging.version.parse(run_version) >= packaging.version.parse('pykilosort_ibl_1.1.0'):
299+
_logger.info(f"Already ran: spike_sorting_{self.SPIKE_SORTER_NAME}.log"
300+
f" found in {sorter_dir}, skipping.")
301+
return sorter_dir
290302
print(sorter_dir.joinpath(f"spike_sorting_{self.SPIKE_SORTER_NAME}.log"))
291303
# get the scratch drive from the shell script
292304
with open(self.SHELL_SCRIPT) as fid:

0 commit comments

Comments
 (0)