Skip to content

Commit 5ca1bef

Browse files
melange396krivarddmytrotskokorlaxxalrok
authored
Merge pull request #1178 from cmu-delphi/release/delphi-epidata-4.1.0
* API keys (#1115) * chore: release delphi-epidata 4.1.0 --------- Co-authored-by: Katie Mazaitis <[email protected]> Co-authored-by: Dmytro Trotsko <[email protected]> Co-authored-by: Brian Clark <[email protected]> Co-authored-by: george haff <[email protected]>
2 parents d45a18c + 48a25c4 commit 5ca1bef

Some content is hidden

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

68 files changed

+1875
-411
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.4.12
2+
current_version = 4.1.0
33
commit = False
44
tag = False
55

.dockerignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/delphi-epidata
2-
/.mypy_cache
2+
**/.mypy_cache
33
/.github
44
/docs
5-
__pycache__
6-
/node_modules
5+
**/__pycache__
6+
**/.pytest_cache
7+
**/node_modules

.env.example

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
FLASK_DEBUG=True
22
SQLALCHEMY_DATABASE_URI=sqlite:///test.db
33
FLASK_SECRET=abc
4-
SECRET_TWITTER=abc
5-
SECRET_GHT=abc
6-
SECRET_FLUVIEW=abc
7-
SECRET_CDC=abc
8-
SECRET_SENSORS=abc
9-
SECRET_SENSOR_TWTR=abc
10-
SECRET_SENSOR_GFT=abc
11-
SECRET_SENSOR_GHT=abc
12-
SECRET_SENSOR_GHTJ=abc
13-
SECRET_SENSOR_CDC=abc
14-
SECRET_SENSOR_QUID=abc
15-
SECRET_SENSOR_WIKI=abc
16-
SECRET_QUIDEL=abc
17-
SECRET_NOROSTAT=abc
18-
SECRET_AFHSB=abc
4+
#API_KEY_REQUIRED_STARTING_AT=2021-07-30
5+
API_KEY_ADMIN_PASSWORD=abc
6+
API_KEY_REGISTER_WEBHOOK_TOKEN=abc

.github/workflows/ci.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,24 +53,31 @@ jobs:
5353
run: |
5454
docker build -t delphi_database_epidata -f ./repos/delphi/delphi-epidata/dev/docker/database/epidata/Dockerfile .
5555
docker build -t delphi_web_python -f repos/delphi/delphi-epidata/dev/docker/python/Dockerfile .
56+
sudo docker build -t delphi_redis -f repos/delphi/delphi-epidata/dev/docker/redis/Dockerfile .
5657
cd ./repos/delphi/delphi-epidata
5758
docker build -t delphi_web_epidata -f ./devops/Dockerfile .
5859
cd ../../../
5960
6061
# MODULE_NAME specifies the location of the `app` variable, the actual WSGI application object to run.
6162
# see https://github.com/tiangolo/meinheld-gunicorn-docker#module_name
62-
- name: Start services
63+
- name: Start database and Redis services
6364
run: |
6465
docker network create --driver bridge delphi-net
6566
docker run --rm -d -p 13306:3306 --network delphi-net --name delphi_database_epidata --cap-add=sys_nice delphi_database_epidata
66-
docker run --rm -d -p 10080:80 --env "MODULE_NAME=delphi.epidata.server.main" --env "SQLALCHEMY_DATABASE_URI=mysql+mysqldb://user:pass@delphi_database_epidata:3306/epidata" --env "FLASK_SECRET=abc" --env "FLASK_PREFIX=/epidata" --network delphi-net --name delphi_web_epidata delphi_web_epidata
67-
docker ps
67+
docker run --rm -d -p 6379:6379 --network delphi-net --env "REDIS_PASSWORD=1234" --name delphi_redis delphi_redis
68+
6869
6970
- run: |
7071
wget https://raw.githubusercontent.com/eficode/wait-for/master/wait-for
7172
chmod +x wait-for
7273
./wait-for localhost:13306 -- echo 'ready'
7374
sleep 10s
75+
76+
- name: Start delphi_web_epidata
77+
run: |
78+
docker run --rm -d -p 10080:80 --env "MODULE_NAME=delphi.epidata.server.main" --env "SQLALCHEMY_DATABASE_URI=mysql+mysqldb://user:pass@delphi_database_epidata:3306/epidata" --env "FLASK_SECRET=abc" --env "FLASK_PREFIX=/epidata" --env "REDIS_HOST=delphi_redis" --env "REDIS_PASSWORD=1234" --env "API_KEY_REGISTER_WEBHOOK_TOKEN=abc" --env "API_KEY_ADMIN_PASSWORD=test_admin_password" --network delphi-net --name delphi_web_epidata delphi_web_epidata
79+
docker ps
80+
7481
- name: Run Unit Tests
7582
run: |
7683
docker run --rm --network delphi-net --env "SQLALCHEMY_DATABASE_URI=mysql+mysqldb://user:pass@delphi_database_epidata:3306/epidata" --env "FLASK_SECRET=abc" delphi_web_python python -m pytest --import-mode importlib repos/delphi/delphi-epidata/tests
@@ -81,7 +88,7 @@ jobs:
8188
8289
- name: Clean Up
8390
run: |
84-
docker stop delphi_database_epidata delphi_web_epidata
91+
docker stop delphi_database_epidata delphi_web_epidata delphi_redis
8592
docker network remove delphi-net
8693
8794
build_js_client:
@@ -108,7 +115,8 @@ jobs:
108115
image:
109116
needs: build
110117
# only on main and dev branch
111-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
118+
# TODO: #1112 Remove `|| github.ref == 'refs/heads/api-keys'` after transition to production status.
119+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/api-keys'
112120

113121
runs-on: ubuntu-latest
114122
steps:

dev/docker/python/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM python:3.8-buster
22

3+
RUN apt-get update && apt-get install -y r-base && Rscript -e "install.packages(c('httr','xml2'))"
4+
35
WORKDIR /usr/src/app
46

57
COPY repos repos

dev/docker/redis/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM redis
2+
3+
ENV REDIS_PASSWORD=$REDIS_PASSWORD
4+
5+
CMD ["sh", "-c", "exec redis-server --requirepass \"$REDIS_PASSWORD\""]

dev/local/Makefile

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ CWD:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
6464
NOW:=$(shell date "+%Y-%m-%d")
6565
LOG_WEB:=delphi_web_epidata_$(NOW).log
6666
LOG_DB:=delphi_database_epidata_$(NOW).log
67+
LOG_REDIS:=delphi_redis_instance_$(NOW).log
6768
WEB_CONTAINER_ID:=$(shell docker ps -q --filter 'name=delphi_web_epidata')
6869
DATABASE_CONTAINER_ID:=$(shell docker ps -q --filter 'name=delphi_database_epidata')
70+
REDIS_CONTAINER_ID:=$(shell docker ps -q --filter 'name=delphi_redis')
6971

7072
M1=
7173
ifeq ($(shell uname -smp), Darwin arm64 arm)
@@ -98,6 +100,10 @@ web:
98100
--env "MODULE_NAME=delphi.epidata.server.main" \
99101
--env "SQLALCHEMY_DATABASE_URI=$(sqlalchemy_uri)" \
100102
--env "FLASK_SECRET=abc" --env "FLASK_PREFIX=/epidata" --env "LOG_DEBUG" \
103+
--env "REDIS_HOST=delphi_redis" \
104+
--env "REDIS_PASSWORD=1234" \
105+
--env "API_KEY_ADMIN_PASSWORD=test_admin_password" \
106+
--env "API_KEY_REGISTER_WEBHOOK_TOKEN=abc" \
101107
--network delphi-net --name delphi_web_epidata \
102108
delphi_web_epidata >$(LOG_WEB) 2>&1 &
103109

@@ -136,8 +142,25 @@ py:
136142
$(M1) \
137143
-f repos/delphi/delphi-epidata/dev/docker/python/Dockerfile .
138144

145+
.PHONY=redis
146+
redis:
147+
@# Stop container if running
148+
@if [ $(REDIS_CONTAINER_ID) ]; then\
149+
docker stop $(REDIS_CONTAINER_ID);\
150+
fi
151+
152+
@docker build -t delphi_redis \
153+
$(M1) \
154+
-f repos/delphi/delphi-epidata/dev/docker/redis/Dockerfile .
155+
156+
@docker run --rm -d -p 127.0.0.1:6379:6379 \
157+
$(M1) \
158+
--network delphi-net \
159+
--env "REDIS_PASSWORD=1234" \
160+
--name delphi_redis delphi_redis >$(LOG_REDIS) 2>&1 &
161+
139162
.PHONY=all
140-
all: db web py
163+
all: db web py redis
141164

142165
.PHONY=test
143166
test:
@@ -149,6 +172,17 @@ test:
149172
--env "FLASK_SECRET=abc" \
150173
delphi_web_python python -m pytest --import-mode importlib $(pdb) $(test) | tee test_output_$(NOW).log
151174

175+
.PHONY=r-test
176+
r-test:
177+
@docker run -i --rm --network delphi-net \
178+
$(M1) \
179+
--mount type=bind,source=$(CWD)repos/delphi/delphi-epidata,target=/usr/src/app/repos/delphi/delphi-epidata,readonly \
180+
--mount type=bind,source=$(CWD)repos/delphi/delphi-epidata/src,target=/usr/src/app/delphi/epidata,readonly \
181+
--env "SQLALCHEMY_DATABASE_URI=$(sqlalchemy_uri)" \
182+
--env "FLASK_SECRET=abc" \
183+
delphi_web_python Rscript repos/delphi/delphi-epidata/integrations/client/test_delphi_epidata.R | tee r-test_output_$(NOW).log
184+
185+
152186
.PHONY=bash
153187
bash:
154188
@docker run -it --rm --network delphi-net \

dev/local/setup.cfg

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

55
[options]
66
packages =
@@ -28,6 +28,8 @@ packages =
2828
delphi.epidata.acquisition.wiki
2929
delphi.epidata.client
3030
delphi.epidata.server
31+
delphi.epidata.server.admin
32+
delphi.epidata.server.admin.templates
3133
delphi.epidata.server.covidcast_issues_migration
3234
delphi.epidata.server.endpoints
3335
delphi.epidata.server.endpoints.covidcast_utils

docs/api/api_keys.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ change as we learn more about their impact:
1616

1717
For example, a query for three signals on one date across all counties can be
1818
submitted anonymously, but a query for three signals on a period of four weeks
19-
across all counties requires an API key.
19+
across all counties requires an API key.
2020

2121
An API key is a pseudonymous access token that grants privileged access to the
22-
Epidata API. You can request an API key by
23-
[registering with us](https://forms.gle/hkBr5SfQgxguAfEt7).
22+
Epidata API. You can request an API key by
23+
[registering with us](https://api.delphi.cmu.edu/epidata/admin/registration_form).
2424
Privileges of registration may include:
2525

2626
1. no rate limit
@@ -36,7 +36,8 @@ store the information you provide us at registration time, see our
3636

3737
## Usage
3838

39-
If you choose to [register for an API key](https://forms.gle/hkBr5SfQgxguAfEt7),
39+
If you choose to
40+
[register for an API key](https://api.delphi.cmu.edu/epidata/admin/registration_form),
4041
there are several ways to use your key to authenticate your requests:
4142

4243
### Via request parameter

docs/api/privacy_statement.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ purposes:
2929
* to identify excessive or abnormal usage patterns which may harm our system
3030

3131
The logs are only available to members of our operations team, and are expunged
32-
at or before they reach five years in age.
32+
at or before they reach five years in age.
3333

3434
If you provide us with your email address, we will only use it to contact you in
3535
the following scenarios:
@@ -47,9 +47,9 @@ security practices to help us keep your information secure. We only retrieve
4747
this mapping to resolve cases of excessive or abnormal usage. We automatically
4848
disassociate an email address from its API key when the API key has not been
4949
used for six months, or upon user request. You can request that your
50-
email address be removed from our records by filling out a
51-
[deletion request](https://forms.gle/GucFmZHTMgEFjH197).
50+
email address be removed from our records by filling out a
51+
[deletion request](https://api.delphi.cmu.edu/epidata/admin/removal_request).
5252

53-
For more information, see
53+
For more information, see
5454
[Carnegie Mellon’s privacy notice](https://www.cmu.edu/legal/privacy-notice.html).
5555
Further questions can be directed to [email protected].

0 commit comments

Comments
 (0)