Skip to content

Commit 658e4d3

Browse files
committed
updated and new setup info in README.md
1 parent bbe1d16 commit 658e4d3

File tree

3 files changed

+75
-11
lines changed

3 files changed

+75
-11
lines changed

README.md

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ This is the home of [Delphi](https://delphi.cmu.edu/)'s epidemiological data
88
API. See our [API documentation](https://cmu-delphi.github.io/delphi-epidata/)
99
for details on the available data sets, APIs, and clients.
1010

11-
## Development Quickstart
11+
# Development Quickstart
12+
13+
## Setup
1214

1315
Requires: Docker, possibly sudo access (depending on your Docker installation and OS).
1416

1517
In the directory where you want to work run the following:
1618

1719
```sh
1820
# Make folder structure, download dependent repos, and symlink Makefile
19-
$ curl "https://raw.githubusercontent.com/cmu-delphi/delphi-epidata/dev/dev/local/install.sh" | bash
21+
$ curl "https://raw.githubusercontent.com/cmu-delphi/delphi-epidata/dev/dev/local/install.sh" | bash && cd driver
2022
```
2123

2224
You should now have the following directory structure:
@@ -37,21 +39,26 @@ You should now have the following directory structure:
3739
│ │ └── utils
3840
```
3941

40-
and you should now be in the `driver` directory.
41-
You can now execute make commands
42+
and you should be in the `driver` directory.
43+
You can now execute `make` commands.
4244

4345
```sh
44-
# Create all docker containers: db, web, and python
46+
# Create all docker containers: db, web, redis, and python
4547
$ [sudo] make all
4648

4749
# Run tests
4850
$ [sudo] make test
4951

5052
# To drop into debugger on error
53+
# Warning: this can hang, so as an alternative import pdb and add a `pdb.set_trace()` in the failing test.
5154
$ [sudo] make test pdb=1
5255

53-
# To test only a subset of tests
56+
# To test only a subset of tests, specify the path to the directory or file of interest.
5457
$ [sudo] make test test=repos/delphi/delphi-epidata/integrations/acquisition
58+
$ [sudo] make test test=repos/delphi/delphi-epidata/integrations/acquisition/covid_hosp/facility/test_scenarios.py
59+
60+
# To run R tests
61+
$ [sudo] make r-test
5562
```
5663

5764
Enabling features like code autocompletion and linting in your editor
@@ -64,6 +71,63 @@ $ cd repos
6471
$ pip install -e . --config-settings editable_mode=strict
6572
```
6673

74+
## Running local epidata acquisition
75+
76+
From the `driver` directory, run
77+
78+
```sh
79+
# If containers are not already started
80+
$ [sudo] make all
81+
# Starts a bash session inside the `delphi_web_python` container
82+
$ [sudo] make bash
83+
```
84+
85+
If the container was successfully started, you should see a prompt that looks like `root@containerhash:/usr/src/app#`.
86+
87+
From the container, run
88+
89+
```sh
90+
# In production, acquisition injects secrets automatically, but for local runs we need to replace them manually. The values are found in the `sqlalchemy_uri` variable defined eariler in the Makefile.
91+
$ sed -i -e 's/{SECRET_DB_USERNAME_EPI}/user/g' -e 's/{SECRET_DB_PASSWORD_EPI}/pass/g' -e 's/{SECRET_DB_HOST}/delphi_database_epidata/g' delphi/operations/secrets.py
92+
# May need to run
93+
$ pip install --upgrade mysql-connector-python
94+
# Run an acquisition pipeline, e.g.
95+
$ python -m delphi.epidata.acquisition.flusurv.flusurv_update all
96+
```
97+
98+
You may need to add '$(M1)' flag to subcommands if using a new M\* chip Mac. The '$(M1)' flag is added to commands within the [Makefile](https://github.com/cmu-delphi/delphi-epidata/blob/cae43f8/dev/local/Makefile), so take a look there for guidance.
99+
100+
## Other useful commands and information
101+
102+
```sh
103+
# Starts a MySQL prompt that can be used to query the local database.
104+
# This connection can be kept open while adding data to the database.
105+
$ [sudo] make sql
106+
# Cleans up the docker environment
107+
$ [sudo] make clean
108+
```
109+
110+
The structure of the `driver` directory is largely replicated inside of the `delphi_web_python` container, with the following exceptions:
111+
112+
- Python package names can't contain hyphens, so hyphens in repo names are
113+
replaced with underscores in the package hierarchy. (An exception is the
114+
repo `delphi-epidata`, which is renamed to simply `epidata`.)
115+
- Repos are organized such that the main code for the package is inside of
116+
a `src/` directory. When deployed,
117+
[the contents of `src/` are moved](https://github.com/cmu-delphi/delphi-epidata/blob/cae43f8/dev/docker/python/setup.sh#L22-L27).
118+
(An [exception is the legacy `undef-analysis` repo](https://github.com/cmu-delphi/delphi-epidata/blob/cae43f8/dev/docker/python/setup.sh#L17-L18),
119+
which has sources at the top-level.)
120+
121+
Dependencies in [`delphi-epidata/requirements.api.txt` and `delphi-epidata/requirements.dev.txt` are installed](https://github.com/cmu-delphi/delphi-epidata/blob/cae43f8/dev/docker/python/Dockerfile#L13).
122+
123+
The [`delphi-epidata` code is mounted](https://github.com/cmu-delphi/delphi-epidata/blob/cae43f8/dev/local/Makefile#L203-L204) for `test`, `r-test`, and `bash` Make targets so any changes to `delphi-epidata` code or tests are automatically reflected in the Docker container without needing to rebuild.
124+
125+
The `delphi-epidata` (and other repos) found in `driver/repos/delphi` is a full copy of the repo, using the default branch.
126+
Other branches can be checked out too, so development can happen directly in this copy of the repo (_recommended_).
127+
If you have pre-existing work elsewhere on your machine that would be inconvenient to move into the `driver` directory, it is possible to locally change the mount path in the Makefile or perhaps to create a symlink to your other local copy of the repo.
128+
129+
Depending on your GitHub authentication method, [the clone method used during setup](https://github.com/cmu-delphi/delphi-epidata/blob/cae43f8/dev/local/install.sh#L34) may not allow you to push changes or new branches to the remote. In this case, please re-authenticate, or re-clone the repo within `driver/repos/delphi` using your standard method.
130+
67131
# COVIDcast
68132

69133
At the present, our primary focus is developing and expanding the

dev/docker/python/setup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# This script sets up the correct directory structure within the `delphi_img`
1+
# This script sets up the correct directory structure within the `delphi_web_python`
22
# docker image.
33

44
# Some notes on package structure:
55
# - Python package names can't contain hyphens, so hyphens in repo names are
66
# replaced with underscores in the package hierarchy. (An exception is the
77
# repo `delphi-epidata`, which is renamed to simply `epidata`.)
88
# - Repos are organized such that the main code for the package is inside of
9-
# a `src/` directory. When deployed, `src/` is elided. (An exception is the
9+
# a `src/` directory. When deployed, the contents of `src/` are moved. (An exception is the
1010
# legacy `undef-analysis` repo, which has sources at the top-level.)
1111

1212
# bail if anything fails

dev/local/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
# Runs image in the background and pipes stdout to a log file.
2020
# Blocks until database is ready to receive connections.
2121
#
22-
# python: Rebuilds delphi_web_python image. You shouldn't need to do this
22+
# py: Rebuilds delphi_web_python image. You shouldn't need to do this
2323
# often; only if you are installing a new environment, or have
2424
# made changes to delphi-epidata/dev/docker/python/Dockerfile.
2525
#
26-
# all: Runs the commands 'web' 'db' and 'python'.
26+
# all: Runs the commands 'web' 'db' and 'py'.
2727
#
28-
# test: Runs test and integrations in delphi-epidata. If test
28+
# test: Runs test and integrations in delphi-epidata. If test
2929
# optional arg is provided, then only the tests in that subdir
3030
# are run.
3131
#

0 commit comments

Comments
 (0)