-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove pg-post-tasks and add common bash variable and functions
- Loading branch information
Showing
13 changed files
with
159 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
- name: Ensure directory for bashrc common files | ||
file: | ||
state: directory | ||
path: "{{ common_bashrc_dir }}" | ||
- name: Template bashrc_common path | ||
copy: | ||
dest: "{{ common_bashrc_vars_file }}" | ||
mode: 0755 | ||
content: | | ||
# slurm | ||
export SINFO_FORMAT="{{ common_sinfo_format }}" | ||
export SQUEUE_FORMAT="{{ common_squeue_format }}" | ||
export SINFO_FORMAT="{{ common_sacct_format }}" | ||
{% if is_galaxy_head_node %} | ||
# galaxy | ||
export PGHOST='{{ db_address }}' | ||
### export PGUSER='galaxy' this goes in local file | ||
export PGDATABASE='galaxy' | ||
export PGPORT='5432' | ||
export GALAXY_CONFIG_DIR={{ galaxy_config_dir }} | ||
export GALAXY_MUTABLE_CONFIG_DIR={{ galaxy_mutable_config_dir }} | ||
export GALAXY_ROOT={{ galaxy_server_dir }} | ||
export GALAXY_CONFIG_FILE={{ galaxy_config_file }} | ||
export GALAXY_JWD_PATH="{{ galaxy_job_working_directory }}" | ||
{% endif %} | ||
- name: Template common_bashrc path | ||
copy: | ||
dest: "{{ common_bashrc_functions_file }}" | ||
mode: 0755 | ||
content: | | ||
{% if is_galaxy_head_node %} | ||
# galaxy | ||
jwd() { # print path of job working directory for job id | ||
python "{{ common_bashrc_dir }}/get_jwd_path_galaxy.py" $1 | ||
} | ||
jwd-size() { | ||
du -sh $(jwd $1) | ||
} | ||
go-jwd() { # go to job working directory for job id | ||
cd $(jwd $1) | ||
} | ||
tail-stderr() { | ||
stderr_filename=$(jwd $1)/outputs/tool_stderr | ||
if [ ! -f $stderr_filename ]; then | ||
echo "No stderr file for job $1"; | ||
else | ||
tail $stderr_filename; | ||
fi | ||
} | ||
{% endif %} | ||
- name: Template helper scripts | ||
template: | ||
src: "bashrc/{{ item }}.j2" | ||
dest: "{{ common_bashrc_dir }}/{{ item }}" | ||
with_items: | ||
- get_jwd_path_galaxy.py | ||
|
||
- name: Add to .bashrc files | ||
blockinfile: | ||
marker: "# {mark} ANSIBLE MANAGED BLOCK (common role: source common bash env for users)" | ||
dest: "/home/{{ item.name }}/.bashrc" | ||
block: | | ||
source {{ common_bashrc_vars_file }} | ||
source {{ common_bashrc_functions_file }} | ||
# local to user | ||
{% if item == 'ubuntu' %} | ||
export PGUSER='galaxy' | ||
{% elif 'tiaas_admin' in item.roles|d([]) %} | ||
export PGUSER='tiaasadmin' | ||
{% else %} | ||
export PGUSER='reader' | ||
{% endif %} | ||
with_items: "{{ machine_users + [{'name': 'ubuntu'}] }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import argparse | ||
import os | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Get job working directory from a job id') | ||
parser.add_argument('job_id', type=int, help='Galaxy job id') | ||
args = parser.parse_args() | ||
|
||
prefix = os.environ.get("GALAXY_JWD_PATH") | ||
if not prefix: | ||
raise ValueError("Please set GALAXY_JWD_PATH environment variable") | ||
|
||
jwd_path = get_jwd_path(args.job_id, prefix) | ||
print(jwd_path) | ||
|
||
def get_jwd_path(job_id, prefix): | ||
if len(str(job_id)) > 6: # on production this is the case | ||
nine_digit_id = '0'*(9-len(str(job_id))) + str(job_id) | ||
return os.path.join(prefix, nine_digit_id[:3], nine_digit_id[3:6], str(job_id)) | ||
elif len(str(job_id)) <= 6: | ||
six_digit_id = '0'*(6-len(str(job_id))) + str(job_id) | ||
return os.path.join(prefix, six_digit_id[:3], str(job_id)) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters