Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP dockerize the python script #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@

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).

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.
Expand All @@ -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
Expand All @@ -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 \
Expand Down
19 changes: 19 additions & 0 deletions python/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
File renamed without changes.
File renamed without changes.