Skip to content

Survival-analysis based NBA player analysis frontend

Notifications You must be signed in to change notification settings

ak-gupta/nbaspa-app

Repository files navigation

Overview

This repository defines a Flask web app for nbaspa.

Usage

The usage below assumes that you have used nbaspa to download and clean your training data, build your model, and produce impact ratings.

Basic

Install the requirements via pip,

$ python -m pip install -r requirements.txt .

set an environment variable to indicate the path to your nbaspa data directory,

$ export DATA_DIR=nba-data

and launch the web app.

$ python wsgi.py

You can change the --host, --port, and --config. The --config is either production or development, and it refers to the Flask configuration of config.py.

Docker

First, build the docker container

$ docker build --tag nbaspa_app .

Local filesystem

Run the container with the port of your choice.

$ docker run --rm -p 8080:8080 -e PORT=8080 -e DATA_DIR=nba-data nbaspa_app

You may need to mount a filesystem to have access to a local data directory:

$ docker run \
    --rm \
    -p 8080:8080 \
    -e PORT=8080 \
    -e DATA_DIR=/opt/nba-data \
    --mount type=bind,src=/opt/<PATH_TO_PARENT_DIRECTORY>,target=/opt \
    nbaspa_app

GCS filesystem

Pull the gcloud image:

$ docker pull gcr.io/google.com/cloudsdktool/cloud-sdk:latest

and authenticate gcloud with service account credentials:

$ docker run \
    --name gcloud-config \
    gcr.io/google.com/cloudsdktool/cloud-sdk gcloud auth activate-service-account SERVICE_ACCOUNT@DOMAIN.COM --key-file=/path/key.json --project=PROJECT_ID

To change the configuration to point to Google Cloud Storage, supply the FLASK_CONFIG environment variable:

$ docker run \
    --rm \
    --volumes-from gcloud-config \
    -p 8080:8080 \
    -e PORT=8080 \
    -e DATA_DIR=<BUCKET_NAME>/<FOLDER_NAME> \
    -e FLASK_CONFIG=production \
    nbaspa_app

Credits

A huge thank you to Todd Birchard for his excellent Flask tutorial series. In particular, this repository uses

The docker image used for deploying the web application is adapted from the Google Cloud Run documentation. Additionally, this project leverages bulma for the styling.