Skip to content

Commit 01439d8

Browse files
committed
Merge branch 'main' of github.com:cmu-delphi/covidcast-indicators into geo
2 parents 3145ba1 + b21252f commit 01439d8

File tree

13 files changed

+116
-33124
lines changed

13 files changed

+116
-33124
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Feature release
3+
about: Begin the finishing work for features ready to be included in a release
4+
title: 'Release NEW_THING'
5+
labels: 'release'
6+
assignees: 'benjaminysmith'
7+
---
8+
9+
- [Link to issue]()
10+
- [Link to PR]()
11+
- Proposed release version: <!-- eg 1.12 -->
12+
13+
<!-- Additional information about the feature: -->
14+
15+
16+
<!-- relevant for most work -->
17+
18+
- [ ] API [documentation](https://github.com/cmu-delphi/delphi-epidata/tree/main/docs/api) and/or [changelog](https://github.com/cmu-delphi/delphi-epidata/blob/main/docs/api/covidcast_changelog.md)
19+
- [ ] API mailing list notification
20+
21+
<!-- relevant for new signals -->
22+
23+
- [ ] Statistical review (usually [correlations](https://github.com/cmu-delphi/covidcast/tree/main/docs/R-notebooks))
24+
- [ ] Signal / source name review (usually [Roni](https://docs.google.com/document/d/10hGd4Evce4lJ4VkWaQEKFQxvmw2P4xyYGtIAWF52Sf8/edit?usp=sharing))
25+
26+
<!-- relevant for new map signals -->
27+
28+
- [ ] Visual review
29+
- [ ] [Signal description pop-up text](https://docs.google.com/document/d/1kDqRg8EaI4WQXMaUUbbCGPlsUqEql8kgXCNt6AvMA9I/edit?usp=sharing) review
30+
- [ ] [Map release notes](https://docs.google.com/document/d/1BpxGgIma_Lkd2kxtwEo2DBdHQ3zk6dHRz-leUIRlOIA/edit?usp=sharing)

ansible/files/usafacts-params-prod.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"export_start_date": "latest",
3+
"static_file_dir": "./static",
4+
"export_dir": "/common/covidcast/receiving/usa-facts",
5+
"cache_dir": "./cache",
6+
"base_url": "https://usafactsstatic.blob.core.windows.net/public/data/covid-19/covid_{metric}_usafacts.csv",
7+
"aws_credentials": {
8+
"aws_access_key_id": "{{ delphi_aws_access_key_id }}",
9+
"aws_secret_access_key": "{{ delphi_aws_secret_access_key }}"
10+
},
11+
"bucket_name": "delphi-covidcast-indicator-output"
12+
}

claims_hosp/delphi_claims_hosp/update_indicator.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,21 @@ def geo_reindex(self, data):
9696
"""
9797
geo_map = GeoMapper()
9898
if self.geo == "county":
99-
data_frame = geo_map.county_to_megacounty(
100-
data, Config.MIN_DEN, Config.MAX_BACKWARDS_PAD_LENGTH,
101-
thr_col="den", mega_col=self.geo)
99+
data_frame = geo_map.fips_to_megacounty(data,
100+
Config.MIN_DEN,
101+
Config.MAX_BACKWARDS_PAD_LENGTH,
102+
thr_col="den",
103+
mega_col=self.geo)
102104
elif self.geo == "state":
103-
data_frame = geo_map.county_to_state(data, state_id_col=self.geo)
105+
data_frame = geo_map.replace_geocode(data,
106+
from_code="fips",
107+
new_col=self.geo,
108+
new_code="state_id")
109+
data_frame[self.geo] = data_frame[self.geo]
104110
elif self.geo == "msa":
105-
data_frame = geo_map.county_to_msa(data, msa_col=self.geo)
111+
data_frame = geo_map.replace_geocode(data,
112+
from_code="fips",
113+
new_code=self.geo)
106114
elif self.geo == "hrr":
107115
data_frame = data # data is already adjusted in aggregation step above
108116
else:
@@ -119,7 +127,6 @@ def geo_reindex(self, data):
119127
assert (
120128
len(multiindex) <= (GeoConstants.MAX_GEO[self.geo] * len(self.fit_dates))
121129
), "more loc-date pairs than maximum number of geographies x number of dates"
122-
123130
# fill dataframe with missing dates using 0
124131
data_frame = data_frame.reindex(multiindex, fill_value=0)
125132
data_frame.fillna(0, inplace=True)

claims_hosp/static/02_20_uszips.csv

Lines changed: 0 additions & 33100 deletions
This file was deleted.

jenkins/usafacts-jenkins-test.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ local_indicator="usafacts"
1515
cd "${WORKSPACE}/${local_indicator}" || exit
1616

1717
# Linter
18-
env/bin/pylint delphi_"${local_indicator}"
18+
#env/bin/pylint delphi_"${local_indicator}"
19+
echo "Skip linting because we have weird breakage :( \
20+
TODO: https://github.com/cmu-delphi/covidcast-indicators/issues/333"
1921

2022
# Unit tests and code coverage
2123
cd tests || exit && \

usafacts/delphi_usafacts/run.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111

1212
import numpy as np
1313
import pandas as pd
14-
from delphi_utils import read_params, create_export_csv, GeoMapper
14+
from delphi_utils import (
15+
read_params,
16+
create_export_csv,
17+
S3ArchiveDiffer,
18+
GeoMapper
19+
)
1520

1621
from .geo import geo_map
1722
from .pull import pull_usafacts_data
@@ -73,6 +78,13 @@ def run_module():
7378
export_dir = params["export_dir"]
7479
base_url = params["base_url"]
7580
static_file_dir = params["static_file_dir"]
81+
cache_dir = params["cache_dir"]
82+
83+
arch_diff = S3ArchiveDiffer(
84+
cache_dir, export_dir,
85+
params["bucket_name"], "usafacts",
86+
params["aws_credentials"])
87+
arch_diff.update_cache()
7688

7789
map_df = pd.read_csv(
7890
join(static_file_dir, "fips_prop_pop.csv"), dtype={"fips": int}
@@ -105,3 +117,19 @@ def run_module():
105117
geo_res=geo_res,
106118
sensor=sensor_name,
107119
)
120+
121+
# Diff exports, and make incremental versions
122+
_, common_diffs, new_files = arch_diff.diff_exports()
123+
124+
# Archive changed and new files only
125+
to_archive = [f for f, diff in common_diffs.items() if diff is not None]
126+
to_archive += new_files
127+
_, fails = arch_diff.archive_exports(to_archive)
128+
129+
# Filter existing exports to exclude those that failed to archive
130+
succ_common_diffs = {f: diff for f, diff in common_diffs.items() if f not in fails}
131+
arch_diff.filter_exports(succ_common_diffs)
132+
133+
# Report failures: someone should probably look at them
134+
for exported_file in fails:
135+
print(f"Failed to archive '{exported_file}'")

usafacts/params.json.template

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
"static_file_dir": "./static",
44
"export_dir": "./receiving",
55
"cache_dir": "./cache",
6-
"base_url": "https://usafactsstatic.blob.core.windows.net/public/data/covid-19/covid_{metric}_usafacts.csv"
6+
"base_url": "https://usafactsstatic.blob.core.windows.net/public/data/covid-19/covid_{metric}_usafacts.csv",
7+
"aws_credentials": {
8+
"aws_access_key_id": "",
9+
"aws_secret_access_key": ""
10+
},
11+
"bucket_name": ""
712
}

usafacts/tests/conftest.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
# -*- coding: utf-8 -*-
22

3+
from boto3 import Session
4+
from moto import mock_s3
35
import pytest
46

57
from os import listdir, remove
68
from os.path import join
79

10+
from delphi_utils import read_params
811
from delphi_usafacts.run import run_module
912

1013

1114
@pytest.fixture(scope="session")
1215
def run_as_module():
1316
# Clean receiving directory
14-
for fname in listdir("../receiving"):
17+
for fname in listdir("receiving"):
1518
if fname[0] == ".":
1619
continue
17-
remove(join("../receiving", fname))
20+
remove(join("receiving", fname))
1821

19-
run_module()
22+
with mock_s3():
23+
# Create the fake bucket we will be using
24+
params = read_params()
25+
aws_credentials = params["aws_credentials"]
26+
s3_client = Session(**aws_credentials).client("s3")
27+
s3_client.create_bucket(Bucket=params["bucket_name"])
28+
29+
run_module()

usafacts/tests/params.json.template

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
"static_file_dir": "../static",
44
"export_dir": "./receiving",
55
"cache_dir": "./cache",
6-
"base_url": "./test_data/small_{metric}.csv"
6+
"base_url": "./test_data/small_{metric}.csv",
7+
"aws_credentials": {
8+
"aws_access_key_id": "FAKE_TEST_ACCESS_KEY_ID",
9+
"aws_secret_access_key": "FAKE_TEST_SECRET_ACCESS_KEY"
10+
},
11+
"bucket_name": "test-bucket"
712
}

0 commit comments

Comments
 (0)