Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions nhsn/delphi_nhsn/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ def patch(params):

patch_list = filter_source_files(source_files)
for file in patch_list:
issue_date = datetime.strptime(file.name.split(".")[0], "%Y%m%d")
current_issue_ew = Week.fromdate(issue_date)
logger.info("Running issue", issue_date=issue_date.strftime("%Y-%m-%d"))
params["patch"]["issue_date"] = issue_date.strftime("%Y%m%d")
current_issue_dir = f"{params['patch']['patch_dir']}/issue_{current_issue_ew}/nhsn"
issue_date_str = file.name.split(".")[0]
logger.info("Running issue", issue_date=datetime.strptime(issue_date_str, "%Y%m%d").strftime("%Y-%m-%d"))
params["patch"]["issue_date"] = issue_date_str
# regardless of week date type or not the directory name must be issue_date_YYYYMMDD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# regardless of week date type or not the directory name must be issue_date_YYYYMMDD
# regardless of week date type or not the directory name must be `issue_YYYYMMDD`

# conversion in done in acquisition
current_issue_dir = f"{params['patch']['patch_dir']}/issue_{issue_date_str}/nhsn"
makedirs(current_issue_dir, exist_ok=True)
params["common"]["export_dir"] = current_issue_dir
params["common"]["custom_run"] = True
Expand Down
3 changes: 1 addition & 2 deletions nhsn/tests/test_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ def test_patch(self, params_w_patch):
issue_dt_str = issue_path.name.replace("issue_", "")
for file in Path(issue_path / "nhsn").iterdir():
df = pd.read_csv(file)
val = Week.fromdate(datetime.strptime(str(int(df["val"][0])), "%Y%m%d"))
assert issue_dt_str == str(val)
assert issue_dt_str == str(int(df["val"][0]))

# clean up
shutil.rmtree(f"{TEST_DIR}/patch_dir")
Expand Down
Loading