Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert options from json to yaml #34

Merged
merged 7 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ sequenceserver_blast_db:
users: ['fbar','jsmith']
web_page_title: 'blablabla'
placeholders: [{key: 'key1', value: 'value1'}, {key: 'key2', value: 'value2'}]
conf_options: [{key: 'job_lifetime', value: '10080'}, {key: 'databases_widget', value: 'tree'}, {key: 'options', value: {'blastn': {'default': ['-task blastn', '-evalue 1e-5'], 'short-seq': ['-task blastn-short', '-evalue 1e-1']}}}]
```
This is the variable used to define the BLAST databases.

Expand All @@ -55,7 +56,7 @@ Each database is defined as a dictionary of the following parameters:
- `group` Optional. Useful if the database needs restricted access. An LDAP group ("gid"). LDAP users who are member of this group will have access to the database.
- `web_page_title` Optional. The title displayed at the top of the web page. If not provided, the default title is "BLAST server for `name`".
- `placeholders` Optional. A list of placeholder dictionaries `{key: 'key_item', value: 'value_item'}` that are used to customize top or bottom supplementary HTML code (see `sequenceserver_top_web_page_html_path` and `sequenceserver_bottom_web_page_html_path`). For example `placeholders: [{key: 'key1', value: 'value1'}, {key: 'key2', value: 'value2'}]`.
- `conf_options` Optional. A list of supplementary SequenceServer configuration options dictionaries `{key: 'key_item', value: 'value_item'}` (see [SequenceServer documentation](https://sequenceserver.com/doc/#basics)). For example `conf_options: [{key: 'job_lifetime', value: '10080'}, {key: 'databases_widget', value: 'tree'}]`.
- `conf_options` Optional. A list of supplementary SequenceServer configuration options as dictionaries `{key: 'key_item', value: 'value_item'}` (see [SequenceServer documentation](https://sequenceserver.com/doc/#basics)). For example `[{key: 'job_lifetime', value: '10080'}, {key: 'databases_widget', value: 'tree'}, {key: 'options', value: {'blastn': {'default': ['-task blastn', '-evalue 1e-5'], 'short-seq': ['-task blastn-short', '-evalue 1e-1']}}}]`

Unique `name` and `port` are mandatory for each database.
`users`, `ldap_businesscategory` and `group` are optional and can be used to add an authentication layer with the nginx-auth-ldap module. Choose one single authentication mode for each database.
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
port: '4567'
path: '/tmp/test-data'
placeholders: [{key: 'key_string', value: 'value1'}, {key: 'key_link', value: '<a href="http://testplaceholder.com">my favorite link</a>'}]
conf_options: [{key: 'job_lifetime', value: '10080'}, {key: 'databases_widget', value: 'tree'}]
conf_options: [{key: 'job_lifetime', value: '10080'}, {key: 'databases_widget', value: 'tree'}, {key: 'options', value: {'blastn': {'default': ['-task blastn', '-evalue 1e-5'], 'short-seq': ['-task blastn-short', '-evalue 1e-1']}}}]
sequenceserver_top_web_page_html_path: "/tmp/top_web_page.html"
sequenceserver_bottom_web_page_html_path: "/tmp/bottom_web_page.html"
sequenceserver_home_url: "http://myfavoritewebsite.com"
Expand Down
22 changes: 11 additions & 11 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
become: true
tasks:
- name: Test blast installation
shell: # noqa 301 305

Check warning on line 7 in molecule/default/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

7:14 [comments] too few spaces before comment
cmd: "/usr/local/anaconda/envs/blast/bin/blastn -version"
register: blast_command
failed_when: blast_command.rc > 0
- name: Test my_db
shell: # noqa 301 305

Check warning on line 12 in molecule/default/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

12:14 [comments] too few spaces before comment
cmd: "/usr/local/anaconda/envs/blast/bin/blastdbcmd -db /tmp/test-data/my_db -entry all"
register: blastdbcmd_command
failed_when: blastdbcmd_command.rc > 0
- name: Ubuntu 20 | Test SequenceServer installation
shell: # noqa 301

Check warning on line 17 in molecule/default/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

17:14 [comments] too few spaces before comment
cmd: "export GEM_PATH=/usr/local/share/gems && /usr/local/share/gems/bin/sequenceserver --version"
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "20"
register: sequenceserver_command
Expand All @@ -26,6 +26,17 @@
- name: Display SequenceServer service logs
debug:
msg: "{{ log.content | b64decode }}"
- name: Get the SequenceServer configuration file of my_db
slurp:
src: "/etc/sequenceserver/config/sequenceserver.my_db.conf"
register: my_db_conf
- name: Display content of the SequenceServer configuration file of my_db
debug:
msg: "{{ my_db_conf.content | b64decode }}"
- name: Check that conf_option is in the SequenceServer configuration file of my_db
set_fact:
grep_slurm_batch: "{{ my_db_conf.content | b64decode | regex_findall('databases_widget') | first }}"
failed_when: grep_slurm_batch != 'databases_widget'
- name: Test that SequenceServer service is running for my_db
systemd:
name: sequenceserver-my_db.service
Expand All @@ -35,8 +46,8 @@
get_url:
url: "http://localhost"
dest: "/tmp/nginx.html"
- name: Test SequenceServer home page with curl # same thing tried with the ansible get_url module without success

Check warning on line 49 in molecule/default/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

49:53 [comments] too few spaces before comment
shell: # noqa 301

Check warning on line 50 in molecule/default/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

50:14 [comments] too few spaces before comment
cmd: "curl -sL http://localhost:4567 -o /tmp/home.html"
register: sequenceserver_command
failed_when: sequenceserver_command.rc > 0
Expand All @@ -48,27 +59,27 @@
debug:
msg: "{{ sequenceserver_page.content | b64decode }}"
- name: Check title in home page content
shell: # noqa 301

Check warning on line 62 in molecule/default/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

62:14 [comments] too few spaces before comment
cmd: curl -sL http://localhost:4567 | grep -q 'http://myfavoritewebsite.com'
register: grep_title
failed_when: grep_title.rc > 0
- name: Check support email in home page content
shell: # noqa 301

Check warning on line 67 in molecule/default/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

67:14 [comments] too few spaces before comment
cmd: curl -sL http://localhost:4567 | grep -q 'mailto:[email protected]'
register: grep_support
failed_when: grep_support.rc > 0
- name: Check custom html in home page content (top)
shell: # noqa 301

Check warning on line 72 in molecule/default/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

72:14 [comments] too few spaces before comment
cmd: curl -sL http://localhost:4567 | grep -q 'My message'
register: grep_custom_html_top
failed_when: grep_custom_html_top.rc > 0
- name: Check custom html in home page content (bottom)
shell: # noqa 301

Check warning on line 77 in molecule/default/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

77:14 [comments] too few spaces before comment
cmd: curl -sL http://localhost:4567 | grep -q 'Render custom string for this database'
register: grep_custom_html_bottom
failed_when: grep_custom_html_bottom.rc > 0
- name: Check that the home page is rendering the values of the placeholders set for my_db
shell: # noqa 301

Check warning on line 82 in molecule/default/verify.yml

View workflow job for this annotation

GitHub Actions / Lint

82:14 [comments] too few spaces before comment
cmd: curl -sL http://localhost:4567 | grep -q '<a href="http://testplaceholder.com">my favorite link</a>'
register: grep_placeholder
failed_when: grep_placeholder.rc > 0
Expand All @@ -83,14 +94,3 @@
set_fact:
grep_slurm_batch: "{{ lib_modified_for_hpc_integration.content | b64decode | regex_findall('slurm_sbatch.sh') | first }}"
failed_when: grep_slurm_batch != 'slurm_sbatch.sh'
- name: Get the SequenceServer configuration file of my_db
slurp:
src: "/etc/sequenceserver/config/sequenceserver.my_db.conf"
register: my_db_conf
- name: Display content of the SequenceServer configuration file of my_db
debug:
msg: "{{ my_db_conf.content | b64decode }}"
- name: Check that conf_option is in the SequenceServer configuration file of my_db
set_fact:
grep_slurm_batch: "{{ my_db_conf.content | b64decode | regex_findall('databases_widget') | first }}"
failed_when: grep_slurm_batch != 'databases_widget'
19 changes: 16 additions & 3 deletions templates/sequenceserver.conf.j2
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
:port: '{{ item.port }}'
:database_dir: '{{ item.path }}'
{% if item.conf_options is defined and item.conf_options %}
{% for option in item.conf_options %}
{% if option.key is defined and option.key and option.value is defined and option.value %}
:{{ option.key }}: '{{ option.value }}'
{% for conf_option in item.conf_options %}
{% if conf_option.key is defined and conf_option.key and conf_option.value is defined and conf_option.value %}
{% if conf_option.key != 'options' %}
:{{ conf_option.key }}: '{{ conf_option.value }}'
{% else %}
:options:
{% for blast_type, blast_configs in conf_option.value.items() %}
:{{ blast_type }}:
{% for blast_config, blast_params in blast_configs.items() %}
:{{ blast_config }}:
{% for blast_param in blast_params %}
- {{ blast_param }}
{% endfor %}
{% endfor %}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}