This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
58 lines (44 loc) · 1.62 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Variables
SERVICE_NAME=vacina-manaus-backend
SHELL=/usr/bin/env bash
LATEST_CSV=data/cleaned/${shell echo ${LATEST_PDF} | cut -d "." -f1}.csv
LATEST_PDF=$(shell ls -t1 data/raw/ | head -n 1)
NUM_CHUNKS=$(shell ls tmp/csv/*.csv | wc -l)
.PHONY: all
all: build data
.PHONY: build
build:
@docker-compose build --pull
.PHONY: build-no-cache
build-no-cache:
@docker-compose build --no-cache
.PHONY: data
data: download-data extract-data process-data
.PHONY: download-data
download-data:
@docker-compose run --user=$(shell id -u) --rm ${SERVICE_NAME} python src/download_data.py
.PHONY: extract-data
extract-data: split-pdf run-extract-data concatenate-csv
.PHONY: run-extract-data
run-extract-data:
$(info Running extract_data.py...)
@docker-compose run --user=$(shell id -u) --rm ${SERVICE_NAME} python src/extract_data.py
.PHONY: split-pdf
split-pdf:
$(info Splitting the pdf ${LATEST_PDF} into pages...)
@mkdir -p tmp/pdf
@docker-compose run --user=$(shell id -u) --rm ${SERVICE_NAME} \
qpdf --split-pages data/raw/${LATEST_PDF} tmp/pdf/page-%d.pdf
.PHONY: concatenate-csv
concatenate-csv:
$(info Concatenating all csv files into ${LATEST_CSV}...)
@eval cat tmp/csv/page-{$(shell printf "%.$(shell expr length ${NUM_CHUNKS})d" 1)..${NUM_CHUNKS}}.csv > ${LATEST_CSV}
.PHONY: process-data
process-data:
@docker-compose run --user=$(shell id -u) --rm ${SERVICE_NAME} python src/process_data.py
.PHONY: process-main
process-main:
@docker-compose run --user=$(shell id -u) --rm ${SERVICE_NAME} python src/main.py
.PHONY: lint
lint:
@docker run --rm -v $(shell pwd):/apps alpine/flake8:3.8.4 --config=.flake8 $(shell find src/*.py)