Skip to content

Add logic in case conda call doesn't work

John Douglas Veitch requested to merge conda_check into master

@ann-kristin.malz and I have encountered the situation where bilby is running in a conda env, but it doesn't have access to the conda executable. This scenario happens when the conda env is created on a head machine, but then used via condor on a cluster where each node doesn't have conda installed. This causes a crash in current master, with the log

Traceback (most recent call last):
  File "/data/wiay/undergrads/2406354m/mybilby/bilby/examples/gw_examples/injection_examples/fast_tutorial.py", line 115, in <module>
    result = bilby.run_sampler(
  File "/data/wiay/undergrads/2406354m/mybilby/bilby/bilby/core/sampler/__init__.py", line 178, in run_sampler
    meta_data["environment_packages"] = env_package_list(as_dataframe=True)
  File "/data/wiay/undergrads/2406354m/mybilby/bilby/bilby/core/utils/log.py", line 103, in env_package_list
    pkgs = json.loads(subprocess.check_output([
  File "/data/wiay/conda_envs/undergrads/2406354m/project_mybilby/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/data/wiay/conda_envs/undergrads/2406354m/project_mybilby/lib/python3.9/subprocess.py", line 505, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/data/wiay/conda_envs/undergrads/2406354m/project_mybilby/lib/python3.9/subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/data/wiay/conda_envs/undergrads/2406354m/project_mybilby/lib/python3.9/subprocess.py", line 1821, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'conda'

This MR adds some exception handling for this case, which will cause it to fall back to using pip (which has its own exception handling already).

Merge request reports

Loading