Skip to content

Commit

Permalink
Merge pull request #1489 from cmu-delphi/release/delphi-epidata-4.1.24
Browse files Browse the repository at this point in the history
Release Delphi Epidata 4.1.24
  • Loading branch information
melange396 authored Jul 9, 2024
2 parents 11acb91 + 832422f commit aa3dedb
Show file tree
Hide file tree
Showing 30 changed files with 1,210 additions and 900 deletions.
6 changes: 1 addition & 5 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 4.1.23
current_version = 4.1.24
commit = False
tag = False

Expand All @@ -9,10 +9,6 @@ tag = False

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

[bumpversion:file:src/client/delphi_epidata.py]

[bumpversion:file:src/client/packaging/npm/package.json]

[bumpversion:file:src/client/packaging/pypi/setup.py]

[bumpversion:file:dev/local/setup.cfg]
40 changes: 36 additions & 4 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
versionName:
description: 'Semantic Version Number (i.e., 5.5.0 or patch, minor, major, prepatch, preminor, premajor, prerelease)'
description: 'Semantic Version Number (i.e., 5.5.0 or patch, minor, major)'
required: true
default: patch

Expand All @@ -27,11 +27,43 @@ jobs:
python-version: 3.8
- name: Change version number
id: version
# See this issue for explanation and testing:
# https://github.com/cmu-delphi/delphi-epidata/pull/1473
run: |
python -m pip install bump2version
echo -n "::set-output name=next_tag::"
bump2version --list ${{ github.event.inputs.versionName }} | grep new_version | sed -r s,"^.*=",,
- name: Create pull request into prod
if [[ ${{ github.event.inputs.versionName }} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# use given version number
NEXT_TAG="${{ github.event.inputs.versionName }}"
elif [[ ${{ github.event.inputs.versionName }} =~ ^(major|minor|patch)$ ]]; then
# calculate new version number based on given tag
NEXT_TAG=$(bump2version --dry-run --list ${{ github.event.inputs.versionName }} | grep ^new_version | sed -r s,"^.*=",,)
else
echo "\nInvalid version name: ${{ github.event.inputs.versionName }}"
exit 1
fi
# apply given or calculated version number
bump2version --new-version $NEXT_TAG _ignored_arg_
# save version number for later
echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
- name: Get Python client file changes
id: changed-py
uses: dorny/paths-filter@v3
with:
base: "main"
ref: "dev"
filters: |
python_client_changed:
- src/client/delphi_epidata.py
- src/client/packaging/pypi/**
- name: Bump Python versions if client files changed
if: steps.changed-py.outputs.python_client_changed == 'true'
# _ignored_arg_ below is required because of tool quirk
# https://github.com/c4urself/bump2version/issues/22
run: |
cd src/client/packaging/pypi
# 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
bump2version --allow-dirty --new-version ${{ steps.version.outputs.next_tag }} _ignored_arg_
- name: Create pull request into main
uses: peter-evans/create-pull-request@v3
with:
branch: release/delphi-epidata-${{ steps.version.outputs.next_tag }}
Expand Down
40 changes: 32 additions & 8 deletions .github/workflows/release-helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,29 @@ jobs:
if: github.repository_owner != 'cmu-delphi'
run: exit 1

client_changed:
needs: correct_repository
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Get Python client file changes
id: changed-py
uses: dorny/paths-filter@v3
with:
# when base and ref are the same, changes are detected against the most recent commit before the push.
# see https://github.com/dorny/paths-filter#usage for details.
base: 'main'
ref: 'main'
filters: |
python_client_changed:
- src/client/delphi_epidata.py
- src/client/packaging/pypi/**
outputs:
python_client_changed: ${{ steps.changed-py.outputs.python_client_changed }}

create_release:
needs: correct_repository
runs-on: ubuntu-latest
Expand All @@ -29,8 +52,8 @@ jobs:
id: extract_version
run: |
python -m pip install bump2version
echo -n "::set-output name=version::"
bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,
VERSION=$(bump2version --dry-run --list patch | grep ^current_version | sed -r s,"^.*=",,)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: release-drafter/release-drafter@v5
Expand All @@ -45,7 +68,8 @@ jobs:
tag_name: ${{ steps.create_release.outputs.tag_name }}

release_python_client:
needs: create_release
needs: [client_changed, create_release]
if: needs.client_changed.outputs.python_client_changed == 'true'
runs-on: ubuntu-latest
steps:
- name: Check out code
Expand All @@ -57,14 +81,14 @@ jobs:
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install wheel twine
pip install build wheel twine
- name: Prepare package
run: |
cp src/client/*.py src/client/packaging/pypi/delphi_epidata/
- name: Create release
working-directory: src/client/packaging/pypi
run: |
python setup.py sdist bdist_wheel
python -m build --sdist --wheel
- uses: actions/upload-artifact@v2
with:
name: delphi_epidata_py
Expand All @@ -80,8 +104,8 @@ jobs:
with:
user: __token__
password: ${{ secrets.DELPHI_PYPI_PROD_TOKEN }}
packages_dir: src/client/packaging/pypi/dist/
skip_existing: true
packages-dir: src/client/packaging/pypi/dist/
skip-existing: true
# repository_url: https://test.pypi.org/legacy/

release_js_client:
Expand All @@ -95,7 +119,7 @@ jobs:
uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
node-version: "16.x"
- name: Cache Node.js modules
uses: actions/cache@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion dev/local/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = Delphi Development
version = 4.1.23
version = 4.1.24

[options]
packages =
Expand Down
86 changes: 42 additions & 44 deletions docs/api/client_libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,81 @@ nav_order: 1

# Epidata API Client Libraries

To access Delphi Epidata programmatically, we recommend our client libraries:

- R: [epidatr](https://cmu-delphi.github.io/epidatr/),
- Python: [delphi-epidata](https://pypi.org/project/delphi-epidata/) (soon to be replaced with [epidatpy](https://github.com/cmu-delphi/epidatpy)),
- Javascript: [delphi-epidata](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.js).

For anyone looking for COVIDCast data, please visit our [COVIDCast Libraries](covidcast_clients.md).

A full-featured Epidata client for R is available at
[epidatr](https://github.com/cmu-delphi/epidatr) and
[also on CRAN](https://cran.r-project.org/web/packages/epidatr/index.html).

We are currently working on a new full-featured Epidata client for Python. It is not ready
for release yet, but you can track our development progress and help us test it out at
[epidatpy](https://github.com/cmu-delphi/epidatpy).

In the meantime, minimalist Epidata clients remain available for
[Python](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.py),
[JavaScript](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.js),
and
[R (legacy)](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.R).
The following samples show how to import the library and fetch Delphi's COVID-19
Surveillance Streams from Facebook Survey CLI for county 06001, and days
The following samples show how to import the library and fetch Delphi's
COVID-19 Surveillance Streams from Facebook Survey CLI for county 06001 and days
`20200401` and `20200405-20200414` (11 days total).

### R

````R
# [Optional] configure your API key, if desired
# Interactive. See https://cmu-delphi.github.io/epidatr/articles/epidatr.html#api-keys for details.
Install [`epidatr` from CRAN](https://cran.r-project.org/package=epidatr)
with `install.packages("epidatr")`.

```R
# Configure API key interactively, if needed. See
# https://cmu-delphi.github.io/epidatr/articles/epidatr.html#api-keys for details.
#save_api_key()
# Import
library(epidatr)
# Fetch data
res <- pub_covidcast('fb-survey', 'smoothed_cli', 'county', 'day', geo_values = '06001',
time_values = c(20200401, 20200405:20200414))
cat(res)
````
```

### Python

Optionally install the [package from PyPI](https://pypi.org/project/delphi-epidata/) using pip(env):
````bash
pip install delphi-epidata
````
Install [`delphi-epidata` from PyPI](https://pypi.org/project/delphi-epidata/) with
`pip install delphi-epidata`.

Otherwise, place
[`delphi_epidata.py`](https://github.com/cmu-delphi/delphi-epidata/blob/master/src/client/delphi_epidata.py)
in the same directory as your Python script.

````python
# Import
```python
from delphi_epidata import Epidata
# [Optional] configure your API key, if desired
# Configure API key, if needed.
#Epidata.auth = ('epidata', <your API key>)
# Fetch data
res = Epidata.covidcast('fb-survey', 'smoothed_cli', 'day', 'county', [20200401, Epidata.range(20200405, 20200414)], '06001')
print(res['result'], res['message'], len(res['epidata']))
````
```

### JavaScript (in a web browser)

The minimalist JavaScript client does not currently support API keys. If you need API key support in JavaScript, contact delphi-support+privacy@andrew.cmu.edu.
The minimalist JavaScript client does not currently support API keys.
If you need API key support in JavaScript, contact delphi-support+privacy@andrew.cmu.edu.

````html
<!-- Imports -->
```html
<script src="delphi_epidata.js"></script>
<!-- Fetch data -->
<script>
EpidataAsync.covidcast('fb-survey', 'smoothed_cli', 'day', 'county', [20200401, EpidataAsync.range(20200405, 20200414)], '06001').then((res) => {
console.log(res.result, res.message, res.epidata != null ? res.epidata.length : 0);
EpidataAsync.covidcast(
"fb-survey",
"smoothed_cli",
"day",
"county",
[20200401, EpidataAsync.range(20200405, 20200414)],
"06001"
).then((res) => {
console.log(
res.result,
res.message,
res.epidata != null ? res.epidata.length : 0
);
});
</script>
````
```

### R (legacy)

The old Delphi Epidata R client is available
[here](https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/client/delphi_epidata.R),
but its use is discouraged.

```R
# [Optional] configure your API key, if desired
# Configure API key, if needed.
#option('epidata.auth', <your API key>)
# Import
source('delphi_epidata.R')
# Fetch data
res <- Epidata$covidcast('fb-survey', 'smoothed_cli', 'day', 'county', list(20200401, Epidata$range(20200405, 20200414)), '06001')
cat(paste(res$result, res$message, length(res$epidata), "\n"))
```
Loading

0 comments on commit aa3dedb

Please sign in to comment.