Skip to content

Commit aa3dedb

Browse files
authored
Merge pull request #1489 from cmu-delphi/release/delphi-epidata-4.1.24
Release Delphi Epidata 4.1.24
2 parents 11acb91 + 832422f commit aa3dedb

30 files changed

+1210
-900
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.1.23
2+
current_version = 4.1.24
33
commit = False
44
tag = False
55

@@ -9,10 +9,6 @@ tag = False
99

1010
[bumpversion:file:src/client/delphi_epidata.R]
1111

12-
[bumpversion:file:src/client/delphi_epidata.py]
13-
1412
[bumpversion:file:src/client/packaging/npm/package.json]
1513

16-
[bumpversion:file:src/client/packaging/pypi/setup.py]
17-
1814
[bumpversion:file:dev/local/setup.cfg]

.github/workflows/create-release.yml

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
inputs:
66
versionName:
7-
description: 'Semantic Version Number (i.e., 5.5.0 or patch, minor, major, prepatch, preminor, premajor, prerelease)'
7+
description: 'Semantic Version Number (i.e., 5.5.0 or patch, minor, major)'
88
required: true
99
default: patch
1010

@@ -27,11 +27,43 @@ jobs:
2727
python-version: 3.8
2828
- name: Change version number
2929
id: version
30+
# See this issue for explanation and testing:
31+
# https://github.com/cmu-delphi/delphi-epidata/pull/1473
3032
run: |
3133
python -m pip install bump2version
32-
echo -n "::set-output name=next_tag::"
33-
bump2version --list ${{ github.event.inputs.versionName }} | grep new_version | sed -r s,"^.*=",,
34-
- name: Create pull request into prod
34+
if [[ ${{ github.event.inputs.versionName }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
35+
# use given version number
36+
NEXT_TAG="${{ github.event.inputs.versionName }}"
37+
elif [[ ${{ github.event.inputs.versionName }} =~ ^(major|minor|patch)$ ]]; then
38+
# calculate new version number based on given tag
39+
NEXT_TAG=$(bump2version --dry-run --list ${{ github.event.inputs.versionName }} | grep ^new_version | sed -r s,"^.*=",,)
40+
else
41+
echo "\nInvalid version name: ${{ github.event.inputs.versionName }}"
42+
exit 1
43+
fi
44+
# apply given or calculated version number
45+
bump2version --new-version $NEXT_TAG _ignored_arg_
46+
# save version number for later
47+
echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
48+
- name: Get Python client file changes
49+
id: changed-py
50+
uses: dorny/paths-filter@v3
51+
with:
52+
base: "main"
53+
ref: "dev"
54+
filters: |
55+
python_client_changed:
56+
- src/client/delphi_epidata.py
57+
- src/client/packaging/pypi/**
58+
- name: Bump Python versions if client files changed
59+
if: steps.changed-py.outputs.python_client_changed == 'true'
60+
# _ignored_arg_ below is required because of tool quirk
61+
# https://github.com/c4urself/bump2version/issues/22
62+
run: |
63+
cd src/client/packaging/pypi
64+
# this is using the new literal version number (steps.version.outputs.next_tag) output from the bump2version step above, not the workflow input (github.event.inputs.versionName) which can be relative
65+
bump2version --allow-dirty --new-version ${{ steps.version.outputs.next_tag }} _ignored_arg_
66+
- name: Create pull request into main
3567
uses: peter-evans/create-pull-request@v3
3668
with:
3769
branch: release/delphi-epidata-${{ steps.version.outputs.next_tag }}

.github/workflows/release-helper.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@ jobs:
1313
if: github.repository_owner != 'cmu-delphi'
1414
run: exit 1
1515

16+
client_changed:
17+
needs: correct_repository
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Check out code
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 2
24+
- name: Get Python client file changes
25+
id: changed-py
26+
uses: dorny/paths-filter@v3
27+
with:
28+
# when base and ref are the same, changes are detected against the most recent commit before the push.
29+
# see https://github.com/dorny/paths-filter#usage for details.
30+
base: 'main'
31+
ref: 'main'
32+
filters: |
33+
python_client_changed:
34+
- src/client/delphi_epidata.py
35+
- src/client/packaging/pypi/**
36+
outputs:
37+
python_client_changed: ${{ steps.changed-py.outputs.python_client_changed }}
38+
1639
create_release:
1740
needs: correct_repository
1841
runs-on: ubuntu-latest
@@ -29,8 +52,8 @@ jobs:
2952
id: extract_version
3053
run: |
3154
python -m pip install bump2version
32-
echo -n "::set-output name=version::"
33-
bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,
55+
VERSION=$(bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,)
56+
echo "version=$VERSION" >> $GITHUB_OUTPUT
3457
- name: Create Release
3558
id: create_release
3659
uses: release-drafter/release-drafter@v5
@@ -45,7 +68,8 @@ jobs:
4568
tag_name: ${{ steps.create_release.outputs.tag_name }}
4669

4770
release_python_client:
48-
needs: create_release
71+
needs: [client_changed, create_release]
72+
if: needs.client_changed.outputs.python_client_changed == 'true'
4973
runs-on: ubuntu-latest
5074
steps:
5175
- name: Check out code
@@ -57,14 +81,14 @@ jobs:
5781
- name: Install build dependencies
5882
run: |
5983
python -m pip install --upgrade pip
60-
pip install wheel twine
84+
pip install build wheel twine
6185
- name: Prepare package
6286
run: |
6387
cp src/client/*.py src/client/packaging/pypi/delphi_epidata/
6488
- name: Create release
6589
working-directory: src/client/packaging/pypi
6690
run: |
67-
python setup.py sdist bdist_wheel
91+
python -m build --sdist --wheel
6892
- uses: actions/upload-artifact@v2
6993
with:
7094
name: delphi_epidata_py
@@ -80,8 +104,8 @@ jobs:
80104
with:
81105
user: __token__
82106
password: ${{ secrets.DELPHI_PYPI_PROD_TOKEN }}
83-
packages_dir: src/client/packaging/pypi/dist/
84-
skip_existing: true
107+
packages-dir: src/client/packaging/pypi/dist/
108+
skip-existing: true
85109
# repository_url: https://test.pypi.org/legacy/
86110

87111
release_js_client:
@@ -95,7 +119,7 @@ jobs:
95119
uses: actions/checkout@v2
96120
- uses: actions/setup-node@v2
97121
with:
98-
node-version: '16.x'
122+
node-version: "16.x"
99123
- name: Cache Node.js modules
100124
uses: actions/cache@v2
101125
with:

dev/local/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = Delphi Development
3-
version = 4.1.23
3+
version = 4.1.24
44

55
[options]
66
packages =

docs/api/client_libraries.md

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,83 +6,81 @@ nav_order: 1
66

77
# Epidata API Client Libraries
88

9+
To access Delphi Epidata programmatically, we recommend our client libraries:
10+
11+
- R: [epidatr](https://cmu-delphi.github.io/epidatr/),
12+
- Python: [delphi-epidata](https://pypi.org/project/delphi-epidata/) (soon to be replaced with [epidatpy](https://github.com/cmu-delphi/epidatpy)),
13+
- Javascript: [delphi-epidata](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.js).
14+
915
For anyone looking for COVIDCast data, please visit our [COVIDCast Libraries](covidcast_clients.md).
1016

11-
A full-featured Epidata client for R is available at
12-
[epidatr](https://github.com/cmu-delphi/epidatr) and
13-
[also on CRAN](https://cran.r-project.org/web/packages/epidatr/index.html).
14-
15-
We are currently working on a new full-featured Epidata client for Python. It is not ready
16-
for release yet, but you can track our development progress and help us test it out at
17-
[epidatpy](https://github.com/cmu-delphi/epidatpy).
18-
19-
In the meantime, minimalist Epidata clients remain available for
20-
[Python](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.py),
21-
[JavaScript](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.js),
22-
and
23-
[R (legacy)](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.R).
24-
The following samples show how to import the library and fetch Delphi's COVID-19
25-
Surveillance Streams from Facebook Survey CLI for county 06001, and days
17+
The following samples show how to import the library and fetch Delphi's
18+
COVID-19 Surveillance Streams from Facebook Survey CLI for county 06001 and days
2619
`20200401` and `20200405-20200414` (11 days total).
2720

2821
### R
2922

30-
````R
31-
# [Optional] configure your API key, if desired
32-
# Interactive. See https://cmu-delphi.github.io/epidatr/articles/epidatr.html#api-keys for details.
23+
Install [`epidatr` from CRAN](https://cran.r-project.org/package=epidatr)
24+
with `install.packages("epidatr")`.
25+
26+
```R
27+
# Configure API key interactively, if needed. See
28+
# https://cmu-delphi.github.io/epidatr/articles/epidatr.html#api-keys for details.
3329
#save_api_key()
34-
# Import
3530
library(epidatr)
36-
# Fetch data
3731
res <- pub_covidcast('fb-survey', 'smoothed_cli', 'county', 'day', geo_values = '06001',
3832
time_values = c(20200401, 20200405:20200414))
3933
cat(res)
40-
````
34+
```
4135

4236
### Python
4337

44-
Optionally install the [package from PyPI](https://pypi.org/project/delphi-epidata/) using pip(env):
45-
````bash
46-
pip install delphi-epidata
47-
````
38+
Install [`delphi-epidata` from PyPI](https://pypi.org/project/delphi-epidata/) with
39+
`pip install delphi-epidata`.
4840

49-
Otherwise, place
50-
[`delphi_epidata.py`](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.py)
51-
in the same directory as your Python script.
52-
53-
````python
54-
# Import
41+
```python
5542
from delphi_epidata import Epidata
56-
# [Optional] configure your API key, if desired
43+
# Configure API key, if needed.
5744
#Epidata.auth = ('epidata', <your API key>)
58-
# Fetch data
5945
res = Epidata.covidcast('fb-survey', 'smoothed_cli', 'day', 'county', [20200401, Epidata.range(20200405, 20200414)], '06001')
6046
print(res['result'], res['message'], len(res['epidata']))
61-
````
47+
```
6248

6349
### JavaScript (in a web browser)
6450

65-
The minimalist JavaScript client does not currently support API keys. If you need API key support in JavaScript, contact [email protected].
51+
The minimalist JavaScript client does not currently support API keys.
52+
If you need API key support in JavaScript, contact [email protected].
6653

67-
````html
68-
<!-- Imports -->
54+
```html
6955
<script src="delphi_epidata.js"></script>
70-
<!-- Fetch data -->
7156
<script>
72-
EpidataAsync.covidcast('fb-survey', 'smoothed_cli', 'day', 'county', [20200401, EpidataAsync.range(20200405, 20200414)], '06001').then((res) => {
73-
console.log(res.result, res.message, res.epidata != null ? res.epidata.length : 0);
57+
EpidataAsync.covidcast(
58+
"fb-survey",
59+
"smoothed_cli",
60+
"day",
61+
"county",
62+
[20200401, EpidataAsync.range(20200405, 20200414)],
63+
"06001"
64+
).then((res) => {
65+
console.log(
66+
res.result,
67+
res.message,
68+
res.epidata != null ? res.epidata.length : 0
69+
);
7470
});
7571
</script>
76-
````
72+
```
7773

7874
### R (legacy)
7975

76+
The old Delphi Epidata R client is available
77+
[here](https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/client/delphi_epidata.R),
78+
but its use is discouraged.
79+
8080
```R
81-
# [Optional] configure your API key, if desired
81+
# Configure API key, if needed.
8282
#option('epidata.auth', <your API key>)
83-
# Import
8483
source('delphi_epidata.R')
85-
# Fetch data
8684
res <- Epidata$covidcast('fb-survey', 'smoothed_cli', 'day', 'county', list(20200401, Epidata$range(20200405, 20200414)), '06001')
8785
cat(paste(res$result, res$message, length(res$epidata), "\n"))
8886
```

0 commit comments

Comments
 (0)