Skip to content

Commit 7e99b5e

Browse files
authored
Merge pull request #425 from cmu-delphi/bgc-fix-deploy-changehc
Update changehc deployment
2 parents 6f3197e + 152ab1a commit 7e99b5e

File tree

7 files changed

+83
-9
lines changed

7 files changed

+83
-9
lines changed

Jenkinsfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ pipeline {
5959
}
6060
}
6161

62+
stage('Deploy to staging env') {
63+
when {
64+
changeRequest target: "deploy-*", comparator: "GLOB"
65+
}
66+
steps {
67+
sh "jenkins/jenkins-deploy-staging.sh ${INDICATOR}"
68+
}
69+
}
70+
6271
stage('Deploy') {
6372
when {
6473
branch "deploy-*"

ansible/ansible-deploy-staging.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
- hosts: runtime_host_staging
3+
vars_files:
4+
- vars.yaml
5+
- vault.yaml
6+
tasks:
7+
- name: Copy and unarchive the package into the indicators runtime host directory.
8+
unarchive:
9+
src: "{{ jenkins_artifact_dir }}/{{ package }}"
10+
dest: "{{ indicators_runtime_dir }}"
11+
owner: "{{ runtime_user }}"
12+
group: "{{ runtime_user }}"
13+
14+
- name: Mutate Python bin path used in venv.
15+
file:
16+
src: "{{ pyenv_python_path }}"
17+
dest: "{{ indicators_runtime_dir }}/{{ indicator }}/env/bin/python"
18+
owner: "{{ runtime_user }}"
19+
group: "{{ runtime_user }}"
20+
state: link
21+
22+
- name: Check to see if we have a params file to send.
23+
local_action: stat path="files/{{ indicator }}-params-prod.json"
24+
register: file
25+
26+
- name: Check to see if we have a params template to send.
27+
local_action: stat path="templates/{{ indicator }}-params-prod.json.j2"
28+
register: template
29+
30+
- name: Set production params file.
31+
copy:
32+
src: files/{{ indicator }}-params-prod.json
33+
dest: "{{ indicators_runtime_dir }}/{{ indicator }}/params.json"
34+
owner: "{{ runtime_user }}"
35+
group: "{{ runtime_user }}"
36+
when: file.stat.exists
37+
38+
- name: Set production params template.
39+
template:
40+
src: templates/{{ indicator }}-params-prod.json.j2
41+
dest: "{{ indicators_runtime_dir }}/{{ indicator }}/params.json"
42+
owner: "{{ runtime_user }}"
43+
group: "{{ runtime_user }}"
44+
when: template.stat.exists

ansible/inventory

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[runtime_host]
2-
delphi-master-prod-01.delphi.cmu.edu
2+
delphi-master-prod-01.delphi.cmu.edu
3+
4+
[runtime_host_staging]
5+
app-mono-dev-01.delphi.cmu.edu

ansible/templates/changehc-params-prod.json.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"static_file_dir": "./static",
3-
"export_dir": "./receiving",
3+
"export_dir": "/common/covidcast/receiving/changehc",
44
"cache_dir": "./cache",
5-
"input_emr_file": "./tests/test_data/SYNICUE_CMB_INPATIENT_11062020.csv.gz",
6-
"input_claims_file": "./tests/test_data/SYNEDI_AGG_INPATIENT_11062020_1451CDT.csv.gz",
5+
"input_denom_file": "./tests/test_data/20200601_All_Outpatients_By_County.dat",
6+
"input_covid_file": "./tests/test_data/20200601_Covid_Outpatients_By_County.dat",
77
"start_date": "2020-02-01",
88
"end_date": null,
99
"drop_date": null,
1010
"n_backfill_days": 60,
1111
"n_waiting_days": 3,
1212
"se": false,
1313
"parallel": false,
14-
"geos": ["state", "msa", "hrr", "fips"],
14+
"geos": ["state", "msa", "hrr", "county"],
1515
"weekday": [true, false],
1616
"wip_signal": "",
1717
"aws_credentials": {

changehc/delphi_changehc/download_ftp_files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def download(out_path, ftp_conn):
5757
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
5858

5959
client.connect(ftp_conn["host"], username=ftp_conn["user"],
60-
password=ftp_conn["pass"][1:] + ftp_conn["pass"][0],
60+
password=ftp_conn["pass"],
6161
port=ftp_conn["port"],
6262
allow_agent=False, look_for_keys=False)
6363
sftp = client.open_sftp()

changehc/params.json.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
"static_file_dir": "./static",
33
"export_dir": "./receiving",
44
"cache_dir": "./cache",
5-
"input_emr_file": "./tests/test_data/SYNICUE_CMB_INPATIENT_11062020.csv.gz",
6-
"input_claims_file": "./tests/test_data/SYNEDI_AGG_INPATIENT_11062020_1451CDT.csv.gz",
5+
"input_denom_file": "./tests/test_data/20200601_All_Outpatients_By_County.dat",
6+
"input_covid_file": "./tests/test_data/20200601_Covid_Outpatients_By_County.dat",
77
"start_date": "2020-02-01",
88
"end_date": null,
99
"drop_date": null,
1010
"n_backfill_days": 60,
1111
"n_waiting_days": 3,
1212
"se": false,
1313
"parallel": false,
14-
"geos": ["state", "msa", "hrr", "fips"],
14+
"geos": ["state", "msa", "hrr", "county"],
1515
"weekday": [true, false],
1616
"wip_signal": "",
1717
"aws_credentials": {

jenkins/jenkins-deploy-staging.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Jenkins deploy
4+
#
5+
6+
set -eo pipefail
7+
source ~/.bash_profile
8+
9+
#
10+
# Deploy
11+
#
12+
13+
local_indicator=$1
14+
15+
cd "${WORKSPACE}/ansible" || exit
16+
17+
# Ansible!
18+
ansible-playbook ansible-deploy-staging.yaml --extra-vars "indicator=${local_indicator}" -i inventory

0 commit comments

Comments
 (0)