Skip to content

Commit 66b618b

Browse files
committed
Merge branch 'main' into 7dav_new_geo_ids
2 parents 3989131 + 716f733 commit 66b618b

File tree

104 files changed

+1455
-667
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1455
-667
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.5
2+
current_version = 0.2.19
33
commit = True
44
message = chore: bump covidcast-indicators to {new_version}
55
tag = False

.github/workflows/python-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
pip install pylint pytest pydocstyle wheel
3333
- name: Install
3434
run: |
35-
make install
35+
make install-ci
3636
- name: Lint
3737
run: |
3838
make lint

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- Keep in sync with '.github/workflows/python-ci.yml'.
1010
- TODO: #527 Get this list automatically from python-ci.yml at runtime.
1111
*/
12-
def indicator_list = ["cdc_covidnet", "changehc", "claims_hosp", "combo_cases_and_deaths", "covid_act_now", "facebook", "google_symptoms", "hhs_hosp", "jhu", "nchs_mortality", "quidel", "quidel_covidtest", "safegraph_patterns", "sir_complainsalot", "usafacts"]
12+
def indicator_list = ["changehc", "claims_hosp", "covid_act_now", "facebook", "google_symptoms", "hhs_hosp", "jhu", "nchs_mortality", "quidel", "quidel_covidtest", "safegraph_patterns", "sir_complainsalot", "usafacts"]
1313
def build_package = [:]
1414
def deploy_staging = [:]
1515
def deploy_production = [:]

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,33 @@ Each indicator pipeline includes its own documentation.
2626
* Consult REVIEW.md for the checklist to use for code reviews.
2727
* Consult DETAILS.md (if present) for implementation details, including handling of corner cases.
2828

29+
## Development
30+
31+
`prod` reflects what is currently in production. `main` is the staging branch for the next release.
32+
33+
1. Branch from `main` to develop a new change
34+
2. PR into `main` and assign a reviewer (or tag someone) to get feedback on your change. List the issue number under `Fixes` if your change resolves an existing [GitHub Issue](https://github.com/cmu-delphi/covidcast-indicators/issues).
35+
3. Add new commits to your branch in response to feedback.
36+
4. When approved, tag an admin to merge the PR. Let them know if this change should be released immediately, at a set future date, or if it can just go along for the ride whenever the next release happens.
37+
38+
## Release Process
39+
40+
The release process consists of multiple steps which can all be done via the GitHub website:
41+
42+
1. Go to [create_release GitHub Action](https://github.com/cmu-delphi/covidcast-indicators/actions/workflows/create-release.yml) and click the `Run workflow` dropdown button. Leave branch as `main` unless you know what you're doing. Enter the type of release (patch: bugfixes, params file changes, new signals for existing indicators; minor: new indicators, new utilities; major: backwards-incompatible changes requiring substantial refactoring) and GitHub will automatically compute the next version number for you; alternately, specify the version number by hand. Hit the green `Run workflow` button.
43+
2. The action will prepare a new release and generate an associated [Pull Request](https://github.com/cmu-delphi/covidcast-indicators/pulls).
44+
3. Edit the PR description and **list all pull requests included in this release**. This is a manual step to make sure you are aware of 100% of the changes that will be deployed. You can use `#xxx` notation and GitHub will automatically render the title of each PR in Preview mode and when the edit is saved.
45+
4. Verify that CI passes for the PR as a whole and for the most-recent/bottom-most commit in the PR. We're currently having problems where [python-ci does not run on release PRs](https://github.com/cmu-delphi/covidcast-indicators/issues/1310), but if you see a green check next to the most-recent commit you should be fine.
46+
5. Approve the PR, merge it, and delete the branch.
47+
6. Jenkins will automatically deploy the most-recently-built indicator packages to the pipeline servers
48+
7. Another GitHub action will automatically
49+
1. Create a git tag
50+
2. Create another [Pull Request](https://github.com/cmu-delphi/covidcast-indicators/pulls) to merge the changes back into the `main` branch
51+
3. (if `delphi-utils` was updated) Upload the new version of `delphi-utils` to PyPI
52+
8. Approve the sync PR, merge it, and delete the branch
53+
9. Done
54+
55+
You may need to be an admin to perform some of the steps above.
2956

3057
## License
3158

_delphi_utils_python/.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.2.4
2+
current_version = 0.2.8
33
commit = True
44
message = chore: bump delphi_utils to {new_version}
55
tag = False

_delphi_utils_python/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ install: venv
88
pip install wheel ; \
99
pip install -e .
1010

11+
install-ci: venv
12+
. env/bin/activate; \
13+
pip install wheel ; \
14+
pip install .
15+
1116
lint:
1217
. env/bin/activate; pylint delphi_utils
1318
. env/bin/activate; pydocstyle delphi_utils

_delphi_utils_python/delphi_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
from .nancodes import Nans
1616
from .weekday import Weekday
1717

18-
__version__ = "0.2.4"
18+
__version__ = "0.2.8"

_delphi_utils_python/delphi_utils/archive.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,9 @@ def filter_exports(self, common_diffs: FileDiffMap):
307307
else:
308308
replace(diff_file, exported_file)
309309

310-
def run(self):
310+
def run(self, logger=None):
311311
"""Run the differ and archive the changed and new files."""
312+
start_time = time.time()
312313
self.update_cache()
313314

314315
# Diff exports, and make incremental versions
@@ -317,6 +318,11 @@ def run(self):
317318
# Archive changed and new files only
318319
to_archive = [f for f, diff in common_diffs.items()
319320
if diff is not None]
321+
if logger:
322+
logger.debug("Diffed exports",
323+
phase="archiving",
324+
new_files_count=len(new_files),
325+
common_diffs_count=len(to_archive))
320326
to_archive += new_files
321327
_, fails = self.archive_exports(to_archive)
322328

@@ -329,6 +335,14 @@ def run(self):
329335
for exported_file in fails:
330336
print(f"Failed to archive '{exported_file}'")
331337

338+
elapsed_time_in_seconds = round(time.time() - start_time, 2)
339+
if logger:
340+
logger.info("Completed archive run",
341+
phase="archiving",
342+
elapsed_time_in_seconds=elapsed_time_in_seconds,
343+
new_changed_count=len(to_archive),
344+
fail_count=len(fails))
345+
332346

333347
class S3ArchiveDiffer(ArchiveDiffer):
334348
"""
@@ -641,8 +655,23 @@ def archive_exports(self, exported_files):
641655
successes: All files from input
642656
fails: Empty list
643657
"""
658+
archive_success, archive_fail = [], []
659+
for exported_file in exported_files:
660+
archive_file = abspath(
661+
join(self.cache_dir, basename(exported_file)))
662+
663+
# Copy export to cache
664+
try:
665+
# Archive
666+
shutil.copyfile(exported_file, archive_file)
667+
archive_success.append(exported_file)
668+
669+
except FileNotFoundError as ex:
670+
print(ex)
671+
archive_fail.append(exported_file)
672+
644673
self._exports_archived = True
645-
return exported_files, []
674+
return archive_success, archive_fail
646675

647676
def update_cache(self):
648677
"""Handle cache updates with a no-op.
@@ -667,13 +696,6 @@ def update_cache(self):
667696
if "archive" not in _params:
668697
_params = {"archive": _params, "common": _params}
669698

670-
logger = get_structured_logger(
699+
archiver_from_params(_params).run(get_structured_logger(
671700
__name__, filename=_params["common"].get("log_filename"),
672-
log_exceptions=_params["common"].get("log_exceptions", True))
673-
start_time = time.time()
674-
675-
archiver_from_params(_params).run()
676-
677-
elapsed_time_in_seconds = round(time.time() - start_time, 2)
678-
logger.info("Completed archive run.",
679-
elapsed_time_in_seconds=elapsed_time_in_seconds)
701+
log_exceptions=_params["common"].get("log_exceptions", True)))

_delphi_utils_python/delphi_utils/runner.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,19 @@ def run_indicator_pipeline(indicator_fn: Callable[[Params], None],
3636
None if no archiving should be performed.
3737
"""
3838
params = read_params()
39+
logger = get_structured_logger(
40+
name=indicator_fn.__module__,
41+
filename=params["common"].get("log_filename", None),
42+
log_exceptions=params["common"].get("log_exceptions", True))
3943
indicator_fn(params)
4044
validator = validator_fn(params)
4145
archiver = archiver_fn(params)
4246
if validator:
4347
validation_report = validator.validate()
44-
validation_report.log(get_structured_logger(
45-
name = indicator_fn.__module__,
46-
filename=params["common"].get("log_filename", None)))
48+
validation_report.log(logger)
4749
if (not validator or validation_report.success()):
4850
if archiver:
49-
archiver.run()
51+
archiver.run(logger)
5052
if "delivery" in params:
5153
transfer_files()
5254

_delphi_utils_python/delphi_utils/validator/dynamic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def pad_reference_api_df(self, reference_api_df, geo_sig_df, reference_end_date)
345345
Returns:
346346
- reference_api_df: Supplemented version of original
347347
"""
348-
reference_api_df_max_date = reference_api_df.time_value.max()
348+
reference_api_df_max_date = reference_api_df.time_value.max().date()
349349
if reference_api_df_max_date < reference_end_date:
350350
# Querying geo_sig_df, only taking relevant rows
351351
geo_sig_df_supplement = geo_sig_df.query(

0 commit comments

Comments
 (0)