Skip to content

Release covidcast-indicators 0.3.56 [ABANDONED] #2047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 93 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
ab915bc
doc: add logger examples to README and format
dshemetov Jul 1, 2024
830388a
deployment + staging details
minhkhul Jul 3, 2024
57cb4ec
wrap lines
nmdefries Jul 8, 2024
6a289fd
Update _template_python/INDICATOR_DEV_GUIDE.md
minhkhul Jul 9, 2024
d2fafd1
Update _template_python/INDICATOR_DEV_GUIDE.md
minhkhul Jul 9, 2024
67152f7
Update _template_python/INDICATOR_DEV_GUIDE.md
minhkhul Jul 9, 2024
519582a
Update INDICATOR_DEV_GUIDE.md with mysql syntax
minhkhul Jul 9, 2024
9972728
Update INDICATOR_DEV_GUIDE.md reorder instruction on cron jobs
minhkhul Jul 9, 2024
01c9ebe
Merge branch 'main' into deployment-details
nmdefries Jul 10, 2024
35f88fd
Merge pull request #1986 from cmu-delphi/deployment-details
nmdefries Jul 10, 2024
810ebfd
Merge pull request #1992 from cmu-delphi/bot/sync-prod-main
melange396 Jul 10, 2024
19e2df6
switch from input_file to input_dir (#1995)
minhkhul Jul 11, 2024
bfde83f
adjust nssp max_age
minhkhul Jul 15, 2024
b3fe2cb
Merge pull request #1997 from cmu-delphi/adjust-nssp-sir-complains
melange396 Jul 16, 2024
5628813
add pyproject.toml
aysim319 Jul 1, 2024
fa2d2f8
made changes based on suggestion
aysim319 Jul 2, 2024
653309c
update ci config
aysim319 Jul 2, 2024
7fb418a
separate new line
aysim319 Jul 3, 2024
403b2e9
fix: add explicit boto and moto dependencies to indicators
dshemetov Jul 8, 2024
7eaf30f
trying to get package data to show
aysim319 Jul 8, 2024
a38e080
installing dev package before testing in ci
aysim319 Jul 22, 2024
4e04b4c
adding dependency
aysim319 Jul 22, 2024
a54bc10
move comment to right package
aysim319 Jul 22, 2024
c115276
Update _delphi_utils_python/pyproject.toml
aysim319 Jul 22, 2024
13de21a
Merge pull request #1984 from cmu-delphi/1973-clean-up-delphi_utils
aysim319 Jul 24, 2024
526c142
Revert "Clean up delphi_utils "
aysim319 Jul 24, 2024
25ff20b
Merge pull request #2001 from cmu-delphi/revert-1984-1973-clean-up-de…
melange396 Jul 24, 2024
111000e
refactoring date parsing to seperate file
aysim319 Jul 16, 2024
2ca8867
first implimentation
aysim319 Jul 19, 2024
6497f8c
small cleanup and adding missing data
aysim319 Jul 19, 2024
963bdc6
changed wording and some logic
aysim319 Jul 22, 2024
33ae858
made test more explicit
aysim319 Jul 22, 2024
17e0fc5
add missing file
aysim319 Jul 22, 2024
b56fbae
cleaning up tests
aysim319 Jul 22, 2024
71c6e96
consolidating tests into one
aysim319 Jul 22, 2024
ba13c66
fixed wording
aysim319 Jul 22, 2024
c115c58
consolidating test/fixture
aysim319 Jul 23, 2024
6cbdaad
clean up test
aysim319 Jul 23, 2024
11f983b
Update google_symptoms/delphi_google_symptoms/patch.py
aysim319 Jul 23, 2024
c2b33db
clean up lint
aysim319 Jul 23, 2024
8125450
remove teardown
aysim319 Jul 23, 2024
6721ea5
cleaning and renaming
aysim319 Jul 23, 2024
5018b79
more explicit branching for regular run vs patching, renaming, cleaning
aysim319 Jul 23, 2024
36bee6a
cleanup and rewrite logic
aysim319 Jul 24, 2024
b7dab1a
avoid linking keywords in PR template
melange396 Jul 25, 2024
38de491
Update _delphi_utils_python/README.md
dshemetov Jul 25, 2024
15534fc
Merge pull request #1982 from cmu-delphi/ds/logger2
dshemetov Jul 25, 2024
f11ca4e
Merge pull request #2003 from cmu-delphi/pr_template_keyword_removal
melange396 Jul 26, 2024
aaa7766
Refactor Jenkins pipeline
korlaxxalrok Jul 29, 2024
4718bb9
Add separate build and package scripts
korlaxxalrok Jul 29, 2024
0da1791
Update script comments
korlaxxalrok Jul 29, 2024
9dc3c43
Remove unused script
korlaxxalrok Jul 29, 2024
936a4d5
Merge pull request #2005 from cmu-delphi/refactor-jenkins-pipeline
korlaxxalrok Jul 29, 2024
1cb791b
changes based on suggestion
aysim319 Jul 24, 2024
0e14bf1
standardizing output dir in test
aysim319 Jul 24, 2024
e181f54
changing back to session scope
aysim319 Jul 25, 2024
ff22993
more logging and update params
aysim319 Jul 26, 2024
cbebcc3
adding back conditional for num_export_days
aysim319 Jul 26, 2024
240fe5d
test_run does not like fixtures
aysim319 Jul 26, 2024
dd819a7
make deep copies of params fixtures
nmdefries Jul 26, 2024
20c14d9
linting
nmdefries Jul 26, 2024
a3a55ae
test patch check if num_export_days is set or not
nmdefries Jul 26, 2024
eb6a9be
patch fn takes params as an arg, like run_module
nmdefries Jul 29, 2024
46b6317
list values added using actual day as an example
nmdefries Jul 29, 2024
5532aac
move pull date creation into pull_gs_data
nmdefries Jul 29, 2024
d209a9c
don't modify num_export_days; define start/end date in terms of it an…
nmdefries Jul 30, 2024
66aa2cd
refer to params by name; patch_flag -> custom_run flag
nmdefries Jul 30, 2024
0708a22
use test data based on recent actual indicator run
nmdefries Jul 30, 2024
d0d3a7a
say where gold test data came from
nmdefries Jul 30, 2024
766f49e
not all date_utils tests need metadata
nmdefries Jul 30, 2024
a04bdea
formatting
nmdefries Jul 30, 2024
6fce6d8
fn docs
nmdefries Jul 30, 2024
528a1e3
lint and cleanup
aysim319 Jul 30, 2024
4168db5
Merge pull request #1999 from cmu-delphi/1996-patch-google-symptoms
aysim319 Jul 30, 2024
5e76ccb
adding more tests
aysim319 Aug 1, 2024
d480b1a
removed extra lag and made test more robust
aysim319 Aug 1, 2024
9d82c1a
export_start_date is optional since the first available date is baked in
aysim319 Aug 1, 2024
23b9134
need to account for historical / current run for adding lag
aysim319 Aug 2, 2024
f84ccce
adding validation script
aysim319 Aug 9, 2024
b784f30
fix typo
aysim319 Aug 9, 2024
9214a5f
fixing typo in test
aysim319 Aug 9, 2024
17b7e21
lint
aysim319 Aug 9, 2024
7a8a6b6
sample run for validation
aysim319 Aug 9, 2024
6b12388
remove unused input
aysim319 Aug 12, 2024
d5be1bd
remove unused import
aysim319 Aug 12, 2024
c7bf03e
Merge pull request #2015 from cmu-delphi/fix_new_date_for_google_symp…
nmdefries Aug 12, 2024
2184da7
added progress chunk to limit logging (#2024)
aysim319 Aug 15, 2024
ad089cf
add hhs geo level (#2036)
minhkhul Aug 27, 2024
d52dcd5
Add discussion of patching functionality to indicator manual (#2031)
nmdefries Aug 28, 2024
86399ad
Clean up delphi_utils (take 2) (#2014)
melange396 Sep 9, 2024
6f91fe4
chore: bump delphi_utils to 0.3.25
Sep 11, 2024
37900fd
chore: bump covidcast-indicators to 0.3.56
Sep 11, 2024
bd16b3f
[create-pull-request] automated change
minhkhul Sep 11, 2024
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.3.55
current_version = 0.3.56
commit = True
message = chore: bump covidcast-indicators to {new_version}
tag = False
13 changes: 8 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ The production branch is configured to automatically deploy to our production en

* everything else

All other branches are development branches. We don't enforce a naming policy.
All other branches are development branches. We don't enforce a naming policy, but it is recommended to prefix all branches you create with your name, username, or initials (e.g. `username/branch-name`).

We don't forbid force-pushing, but please keep to a minimum and be careful of using when modifying a branch at the same time as others.

## Issues

Expand All @@ -29,7 +31,7 @@ So, how does one go about developing a pipeline for a new data source?
### tl;dr

1. Create your new indicator branch from `main`.
2. Build it using the appropriate template, following the guidelines in the included README.md and REVIEW.md files.
2. Build it using the [indicator template](https://github.com/cmu-delphi/covidcast-indicators/tree/main/_template_python), following the guidelines in the included README.md, REVIEW.md, and INDICATOR_DEV_GUIDE.md files.
3. Make some stuff!
4. When your stuff works, push your development branch to remote, and open a PR against `main` for review.
5. Once your PR has been merged, consult with a platform engineer for the remaining production setup needs. They will create a deployment workflow for your indicator including any necessary production parameters. Production secrets are encrypted in the Ansible vault. This workflow will be tested in staging by admins, who will consult you about any problems they encounter.
Expand All @@ -50,7 +52,7 @@ git checkout -b dev-my-feature-branch

### Creating your indicator

Create a directory for your new indicator by making a copy of `_template_r` or `_template_python` depending on the programming language you intend to use. If using Python, add the name of the directory to the list found in `jobs > build > strategy > matrix > packages` in `.github/workflows/python-ci.yml`, which will enable automated checks for your indicator when you make PRs. The template copies of `README.md` and `REVIEW.md` include the minimum requirements for code structure, documentation, linting, testing, and method of configuration. Beyond that, we don't have any established restrictions on implementation; you can look at other existing indicators see some examples of code layout, organization, and general approach.
Create a directory for your new indicator by making a copy of `_template_python`. (We also make a `_template_r` available, but R should be only used as a last resort, due to complications using it in production.) Add the name of the directory to the list found in `jobs > build > strategy > matrix > packages` in `.github/workflows/python-ci.yml`, which will enable automated checks for your indicator when you make PRs. The template copies of `README.md` and `REVIEW.md` include the minimum requirements for code structure, documentation, linting, testing, and method of configuration. Beyond that, we don't have any established restrictions on implementation; you can look at other existing indicators see some examples of code layout, organization, and general approach.

* Consult your peers with questions! :handshake:

Expand All @@ -62,7 +64,7 @@ Once you have something that runs locally and passes tests you set up your remot
git push -u origin dev-my-feature-branch
```

You can then draft public API documentation for people who would fetch this
You can then draft [public API documentation](https://cmu-delphi.github.io/delphi-epidata/) for people who would fetch this
data from the API. Public API documentation is kept in the delphi-epidata
repository, and there is a [template Markdown
file](https://github.com/cmu-delphi/delphi-epidata/blob/main/docs/api/covidcast-signals/_source-template.md)
Expand Down Expand Up @@ -104,7 +106,8 @@ We use a branch-based git workflow coupled with [Jenkins](https://www.jenkins.io
* Package - Tar and gzip the built environment.
* Deploy - Trigger an Ansible playbook to place the built package onto the runtime host, place any necessary production configuration, and adjust the runtime envirnemnt (if necessary).

There are several additional Jenkins-specific files that will need to be created for each indicator, as well as some configuration additions to the runtime host. It will be important to pair with a platform engineer to prepare the necessary production environment needs, test the workflow, validate on production, and ultimately sign off on a production release.
There are several additional Jenkins-specific files that will need to be created for each indicator, as well as some configuration additions to the runtime host.
It will be important to pair with a platform engineer to prepare the necessary production environment needs, test the workflow, validate on production, and ultimately sign off on a production release.

### Preparing container images of indicators

Expand Down
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Itemize code/test/documentation changes and files added/removed.
- change1
- change2

### Fixes
- Fixes #(issue)
### Associated Issue(s)
- Addresses #(issue)
2 changes: 1 addition & 1 deletion .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
with:
python-version: 3.8
cache: "pip"
cache-dependency-path: "setup.py"
cache-dependency-path: "pyproject.toml"
- name: Install testing dependencies
run: |
python -m pip install --upgrade pip
Expand Down
53 changes: 38 additions & 15 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- TODO: #527 Get this list automatically from python-ci.yml at runtime.
*/

def indicator_list = ["backfill_corrections", "changehc", "claims_hosp", "google_symptoms", "hhs_hosp", "nchs_mortality", "quidel_covidtest", "sir_complainsalot", "doctor_visits", "nwss_wastewater", "nssp"]
def indicator_list = ['backfill_corrections', 'changehc', 'claims_hosp', 'google_symptoms', 'hhs_hosp', 'nchs_mortality', 'quidel_covidtest', 'sir_complainsalot', 'doctor_visits', 'nwss_wastewater', 'nssp']
def build_package_main = [:]
def build_package_prod = [:]
def deploy_staging = [:]
Expand All @@ -19,39 +19,62 @@ def deploy_production = [:]
pipeline {
agent any
stages {
stage('Build and Package main') {
stage('Build dev/feature branch') {
when {
not {
anyOf {
branch 'main'
branch 'prod'
}
}
}
steps {
script {
indicator_list.each { indicator ->
stage("Build ${indicator}") {
sh "jenkins/build-indicator.sh ${indicator}"
}
}
}
}
}
stage('Build and Package main branch') {
when {
branch "main";
branch 'main'
}
steps {
script {
indicator_list.each { indicator ->
build_package_main[indicator] = {
sh "jenkins/build-and-package.sh ${indicator} main"
stage("Build ${indicator}") {
sh "jenkins/build-indicator.sh ${indicator}"
}
stage("Package ${indicator}") {
sh "jenkins/package-indicator.sh ${indicator} main"
}
}
parallel build_package_main
}
}
}
stage('Build and Package prod') {
stage('Build and Package prod branch') {
when {
branch "prod";
branch 'prod'
}
steps {
script {
indicator_list.each { indicator ->
build_package_prod[indicator] = {
sh "jenkins/build-and-package.sh ${indicator} prod"
stage("Build ${indicator}") {
sh "jenkins/build-indicator.sh ${indicator}"
}
stage("Package ${indicator}") {
sh "jenkins/package-indicator.sh ${indicator} prod"
}
}
parallel build_package_prod
}
}
}
stage('Deploy staging') {
stage('Deploy main branch to staging env') {
when {
branch "main";
branch 'main'
}
steps {
script {
Expand All @@ -64,9 +87,9 @@ pipeline {
}
}
}
stage('Deploy production') {
stage('Deploy prod branch to production env') {
when {
branch "prod";
branch 'prod'
}
steps {
script {
Expand Down
4 changes: 2 additions & 2 deletions _delphi_utils_python/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[bumpversion]
current_version = 0.3.24
current_version = 0.3.25
commit = True
message = chore: bump delphi_utils to {new_version}
tag = False

[bumpversion:file:setup.py]
[bumpversion:file:pyproject.toml]

[bumpversion:file:delphi_utils/__init__.py]
2 changes: 1 addition & 1 deletion _delphi_utils_python/DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To install the module in your default version of Python, run the
following from this directory:

```
pip install .
pip install -e '.[dev]'
```

As described in each of the indicator code directories, you will want to install
Expand Down
9 changes: 5 additions & 4 deletions _delphi_utils_python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ venv:
install: venv
. env/bin/activate; \
pip install wheel ; \
pip install -e .
pip install -e '.[dev]'

install-ci: venv
. env/bin/activate; \
pip install wheel ; \
pip install .
pip install 'build[virtualenv]' pylint pytest pydocstyle wheel twine ; \
pip install '.[dev]'

lint:
. env/bin/activate; pylint delphi_utils --rcfile=../pyproject.toml
Expand All @@ -30,4 +30,5 @@ clean:

release: lint test
. env/bin/activate ; \
python setup.py sdist bdist_wheel
pip install 'build[virtualenv]' ; \
python -m build --sdist --wheel
31 changes: 29 additions & 2 deletions _delphi_utils_python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,32 @@ Submodules:
- `validator`: Data sanity checks and anomaly detection.


Source code can be found here:
[https://github.com/cmu-delphi/covidcast-indicators/](https://github.com/cmu-delphi/covidcast-indicators/)
Source code can be found here:
[https://github.com/cmu-delphi/covidcast-indicators/](https://github.com/cmu-delphi/covidcast-indicators/)

## Logger Usage

Single-thread usage.

```py
from delphi_utils.logger import get_structured_logger

logger = get_structured_logger('my_logger')
logger.info('Hello, world!')
```

Multi-thread usage.

```py
from delphi_utils.logger import get_structured_logger, pool_and_threadedlogger

def f(x, threaded_logger):
threaded_logger.info(f'x={x}')
return x*x

logger = get_structured_logger('my_logger')
logger.info('Hello, world!')
with pool_and_threadedlogger(logger, n_cpu) as (pool, threaded_logger):
for i in range(10):
pool.apply_async(f, args=(i, threaded_logger))
```
2 changes: 1 addition & 1 deletion _delphi_utils_python/delphi_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
from .nancodes import Nans
from .weekday import Weekday

__version__ = "0.3.24"
__version__ = "0.3.25"
6 changes: 4 additions & 2 deletions _delphi_utils_python/delphi_utils/geomap.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def add_population_column(
---------
data: pd.DataFrame
The dataframe with a FIPS code column.
geocode_type: {"fips", "zip"}
geocode_type:
The type of the geocode contained in geocode_col.
geocode_col: str, default None
The name of the column containing the geocodes. If None, uses the geocode_type
Expand Down Expand Up @@ -671,8 +671,10 @@ def aggregate_by_weighted_sum(
to a from_geo, e.g. "wastewater collection site").
to_geo: str
The column name of the geocode to aggregate to.
sensor: str
sensor_col: str
The column name of the sensor to aggregate.
time_col: str
The column name of the timestamp to aggregate over.
population_column: str
The column name of the population to weight the sensor by.

Expand Down
34 changes: 16 additions & 18 deletions _delphi_utils_python/delphi_utils/logger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Structured logger utility for creating JSON logs.

See the delphi_utils README.md for usage examples.

The Delphi group uses two ~identical versions of this file.
Try to keep them in sync with edits, for sanity.
https://github.com/cmu-delphi/covidcast-indicators/blob/main/_delphi_utils_python/delphi_utils/logger.py
Expand Down Expand Up @@ -133,19 +135,17 @@ class LoggerThread():
"""
A construct to use a logger from multiprocessing workers/jobs.

the bare structlog loggers are thread-safe but not multiprocessing-safe.
a `LoggerThread` will spawn a thread that listens to a mp.Queue
and logs messages from it with the provided logger,
so other processes can send logging messages to it
via the logger-like `SubLogger` interface.
the SubLogger even logs the pid of the caller.
The bare structlog loggers are thread-safe but not multiprocessing-safe. A
`LoggerThread` will spawn a thread that listens to a mp.Queue and logs
messages from it with the provided logger, so other processes can send
logging messages to it via the logger-like `SubLogger` interface. The
SubLogger even logs the pid of the caller.

this is good to use with a set of jobs that are part of a mp.Pool,
but isnt recommended for general use
because of overhead from threading and multiprocessing,
and because it might introduce lag to log messages.
This is good to use with a set of jobs that are part of a mp.Pool, but isnt
recommended for general use because of overhead from threading and
multiprocessing, and because it might introduce lag to log messages.

somewhat inspired by:
Somewhat inspired by:
docs.python.org/3/howto/logging-cookbook.html#logging-to-a-single-file-from-multiple-processes
"""

Expand Down Expand Up @@ -236,13 +236,11 @@ def pool_and_threadedlogger(logger, *poolargs):
"""
Provide (to a context) a multiprocessing Pool and a proxy to the supplied logger.

Emulates the multiprocessing.Pool() context manager,
but also provides (via a LoggerThread) a SubLogger proxy to logger
that can be safely used by pool workers.
The SubLogger proxy interface supports these methods: debug, info, warning, error,
and critical.
Also "cleans up" the pool by waiting for workers to complete
as it exits the context.
Emulates the multiprocessing.Pool() context manager, but also provides (via
a LoggerThread) a SubLogger proxy to logger that can be safely used by pool
workers. The SubLogger proxy interface supports these methods: debug, info,
warning, error, and critical. Also "cleans up" the pool by waiting for
workers to complete as it exits the context.
"""
with multiprocessing.Manager() as manager:
logger_thread = LoggerThread(logger, manager.Queue())
Expand Down
57 changes: 57 additions & 0 deletions _delphi_utils_python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[build-system]
requires = ["setuptools", "setuptools-scm>=8.0"]
build-backend = "setuptools.build_meta"

[project]
name = "delphi-utils"
version = "0.3.25"
description = "Shared Utility Functions for Indicators"
readme = "README.md"
requires-python = "== 3.8.*"
license = { text = "MIT License" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.8",
"License :: MIT",
]
dependencies = [
"boto3",
"covidcast",
"cvxpy",
"epiweeks",
"gitpython",
"importlib_resources>=1.3",
"numpy",
"pandas>=1.1.0",
"requests",
"slackclient",
"scs<3.2.6", # TODO: remove this ; it is a cvxpy dependency, and the excluded version appears to break our jenkins build. see: https://github.com/cvxgrp/scs/issues/283
"structlog",
"xlrd", # needed by Pandas to read Excel files
]

[project.urls]
Homepage = "https://github.com/cmu-delphi/covidcast-indicators"

[project.optional-dependencies]
dev = [
"darker[isort]~=2.1.1",
"pylint==2.8.3",
"pytest",
"pydocstyle",
"pytest-cov",
"mock",
"moto~=4.2.14",
"requests-mock",
"freezegun",
]
flash = ["scipy"]

[tool.setuptools.packages.find]
where = ["."]
include = ["delphi_utils"]
namespaces = true

[tool.setuptools.package-data]
"delphi_utils.data" = ["20*/*.csv"]
Loading