|
| 1 | +# Patterns Dataset in Safegraph Mobility Data |
| 2 | + |
| 3 | +We import raw mobility data from Safegraph Weekly Patterns, calculate some |
| 4 | +statistics upon it, and aggregate the data from the Zip Code level to County, |
| 5 | +HRR, MSA and State levels. For detailed information see the files `DETAILS.md` |
| 6 | +contained in this directory. |
| 7 | + |
| 8 | +## Running the Indicator |
| 9 | + |
| 10 | +The indicator is run by directly executing the Python module contained in this |
| 11 | +directory. The safest way to do this is to create a virtual environment, |
| 12 | +installed the common DELPHI tools, and then install the module and its |
| 13 | +dependencies. To do this, run the following code from this directory: |
| 14 | + |
| 15 | +``` |
| 16 | +python -m venv env |
| 17 | +source env/bin/activate |
| 18 | +pip install ../_delphi_utils_python/. |
| 19 | +pip install . |
| 20 | +``` |
| 21 | + |
| 22 | +One must also install the |
| 23 | +[AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html). |
| 24 | +Please refer to OS-specific instructions to install this command line |
| 25 | +interface, and verify that it is installed by calling `which aws`. |
| 26 | +If `aws` is not installed prior to running the pipeline, it will raise |
| 27 | +a `FileNotFoundError`. |
| 28 | + |
| 29 | +All of the user-changable parameters are stored in `params.json`. To execute |
| 30 | +the module and produce the output datasets (by default, in `receiving`), run |
| 31 | +the following: |
| 32 | + |
| 33 | +``` |
| 34 | +env/bin/python -m delphi_safegraph_patterns |
| 35 | +``` |
| 36 | + |
| 37 | +Once you are finished with the code, you can deactivate the virtual environment |
| 38 | +and (optionally) remove the environment itself. |
| 39 | + |
| 40 | +``` |
| 41 | +deactivate |
| 42 | +rm -r env |
| 43 | +``` |
| 44 | + |
| 45 | +## Testing the code |
| 46 | + |
| 47 | +To do a static test of the code style, it is recommended to run **pylint** on |
| 48 | +the module. To do this, run the following from the main module directory: |
| 49 | + |
| 50 | +``` |
| 51 | +env/bin/pylint delphi_safegraph_patterns |
| 52 | +``` |
| 53 | + |
| 54 | +The most aggressive checks are turned off; only relatively important issues |
| 55 | +should be raised and they should be manually checked (or better, fixed). |
| 56 | + |
| 57 | +Unit tests are also included in the module. To execute these, run the following |
| 58 | +command from this directory: |
| 59 | + |
| 60 | +``` |
| 61 | +(cd tests && ../env/bin/pytest --cov=delphi_safegraph_patterns --cov-report=term-missing) |
| 62 | +``` |
| 63 | + |
| 64 | +The output will show the number of unit tests that passed and failed, along |
| 65 | +with the percentage of code covered by the tests. None of the tests should |
| 66 | +fail and the code lines that are not covered by unit tests should be small and |
| 67 | +should not include critical sub-routines. |
0 commit comments