Skip to content

Commit

Permalink
Issue 71 use conda spec (#74)
Browse files Browse the repository at this point in the history
* added conda spec

* update vagrant example

* update docs

* added conda spec example

* fixed conda spec
  • Loading branch information
cehbrecht authored Mar 12, 2019
1 parent a296b43 commit 8b77465
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3 deletions.
19 changes: 19 additions & 0 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ You can also add your custom configurations to the ``etc/`` folder to stay away
$ vim etc/custom-emu.yml
$ ln -s etc/custom-emu.yml custom.yml
Use Conda to build identical environments
-----------------------------------------

You can use Conda specification files to build identical environments_.
The WPS service needs to have a specification file, ``spec-file.txt``, in its top level folder.
You can set the following option in your ``custom.yml``::

conda_env_use_spec: true

See an example in ``etc/sample-emu-with-conda-spec.yml``.

.. warning:: This is option is currently enabled for `all` configured WPS services.

.. note:: Conda spec files will work only on a specifc OS, in our case Linux.


.. _`environments`: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#building-identical-conda-environments


Use external PostgreSQL Database
--------------------------------

Expand Down
10 changes: 10 additions & 0 deletions etc/sample-emu-with-conda-spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# Conda spec
conda_env_use_spec: true
# Configuration for Emu WPS
wps_services:
- name: emu
# repo: https://github.com/bird-house/emu.git
# version: master
hostname: localhost
port: 5000
2 changes: 2 additions & 0 deletions etc/sample-vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ wps_enable_https: false
fs_enabled: false
# fs_host: "{{ server_name }}"
# fs_port: 5001
# Conda spec
# conda_env_use_spec: false
# Configuration for Emu WPS
wps_services:
- name: emu
Expand Down
24 changes: 21 additions & 3 deletions roles/pywps/tasks/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,34 @@
args:
chdir: "{{ src_dir }}/{{ item.name }}"
with_items: "{{ wps_services }}"
when: git.changed
register: conda
when: not conda_env_use_spec
register: conda_env
tags:
- pywps
- conda

- name: Install additional Conda packages.
command: "{{ conda_location }}/bin/conda install -y -p {{ conda_envs_dir}}/{{ item.name }} gunicorn psycopg2"
with_items: "{{ wps_services }}"
when: conda.changed
when: conda_env.changed
tags:
- pywps
- conda

- name: Remove Conda environment.
command: "{{ conda_location }}/bin/conda env remove -q -y -p {{ conda_envs_dir}}/{{ item.name }}"
with_items: "{{ wps_services }}"
when: conda_env_use_spec
tags:
- pywps
- conda

- name: Create Conda environment from spec-file.txt file.
command: "{{ conda_location }}/bin/conda create --file {{ conda_env_spec_file }} -p {{ conda_envs_dir}}/{{ item.name }}"
args:
chdir: "{{ src_dir }}/{{ item.name }}"
with_items: "{{ wps_services }}"
when: conda_env_use_spec
tags:
- pywps
- conda
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ miniconda_make_sys_default: False
# conda
conda_location: "{{ prefix }}/anaconda"
conda_envs_dir: "{{ conda_location }}/envs"
conda_env_use_spec: false
conda_env_spec_file: spec-file.txt
# supervisor
supervisor_user: root
supervisor_password: 'test'
Expand Down

0 comments on commit 8b77465

Please sign in to comment.