Skip to content

Commit 6beecb4

Browse files
committed
suggestions from code review
1 parent 2ac11ac commit 6beecb4

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

_template_python/delphi_NAME/run.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ def run_module(params):
3838
__name__, filename=params["common"].get("log_filename"),
3939
log_exceptions=params["common"].get("log_exceptions", True))
4040
mapper = GeoMapper()
41-
stats = []
41+
run_stats = []
4242
## build the base version of the signal at the most detailed geo level you can get.
4343
## compute stuff here or farm out to another function or file
4444
all_data = pd.DataFrame(columns=["timestamp", "val", "zip", "sample_size", "se"])
4545
## aggregate & smooth
4646
## TODO: add num/prop variations if needed
4747
for sensor, smoother, geo in product(SIGNALS, SMOOTHERS, GEOS):
4848
df = mapper.replace_geocode(
49-
all_data, "zip",
49+
all_data, "zip", geo,
5050
new_col="geo_id",
5151
date_col="timestamp")
5252
## TODO: recompute sample_size, se here if not NA
@@ -63,11 +63,11 @@ def run_module(params):
6363
sensor_name,
6464
start_date=start_date)
6565
if len(dates) > 0:
66-
stats.append((max(dates), len(dates)))
66+
run_stats.append((max(dates), len(dates)))
6767
## log this indicator run
6868
elapsed_time_in_seconds = round(time.time() - start_time, 2)
69-
min_max_date = stats and min(s[0] for s in stats)
70-
csv_export_count = sum(s[-1] for s in stats)
69+
min_max_date = run_stats and min(s[0] for s in run_stats)
70+
csv_export_count = sum(s[-1] for s in run_stats)
7171
max_lag_in_days = min_max_date and (datetime.now() - min_max_date).days
7272
formatted_min_max_date = min_max_date and min_max_date.strftime("%Y-%m-%d")
7373
logger.info("Completed indicator run",

_template_python/params.json.template

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
{
2-
"static_file_dir": "./static",
3-
"export_dir": "./receiving",
4-
"cache_dir": "./cache",
5-
"wip_signal": ""
2+
"common": {
3+
"export_dir": "./receiving",
4+
"log_filename": "NAME.log"
5+
},
6+
"validation": {
7+
"common": {
8+
"data_source": "NAME",
9+
"span_length": 14,
10+
"min_expected_lag": {"all": "1"},
11+
"max_expected_lag": {"all": "3"},
12+
"dry_run": true,
13+
"suppressed_errors": []
14+
},
15+
"static": {
16+
"minimum_sample_size": 0,
17+
"missing_se_allowed": true,
18+
"missing_sample_size_allowed": true
19+
},
20+
"dynamic": {}
21+
}
622
}

0 commit comments

Comments
 (0)