Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #132 from deNBI/dev
Browse files Browse the repository at this point in the history
refactor(bioconda): playbook tasks now idempotent (#128)
  • Loading branch information
dweinholz authored Aug 28, 2019
2 parents f7cede3 + c644452 commit fc4fef6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
18 changes: 15 additions & 3 deletions VirtualMachineService/ancon/Playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,21 @@ def copy_and_init(self, playbook_name, playbook_vars):
def load_vars():
if playbook_name == BIOCONDA:
for k, v in playbook_vars.items():
if k == "string_line":
data[playbook_name + "_tools"][k] = v.strip('\"')
data[playbook_name + "_tools"]["timeout_length"] = str(len(v.split()) * 5) + "m"
if k == "packages":
p_array = []
p_dict = {}
for p in (v.strip('\"')).split():
p_array.append(p.split("="))
for p in p_array:
p_dict.update(
{
p[0]: {
"version": p[1],
"build": p[2]
}
}
)
data[playbook_name + "_tools"][k] = p_dict
if playbook_name == THEIA:
for k, v in playbook_vars.items():
if k == "version":
Expand Down
35 changes: 32 additions & 3 deletions VirtualMachineService/ancon/playbooks/bioconda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,53 @@
dest: "{{ bioconda_folders.install_script }}"
mode: 0755
timeout: 180
force: no

- name: Install miniconda
shell: "timeout 3m {{ bioconda_folders.install_script }} -b"
args:
executable: /bin/bash
creates: "{{ bioconda_folders.conda_dir }}"

- name: Add channels
shell: "timeout 2m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda config --add channels default && conda config --add channels bioconda && conda config --add channels conda-forge'"
- name: Check for channels
shell: "timeout 1m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda config --get channels'"
register: added_channels

- name: Add default channel
shell: "timeout 1m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda config --add channels default'"
args:
executable: /bin/bash
when: added_channels.stdout.find('default') == -1

- name: Add bioconda channel
shell: "timeout 1m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda config --add channels bioconda'"
args:
executable: /bin/bash
when: added_channels.stdout.find('bioconda') == -1

- name: Add conda-forge channel
shell: "timeout 1m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda config --add channels conda-forge'"
args:
executable: /bin/bash
when: added_channels.stdout.find('conda-forge') == -1

- name: Check for environment
shell: "timeout 1m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda info -e'"
register: added_envs

- name: Create environment
shell: "timeout 2m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda create --yes -n {{ bioconda_tools.env }}'"
args:
executable: /bin/bash
when: added_envs.stdout.find(bioconda_tools.env) == -1

- name: Check for installed packages
shell: "timeout 1m bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda activate {{ bioconda_tools.env }} && conda list'"
register: added_packages

- name: Install chosen packages
shell: "timeout {{ bioconda_tools.timeout_length }} bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda activate {{ bioconda_tools.env }} && conda install --yes {{ bioconda_tools.string_line }}'"
shell: "timeout {{ bioconda_tools.timeout_length }} bash -c 'source {{ bioconda_folders.conda_dir }}/bin/activate && conda activate {{ bioconda_tools.env }} && conda install --yes {{ item.key }}={{ item.value.version }}={{ item.value.build }}'"
args:
executable: /bin/bash
loop: "{{ lookup('dict', bioconda_tools.packages) }}"
when: added_packages.stdout.find(item.key) == -1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bioconda_tools:
string_line: ""
packages:
env: "denbi"
timeout_length: "5m"

Expand Down

0 comments on commit fc4fef6

Please sign in to comment.