# This makefile specifies the data pipeline for the TagIfAI project.
#
# Notes:
# - It assumes that there is a `.env` file (.gitignored) that exports the
#	following MongoDB environment variables and is run at the CLI before
#	running this makefile:
# 		export MONGODB_USERNAME=??
# 		export MONGODB_PASSWORD=??
# 		export MONGODB_URL="??"

SHELL = /bin/bash

BASE_DIR  := .
DATA_DIR  := $(BASE_DIR)/data
SRC_DIR   := $(BASE_DIR)/src

ALL: $(DATA_DIR)/dataset.csv

$(DATA_DIR)/test.csv: $(DATA_DIR)/test.csv.dvc
	dvc pull

$(DATA_DIR)/dataset.csv: $(DATA_DIR)/test.csv
	python $(SRC_DIR)/process.py \
		--raw-data-filename $(DATA_DIR)/test.csv \
		--dataset-filename $(DATA_DIR)/dataset.csv

.PHONY: style
style:
	black .
	flake8 src/*.py
	isort src/*.py

.PHONY: clean
clean:
	rm -f $(DATA_DIR)/test.csv
	rm -f $(DATA_DIR)/dataset.csv

# This isn't PHONEY.
# If you really want to rebuild it, you'll need to manually delete it first.
# And note that it's not needed for the dev-container because it's baked
#	into the container image.
venv:
	python3.10 -m venv venv && \
    source venv/bin/activate && \
	pip install pip setuptools wheel && \
	pip install -r requirements.txt
