Open pmenzel opened 2 years ago
Users sharing conda environments is a tricky situation.
One way to handle it is to alter tb-profiler to use a user-local version of the database first, and if that does not exist, use the global ome.
The local place would normally be $HOME/.local/share/tb-profiler/
folder.
Oh yeah that is a good idea.
Is there any situation in which tb-profiler wouldn't have permission to create/write to $HOME/.local/share/tb-profiler/
? or is .local
a pretty safe bet, permissions-wise?
This is a fringe issue that I ran into when running TB-profiler through a conda installation that is shared by multiple users. I just want to write it down for posterity, so that the error message can be found by others (or myself) in the future.
Steps:
Next, user Y, using the same miniconda3 installation, runs a snakemake workflow containing a rule that loads a conda yaml file, which also contains tb-profiler 4.2.0, using
snakemake --use-conda --conda-prefix /opt/conda/by-snakemake ...
, and executes the commandtb-profiler update_tbdb --branch who
.This will result in the error:
Running command: set -u pipefail; git clone https://github.com/jodyphelan/tbdb.git
Running command: set -u pipefail; git checkout who
Running command: set -u pipefail; git pull
Running command: set -u pipefail; tb-profiler create_db --load Traceback (most recent call last): File "/opt/conda/by-snakemake/17feee8282d3b1f4544d1531017653a2/bin/tb-profiler", line 566, in
args.func(args)
File "/opt/conda/by-snakemake/17feee8282d3b1f4544d1531017653a2/bin/tb-profiler", line 200, in main_update_tbdb
pp.run_cmd("tb-profiler create_db %s --load" % tmp)
File "/opt/conda/by-snakemake/17feee8282d3b1f4544d1531017653a2/lib/python3.9/site-packages/pathogenprofiler/utils.py", line 391, in run_cmd
raise ValueError("Command Failed:\n%s\nstderr:\n%s" % (cmd,stderr.decode()))
ValueError: Command Failed:
set -u pipefail; tb-profiler create_db --load
stderr:
ESC[94mConverting 580 mutationsESC[0m
Running command: set -u pipefail; snpEff ann Mycobacterium_tuberculosis_h37rv 0eacf2ff-ac5e-426e-8a20-1fc06504de2e ESC[94mConverting 689 mutationsESC[0m
Running command: set -u pipefail; snpEff ann Mycobacterium_tuberculosis_h37rv 6c7cb704-1f82-4e16-b5ad-ac54eee90c18
Running command: set -u pipefail; git log | head -4 ESC[94mCopying file: tbdb.fasta ---> /opt/conda/by-snakemake/17feee8282d3b1f4544d1531017653a2/share/tbprofiler/tbdb.fastaESC[0m Traceback (most recent call last): File "/opt/conda/by-snakemake/17feee8282d3b1f4544d1531017653a2/bin/tb-profiler", line 566, in
args.func(args)
File "/opt/conda/by-snakemake/17feee8282d3b1f4544d1531017653a2/bin/tb-profiler", line 210, in main_create_db
pp.create_db(args,extra_files=extra_files)
File "/opt/conda/by-snakemake/17feee8282d3b1f4544d1531017653a2/lib/python3.9/site-packages/pathogenprofiler/db.py", line 679, in create_db
shutil.copy(val,target)
File "/opt/conda/by-snakemake/17feee8282d3b1f4544d1531017653a2/lib/python3.9/shutil.py", line 428, in copy
copymode(src, dst, follow_symlinks=follow_symlinks)
File "/opt/conda/by-snakemake/17feee8282d3b1f4544d1531017653a2/lib/python3.9/shutil.py", line 317, in copymode
chmod_func(dst, stat.S_IMODE(st.st_mode))
PermissionError: [Errno 1] Operation not permitted: '/opt/conda/by-snakemake/17feee8282d3b1f4544d1531017653a2/share/tbprofiler/tbdb.fasta'
Cleaning up after failed run
[...]