Skip to content

Commit ada4165

Browse files
authored
Merge pull request #2052 from cmu-delphi/release/indicators_v0.3.56_utils_v0.3.25
Release covidcast-indicators 0.3.56
2 parents b338a09 + 9703073 commit ada4165

Some content is hidden

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

60 files changed

+51794
-406
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.3.55
2+
current_version = 0.3.56
33
commit = True
44
message = chore: bump covidcast-indicators to {new_version}
55
tag = False

.github/CONTRIBUTING.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ The production branch is configured to automatically deploy to our production en
1212

1313
* everything else
1414

15-
All other branches are development branches. We don't enforce a naming policy.
15+
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`).
16+
17+
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.
1618

1719
## Issues
1820

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

3133
1. Create your new indicator branch from `main`.
32-
2. Build it using the appropriate template, following the guidelines in the included README.md and REVIEW.md files.
34+
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.
3335
3. Make some stuff!
3436
4. When your stuff works, push your development branch to remote, and open a PR against `main` for review.
3537
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.
@@ -50,7 +52,7 @@ git checkout -b dev-my-feature-branch
5052

5153
### Creating your indicator
5254

53-
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.
55+
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.
5456

5557
* Consult your peers with questions! :handshake:
5658

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

65-
You can then draft public API documentation for people who would fetch this
67+
You can then draft [public API documentation](https://cmu-delphi.github.io/delphi-epidata/) for people who would fetch this
6668
data from the API. Public API documentation is kept in the delphi-epidata
6769
repository, and there is a [template Markdown
6870
file](https://github.com/cmu-delphi/delphi-epidata/blob/main/docs/api/covidcast-signals/_source-template.md)
@@ -104,7 +106,8 @@ We use a branch-based git workflow coupled with [Jenkins](https://www.jenkins.io
104106
* Package - Tar and gzip the built environment.
105107
* 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).
106108

107-
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.
109+
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.
110+
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.
108111

109112
### Preparing container images of indicators
110113

.github/pull_request_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ Itemize code/test/documentation changes and files added/removed.
66
- change1
77
- change2
88

9-
### Fixes
10-
- Fixes #(issue)
9+
### Associated Issue(s)
10+
- Addresses #(issue)

.github/workflows/publish-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
- name: Release
8787
run: |
8888
make release
89-
- uses: actions/upload-artifact@v2
89+
- uses: actions/upload-artifact@v4
9090
with:
9191
name: delphi_utils
9292
path: _delphi_utils_python/dist/*.tar.gz

.github/workflows/python-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
with:
5252
python-version: 3.8
5353
cache: "pip"
54-
cache-dependency-path: "setup.py"
54+
cache-dependency-path: "pyproject.toml"
5555
- name: Install testing dependencies
5656
run: |
5757
python -m pip install --upgrade pip

Jenkinsfile

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- TODO: #527 Get this list automatically from python-ci.yml at runtime.
1111
*/
1212

13-
def indicator_list = ["backfill_corrections", "changehc", "claims_hosp", "google_symptoms", "hhs_hosp", "nchs_mortality", "quidel_covidtest", "sir_complainsalot", "doctor_visits", "nwss_wastewater", "nssp"]
13+
def indicator_list = ['backfill_corrections', 'changehc', 'claims_hosp', 'google_symptoms', 'hhs_hosp', 'nchs_mortality', 'quidel_covidtest', 'sir_complainsalot', 'doctor_visits', 'nwss_wastewater', 'nssp']
1414
def build_package_main = [:]
1515
def build_package_prod = [:]
1616
def deploy_staging = [:]
@@ -19,39 +19,62 @@ def deploy_production = [:]
1919
pipeline {
2020
agent any
2121
stages {
22-
stage('Build and Package main') {
22+
stage('Build dev/feature branch') {
23+
when {
24+
not {
25+
anyOf {
26+
branch 'main'
27+
branch 'prod'
28+
}
29+
}
30+
}
31+
steps {
32+
script {
33+
indicator_list.each { indicator ->
34+
stage("Build ${indicator}") {
35+
sh "jenkins/build-indicator.sh ${indicator}"
36+
}
37+
}
38+
}
39+
}
40+
}
41+
stage('Build and Package main branch') {
2342
when {
24-
branch "main";
43+
branch 'main'
2544
}
2645
steps {
2746
script {
2847
indicator_list.each { indicator ->
29-
build_package_main[indicator] = {
30-
sh "jenkins/build-and-package.sh ${indicator} main"
48+
stage("Build ${indicator}") {
49+
sh "jenkins/build-indicator.sh ${indicator}"
50+
}
51+
stage("Package ${indicator}") {
52+
sh "jenkins/package-indicator.sh ${indicator} main"
3153
}
3254
}
33-
parallel build_package_main
3455
}
3556
}
3657
}
37-
stage('Build and Package prod') {
58+
stage('Build and Package prod branch') {
3859
when {
39-
branch "prod";
60+
branch 'prod'
4061
}
4162
steps {
4263
script {
4364
indicator_list.each { indicator ->
44-
build_package_prod[indicator] = {
45-
sh "jenkins/build-and-package.sh ${indicator} prod"
65+
stage("Build ${indicator}") {
66+
sh "jenkins/build-indicator.sh ${indicator}"
67+
}
68+
stage("Package ${indicator}") {
69+
sh "jenkins/package-indicator.sh ${indicator} prod"
4670
}
4771
}
48-
parallel build_package_prod
4972
}
5073
}
5174
}
52-
stage('Deploy staging') {
75+
stage('Deploy main branch to staging env') {
5376
when {
54-
branch "main";
77+
branch 'main'
5578
}
5679
steps {
5780
script {
@@ -64,9 +87,9 @@ pipeline {
6487
}
6588
}
6689
}
67-
stage('Deploy production') {
90+
stage('Deploy prod branch to production env') {
6891
when {
69-
branch "prod";
92+
branch 'prod'
7093
}
7194
steps {
7295
script {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[bumpversion]
2-
current_version = 0.3.24
2+
current_version = 0.3.25
33
commit = True
44
message = chore: bump delphi_utils to {new_version}
55
tag = False
66

7-
[bumpversion:file:setup.py]
7+
[bumpversion:file:pyproject.toml]
88

99
[bumpversion:file:delphi_utils/__init__.py]

_delphi_utils_python/DEVELOP.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To install the module in your default version of Python, run the
99
following from this directory:
1010

1111
```
12-
pip install .
12+
pip install -e '.[dev]'
1313
```
1414

1515
As described in each of the indicator code directories, you will want to install

_delphi_utils_python/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ venv:
66
install: venv
77
. env/bin/activate; \
88
pip install wheel ; \
9-
pip install -e .
9+
pip install -e '.[dev]'
1010

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

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

3131
release: lint test
3232
. env/bin/activate ; \
33-
python setup.py sdist bdist_wheel
33+
pip install 'build[virtualenv]' ; \
34+
python -m build --sdist --wheel

_delphi_utils_python/README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,32 @@ Submodules:
1717
- `validator`: Data sanity checks and anomaly detection.
1818

1919

20-
Source code can be found here:
21-
[https://github.com/cmu-delphi/covidcast-indicators/](https://github.com/cmu-delphi/covidcast-indicators/)
20+
Source code can be found here:
21+
[https://github.com/cmu-delphi/covidcast-indicators/](https://github.com/cmu-delphi/covidcast-indicators/)
22+
23+
## Logger Usage
24+
25+
Single-thread usage.
26+
27+
```py
28+
from delphi_utils.logger import get_structured_logger
29+
30+
logger = get_structured_logger('my_logger')
31+
logger.info('Hello, world!')
32+
```
33+
34+
Multi-thread usage.
35+
36+
```py
37+
from delphi_utils.logger import get_structured_logger, pool_and_threadedlogger
38+
39+
def f(x, threaded_logger):
40+
threaded_logger.info(f'x={x}')
41+
return x*x
42+
43+
logger = get_structured_logger('my_logger')
44+
logger.info('Hello, world!')
45+
with pool_and_threadedlogger(logger, n_cpu) as (pool, threaded_logger):
46+
for i in range(10):
47+
pool.apply_async(f, args=(i, threaded_logger))
48+
```

0 commit comments

Comments
 (0)