Skip to content

Commit 8f06b22

Browse files
authored
Merge pull request #807 from sgsmob/jhu2
Refactor parameter hierarchy in JHU indicator
2 parents b1b2dfc + 53bef76 commit 8f06b22

File tree

5 files changed

+54
-37
lines changed

5 files changed

+54
-37
lines changed
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
{
2-
"export_start_date": "2020-02-20",
3-
"static_file_dir": "./static",
4-
"export_dir": "/common/covidcast/receiving/jhu-csse/",
5-
"cache_dir": "./cache",
6-
"base_url": "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_{metric}_US.csv",
7-
"aws_credentials": {
8-
"aws_access_key_id": "{{ delphi_aws_access_key_id }}",
9-
"aws_secret_access_key": "{{ delphi_aws_secret_access_key }}"
2+
"common": {
3+
"export_dir": "/common/covidcast/receiving/jhu-csse/",
4+
"log_filename": "/var/log/indicators/jhu.log"
105
},
11-
"bucket_name": "delphi-covidcast-indicator-output",
12-
"log_filename": "/var/log/indicators/jhu.log"
6+
"indicator": {
7+
"base_url": "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_{metric}_US.csv",
8+
"export_start_date": "2020-02-20",
9+
"static_file_dir": "./static"
10+
},
11+
"archive": {
12+
"aws_credentials": {
13+
"aws_access_key_id": "{{ delphi_aws_access_key_id }}",
14+
"aws_secret_access_key": "{{ delphi_aws_secret_access_key }}"
15+
},
16+
"bucket_name": "delphi-covidcast-indicator-output",
17+
"cache_dir": "./cache"
18+
}
1319
}

jhu/delphi_jhu/run.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,20 @@ def run_module():
6969
csv_export_count = 0
7070
oldest_final_export_date = None
7171
params = read_params()
72-
export_start_date = params["export_start_date"]
73-
export_dir = params["export_dir"]
74-
base_url = params["base_url"]
75-
cache_dir = params["cache_dir"]
72+
export_start_date = params["indicator"]["export_start_date"]
73+
export_dir = params["common"]["export_dir"]
74+
base_url = params["indicator"]["base_url"]
7675
logger = get_structured_logger(
77-
__name__, filename=params.get("log_filename"),
78-
log_exceptions=params.get("log_exceptions", True))
76+
__name__, filename=params["common"].get("log_filename"),
77+
log_exceptions=params["common"].get("log_exceptions", True))
7978

80-
if len(params["bucket_name"]) > 0:
79+
if "archive" in params:
8180
arch_diff = S3ArchiveDiffer(
82-
cache_dir,
81+
params["archive"]["cache_dir"],
8382
export_dir,
84-
params["bucket_name"],
83+
params["archive"]["bucket_name"],
8584
"jhu",
86-
params["aws_credentials"],
85+
params["archive"]["aws_credentials"],
8786
)
8887
arch_diff.update_cache()
8988
else:

jhu/params.json.template

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
{
2-
"export_start_date": "2020-02-20",
3-
"static_file_dir": "./static",
4-
"export_dir": "./receiving",
5-
"cache_dir": "./cache",
6-
"base_url": "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_{metric}_US.csv",
7-
"aws_credentials": {
8-
"aws_access_key_id": "",
9-
"aws_secret_access_key": ""
2+
"common": {
3+
"export_dir": "./receiving",
4+
"log_exceptions": false
105
},
11-
"bucket_name": "",
12-
"log_exceptions": false
6+
"indicator": {
7+
"base_url": "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_{metric}_US.csv",
8+
"export_start_date": "2020-02-20",
9+
"static_file_dir": "./static"
10+
},
11+
"archive": {
12+
"aws_credentials": {
13+
"aws_access_key_id": "",
14+
"aws_secret_access_key": ""
15+
},
16+
"bucket_name": "",
17+
"cache_dir": "./cache"
18+
}
1319
}

jhu/tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def run_as_module():
2222
with mock_s3():
2323
# Create the fake bucket we will be using
2424
params = read_params()
25-
aws_credentials = params["aws_credentials"]
25+
aws_credentials = params["archive"]["aws_credentials"]
2626
s3_client = Session(**aws_credentials).client("s3")
27-
s3_client.create_bucket(Bucket=params["bucket_name"])
27+
s3_client.create_bucket(Bucket=params["archive"]["bucket_name"])
2828

2929
run_module()
3030

jhu/tests/params.json.template

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
{
2-
"export_start_date": "2020-03-03",
3-
"static_file_dir": "../static",
4-
"export_dir": "./receiving",
5-
"cache_dir": "./cache",
2+
"common": {
3+
"export_dir": "./receiving"
4+
},
5+
"indicator": {
66
"base_url": "test_data/small_{metric}.csv",
7+
"export_start_date": "2020-03-03",
8+
"static_file_dir": "../static"
9+
},
10+
"archive": {
711
"aws_credentials": {
812
"aws_access_key_id": "FAKE_TEST_ACCESS_KEY_ID",
913
"aws_secret_access_key": "FAKE_TEST_SECRET_ACCESS_KEY"
1014
},
11-
"bucket_name": "test-bucket"
15+
"bucket_name": "test-bucket",
16+
"cache_dir": "./cache"
17+
}
1218
}

0 commit comments

Comments
 (0)