From 81481d000b3241eee0f5a5722f0279ece92d1e96 Mon Sep 17 00:00:00 2001 From: chris-langfield Date: Tue, 30 Jul 2024 09:49:39 -0400 Subject: [PATCH] Revert "test forcing subprocess for large_jobs" This reverts commit 31ff95dc5de1899b813fa8cbd948de6d73472364. --- ibllib/pipes/ephys_tasks.py | 47 ++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/ibllib/pipes/ephys_tasks.py b/ibllib/pipes/ephys_tasks.py index 25bb4707a..ee5a0c8e6 100644 --- a/ibllib/pipes/ephys_tasks.py +++ b/ibllib/pipes/ephys_tasks.py @@ -656,27 +656,32 @@ def _run_iblsort(self, ap_file): _logger.info(f"job progress command: tail -f {temp_dir} *.log") temp_dir.mkdir(parents=True, exist_ok=True) check_nvidia_driver() - command2run = f"{self.SHELL_SCRIPT} {ap_file} {temp_dir}" - _logger.info(command2run) - process = subprocess.Popen( - command2run, - shell=True, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - executable="/bin/bash", - ) - info, error = process.communicate() - info_str = info.decode("utf-8").strip() - _logger.info(info_str) - if process.returncode != 0: - error_str = error.decode("utf-8").strip() - # try and get the kilosort log if any - for log_file in temp_dir.rglob('*_kilosort.log'): - with open(log_file) as fid: - log = fid.read() - _logger.error(log) - break - raise RuntimeError(f"{self.SPIKE_SORTER_NAME} {info_str}, {error_str}") + try: + # if pykilosort is in the environment, use the installed version within the task + import iblsorter.ibl # noqa + iblsorter.ibl.run_spike_sorting_ibl(bin_file=ap_file, scratch_dir=temp_dir) + except ImportError: + command2run = f"{self.SHELL_SCRIPT} {ap_file} {temp_dir}" + _logger.info(command2run) + process = subprocess.Popen( + command2run, + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + executable="/bin/bash", + ) + info, error = process.communicate() + info_str = info.decode("utf-8").strip() + _logger.info(info_str) + if process.returncode != 0: + error_str = error.decode("utf-8").strip() + # try and get the kilosort log if any + for log_file in temp_dir.rglob('*_kilosort.log'): + with open(log_file) as fid: + log = fid.read() + _logger.error(log) + break + raise RuntimeError(f"{self.SPIKE_SORTER_NAME} {info_str}, {error_str}") shutil.copytree(temp_dir.joinpath('output'), sorter_dir, dirs_exist_ok=True) shutil.rmtree(temp_dir, ignore_errors=True)