diff --git a/README.md b/README.md index 18f710f..171476e 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,16 @@ We use a simple Python script to hit the Untappd API. We use R to make graphs and run stats. +## Requirements + +Install [Docker Desktop](https://docs.docker.com/desktop/) for your system. + ### Getting Untappd API Secrets To run the Python script, you'll need an Untappd `CLIENT_ID` and `CLIENT_SECRET`. Put those in the `.env` file in the root of project, like so: ``` -echo "CLIENT_ID=123" >> .env -echo "CLIENT_SECRET=456" >> .env +cd python; echo "CLIENT_ID=123" >> .env; echo "CLIENT_SECRET=456" >> .env ``` You'll need to apply for an [Untappd API key](https://untappd.com/api/docs). @@ -20,7 +23,7 @@ You'll need to apply for an [Untappd API key](https://untappd.com/api/docs). You'll also need to put USERNAMES in the `.env` file as a list, like so: ``` -echo "USERNAMES=alexdannylow,andrewbogo" >> .env +echo "USERNAMES=alexdannylow,andrewbogo,DylanHong" >> .env ``` The users cannot be private on Untappd. @@ -31,25 +34,17 @@ For a single username, you can exclude the comma: "USERNAMES=alexdannylow" ``` -### Running the Python Script - -To create the outfile.csv, you'll need to run the Python script to hit the Untappd API. - -#### First time? - -Create virutal env: +### 1) Getting the Data -`python3 -m venv venv` +To create the *.csv consumed by the R script, you'll need to run the Python script to hit the Untappd API. -In the future, we would like to dockerize this. -#### Then: - -`source venv/bin/activate` +``` +cd python; -`pip3 install -r requirements.txt` +``` -Once everything is installed, you can run the script. +### Script usage ``` python3 main.py --help @@ -71,22 +66,17 @@ optional arguments: Example usage: ``` -python3 main.py --force --outfile "allBeers.csv" --number-of-unique-beers 49 +python3 main.py --force ``` -Note that we ignore `.csv` via our `.gitignore`. +### 3) Generating a report with R -### Generating a report with R - -#### First time? - -Install [Docker Desktop](https://docs.docker.com/desktop/) for your system. -Then, pull the Docker image from Docker Hub: +First, pull the Docker image from Docker Hub: `docker pull aboghoss/bargraph:v0.0.1` -#### Then +Secondly: ``` docker run -it \ diff --git a/python/Dockerfile b/python/Dockerfile new file mode 100644 index 0000000..f52a474 --- /dev/null +++ b/python/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.7 + +# run this before copying requirements for cache efficiency +RUN pip install --upgrade pip + +#set work directory early so remaining paths can be relative +WORKDIR /app + +# Adding requirements file to current directory +# just this file first to cache the pip install step when code changes +COPY requirements.txt . + +#install dependencies +RUN pip install -r requirements.txt + +# copy code itself from context to image +COPY . . + +CMD ["python", "./main.py", "--force"] \ No newline at end of file diff --git a/main.py b/python/main.py similarity index 100% rename from main.py rename to python/main.py diff --git a/requirements.txt b/python/requirements.txt similarity index 100% rename from requirements.txt rename to python/requirements.txt