restructure extra requirement handling in run_sorter_container
@@ -233,6 +233,10 @@ def run_sorter_container(sorter_name, recording, mode, container_image, output_f
remove_existing_folder=True, delete_output_folder=False,
verbose=False, raise_error=True, with_output=True,
extra_requirements=None, **sorter_params):
+
+ if extra_requirements is None:
+ extra_requirements = []
+
# common code for docker and singularity
if output_folder is None:
output_folder = sorter_name + '_output'
@@ -323,17 +327,12 @@ run_sorter_local('{sorter_name}', recording, output_folder=output_folder,
res_output += str(container_client.run_command(cmd))
need_si_install = 'ModuleNotFoundError' in res_output
- cmd = 'pip install --upgrade --no-input nixio'
- res_output = container_client.run_command(cmd)
-
if need_si_install:
if 'dev' in si_version:
if verbose:
print(f"Installing spikeinterface from sources in {container_image}")
- # TODO later check output
- cmd = 'pip install --upgrade --no-input MEArec'
- res_output = container_client.run_command(cmd)
+ # TODO later check output
if install_si_from_source:
si_source = 'local machine'
res_output = container_client.run_command(f'cp -rf {si_dev_path_unix} /opt')
@@ -348,8 +347,7 @@ run_sorter_local('{sorter_name}', recording, output_folder=output_folder,
res_output = container_client.run_command(cmd)
else:
if verbose:
- print(
- f"Installing spikeinterface=={si_version} in {container_image}")
+ print(f"Installing spikeinterface=={si_version} in {container_image}")
cmd = f'pip install --upgrade --no-input spikeinterface[full]=={si_version}'
res_output = container_client.run_command(cmd)
else:
@@ -360,15 +358,12 @@ run_sorter_local('{sorter_name}', recording, output_folder=output_folder,
if hasattr(recording, 'extra_requirements'):
extra_requirements.extend(recording.extra_requirements)
- # execute custom pre-run code from file or string, e.g. to install missing dependencies
- if extra_requirements is None:
- pass
- elif Path(extra_requirements).exists():
- with open(extra_requirements, 'r') as f:
- cmd = f"pip install {' '.join(f.readlines())}"
- res_output = container_client.run_command(cmd)
- else:
- cmd = f"pip install {' '.join(extra_requirements)}"
+ if verbose:
+ print(f'Installing extra requirements: {extra_requirements}')
+
+ # install additional required dependencies
+ if extra_requirements:
+ cmd = f"pip install --upgrade --no-input {' '.join(extra_requirements)}"
res_output = container_client.run_command(cmd)
# run sorter on folder
