Skip to content

Commit f005552

Browse files
authored
Merge pull request #447 from cmu-delphi/deploy-changehc
Merge deploy-changehc to main
2 parents 22e8643 + 5c3b7d8 commit f005552

14 files changed

+235
-27
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
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"static_file_dir": "./static",
3+
"export_dir": "/common/covidcast/receiving/changehc",
4+
"cache_dir": "./cache",
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",
7+
"start_date": "2020-02-01",
8+
"end_date": null,
9+
"drop_date": null,
10+
"n_backfill_days": 60,
11+
"n_waiting_days": 3,
12+
"se": false,
13+
"parallel": false,
14+
"geos": ["state", "msa", "hrr", "county"],
15+
"weekday": [true, false],
16+
"wip_signal": "",
17+
"aws_credentials": {
18+
"aws_access_key_id": "",
19+
"aws_secret_access_key": ""
20+
},
21+
"bucket_name": "",
22+
"ftp_conn": {
23+
"host": "{{ changehc_sftp_host }}",
24+
"user": "{{ changehc_sftp_user }}",
25+
"pass": "{{ changehc_sftp_password }}",
26+
"port": "{{ changehc_sftp_port }}"
27+
}
28+
}

ansible/vars.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ delphi_aws_access_key_id: "{{ vault_delphi_aws_access_key_id }}"
1313
delphi_aws_secret_access_key: "{{ vault_delphi_aws_secret_access_key }}"
1414
safegraph_aws_access_key_id: "{{ vault_safegraph_aws_access_key_id }}"
1515
safegraph_aws_secret_access_key: "{{ vault_safegraph_aws_secret_access_key }}"
16+
quidel_datadrop_mail_server: "{{ vault_quidel_datadrop_mail_server }}"
17+
quidel_datadrop_account: "{{ vault_quidel_datadrop_account }}"
18+
quidel_datadrop_password: "{{ vault_quidel_datadrop_password }}"
19+
quidel_datadrop_sender: "{{ vault_quidel_datadrop_sender }}"
20+
changehc_sftp_host: "{{ vault_changehc_sftp_host }}"
21+
changehc_sftp_port: "{{ vault_changehc_sftp_port }}"
22+
changehc_sftp_user: "{{ vault_changehc_sftp_user }}"
23+
changehc_sftp_password: "{{ vault_changehc_sftp_password }}"

ansible/vault.yaml

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,42 @@
11
$ANSIBLE_VAULT;1.1;AES256
2-
39633436633363346633333638666438316131313337333132396634393538383432623239316463
3-
3435333238376331383439366161656639353039326163370a376363633535623363383233646533
4-
63363865646561323132663032383331346332373364333465643330616638623466333039623831
5-
6530663236313234360a336264656239383166663934303335386238386139386132626165386138
6-
32663164326237323534636263663263666634383339613362633939323565356437663666653436
7-
31353362316334313561333430626361616337643133346664636434313664373333653839323630
8-
65346331383135656135386263643564333063626563336365333865663333353337393866666139
9-
64613735663363323938633161666662653161633835383832656164343836383339376661396332
10-
66353131373265373931366130383632633466363036373562363232663162333966316563373535
11-
65343336363732303132366335616335333334373063313562336330336661353239646533356461
12-
62313365633336613037626261353639323937363066363062356234653631346233373965636461
13-
63326237663537363338346566326232353632663463386135393535343436373335393430393865
14-
33393631623762636230656263363462346561323064653561393666373735313836666238323238
15-
66366564666266343636663666386566336637373036633966643961346636373066356632326464
16-
63336565656666336436383938346461646431353265353133633736363761623634346262616436
17-
61653633326333356330626638386665313865343233393637623662383634346534326537623662
18-
34326633623431343835346339656335386330333664373166313766366339663736376261343965
19-
63616461666230616131326537373130313239663931313330356538356161333537666237376362
20-
64613232333834303737323438616437303666643166383439393030316533343530363863613034
21-
39653761626439356133393164363561316535633230633438316137623333376633663665393634
22-
63333161376263613766353030616336386531303565346263366239653232333764
2+
66636361333161346433333963373239653963623663663037323339313139303634646361373037
3+
3031383130623131653561656465333831613164396563310a613735366261303931663033663031
4+
30643562663566393861616263633338333965383361623236616339663237653733333936366539
5+
3465666462363634390a356463663863333536313765613065353336626633623264633132356634
6+
38623763306165306333663139646465313038303134333461666364656231383965393364666266
7+
39613864386337323032323033623166623265333033396130336633366431333337646263363963
8+
65666461346164643164313838373766316165643635663238326638626136333462373035306161
9+
65383662653061633939383039316562646431343436303838656237323465633936373463336335
10+
39663938303130383665336335303534613135656562326134643730666661356439393838383832
11+
65336562363865626665616438633238353065383735363136363931353161653036643231623939
12+
39303635373861343036663265343636333066616336663338376438663130373438636364626335
13+
32313638633262616664636337323063323166383636356132326339643631613138376266343838
14+
64653636383663626535653334393730393534616165326436396431636237323535393262646233
15+
33313266643962626665353738356262393435313065623863633235373561393231313533383662
16+
65316435386562633763386435643666643930336233383266633033323530633232656337623635
17+
66616435366532663166303766393939346635666136336635373834613834366532313638616464
18+
32313765353362346266323938393561333039663063306538316133343765623632313231613733
19+
31353364316662323332383964326338386164363062353636336636316233636466313838626263
20+
66323435346434663864396262623636316434626631643463653337653063623733323233623731
21+
66636564633438633731346162653561326532616165313866646531376436616266303764666237
22+
31636430623564396432346230666565326137613364363064363963356332346234303865303937
23+
37343863653939323139333533633230323465653962343332306464376138396137626566373063
24+
38626231643961383466376561666338663236613638333831663633376464656432333063363164
25+
34346566636232313734646137303531643536613537373664643663623263653831656136323239
26+
34353034633038316263386636376234393563393466643133383866656134646463666433336234
27+
32323665323634323635386430316238656366376561653365613934303262343938303833323464
28+
32353062363132376131326466393266313662376330663831323136313262333066656261353234
29+
35353966333733333639646130383235333738643833376166396564313666633135613938323236
30+
35643261376537663338323834363734343735366131313133623433323138313631653639323438
31+
61626631656665643939666437303932336437656234626639333138353466613463343032326639
32+
63313432666364306137343131656630326263616135343034303836396435383330626463373733
33+
37303434363735616339353661316461333535656131323631633731353539316264643735633862
34+
31363638353435303963333864393733396232643931613866636463653638646236356563333938
35+
61323134326131353264313264663661333261323533333537323361653636326636653137306330
36+
36643164643438346436613538353835656132366163383865333237383038353839626439346632
37+
66663132313836353766383031383732383838666261653230613336323631346533613361636331
38+
61326535646438643732373130646366653738343236396561623666396231316330383266623839
39+
64666138373032353136666234383434343162323761623061326233363532396132623237306362
40+
35636535313336636566393532303337333630393165616264653466376566323533323737343534
41+
64343831653131306138383263663933396338373736663565373739373330336432326666386230
42+
31616338336265333832613331623339656231643838353261373037636435396531

changehc/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,3 @@ should not include critical sub-routines.
7474
- config.py: Config: constants for reading data and transformations, Constants: constants for sanity checks
7575
- constants.py: constants for signal names
7676
- weekday.py: Weekday: Adjusts for weekday effect
77-

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/changehc-jenkins-build.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Change HC: Jenkins build
4+
#
5+
6+
set -eo pipefail
7+
source ~/.bash_profile
8+
9+
#
10+
# Build
11+
#
12+
13+
local_indicator="changehc"
14+
15+
cd "${WORKSPACE}/${local_indicator}" || exit
16+
17+
# Set up venv
18+
python -m venv env
19+
source env/bin/activate
20+
pip install ../_delphi_utils_python/.
21+
pip install .

jenkins/changehc-jenkins-deploy.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+
# Change HC: Jenkins deploy
4+
#
5+
6+
set -eo pipefail
7+
source ~/.bash_profile
8+
9+
#
10+
# Deploy
11+
#
12+
13+
local_indicator="changehc"
14+
15+
cd "${WORKSPACE}/ansible" || exit
16+
17+
# Ansible!
18+
ansible-playbook ansible-deploy.yaml --extra-vars "indicator=${local_indicator}" -i inventory

jenkins/changehc-jenkins-package.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+
# Change HC: Jenkins package
4+
#
5+
6+
set -eo pipefail
7+
source ~/.bash_profile
8+
9+
#
10+
# Package
11+
#
12+
13+
local_indicator="changehc"
14+
15+
cd "${WORKSPACE}" || exit
16+
17+
# Create .tar.gz for deployment
18+
tar -czvf "${JENKINS_HOME}/artifacts/${local_indicator}.tar.gz" "${local_indicator}"

jenkins/changehc-jenkins-test.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Change HC: Jenkins test
4+
#
5+
6+
set -eo pipefail
7+
source ~/.bash_profile
8+
9+
#
10+
# Test
11+
#
12+
13+
local_indicator="changehc"
14+
15+
cd "${WORKSPACE}/${local_indicator}" || exit
16+
17+
# Linter
18+
env/bin/pylint delphi_"${local_indicator}"
19+
20+
# Unit tests and code coverage
21+
cd tests || exit && \
22+
../env/bin/pytest --cov=delphi_"${local_indicator}" --cov-report=term-missing

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)