Makefiles : checking dependencies beforehand && added help text
This commit is contained in:
@ -1,35 +1,85 @@
|
||||
MODELS_DIR := models
|
||||
OUT_DIR := out
|
||||
DATA_PATH := ../data
|
||||
DATA := $(DATA_PATH)/X_train.bin $(DATA_PATH)/X_test.bin $(DATA_PATH)/y_train.bin $(DATA_PATH)/y_test.bin
|
||||
|
||||
.PHONY: all start reset
|
||||
|
||||
all: ${DATA}
|
||||
.PHONY: all
|
||||
all: venv
|
||||
|
||||
$(DATA):
|
||||
@echo 'Missing $(DATA) files, use downloader first' && exit 1
|
||||
|
||||
.PHONY: venv
|
||||
venv:
|
||||
@bash -c 'source activate.sh'
|
||||
@sh -c '. ./activate.sh'
|
||||
|
||||
start: ${DATA} venv
|
||||
@bash -c 'source activate.sh && python projet.py'
|
||||
.PHONY: start
|
||||
start: $(DATA) | venv check-python-works
|
||||
@sh -c '. ./activate.sh && python projet.py'
|
||||
|
||||
reset:
|
||||
@echo Deleting generated states and models
|
||||
@rm -rf out/* models/* | true
|
||||
|
||||
debug:
|
||||
.PHONY: debug
|
||||
debug: $(DATA) | venv check-python-works check-pudb-works
|
||||
@bash -c 'source activate.sh && pudb projet.py'
|
||||
|
||||
profile:
|
||||
@bash -c 'source activate.sh && python -m cProfile -o prof.out projet.py && gprof2dot -f pstats prof.out | dot -Tpng -o output.png'
|
||||
.PHONY: profile
|
||||
profile: $(DATA) | venv check-python-works check-gprof2dot-works check-dot-works
|
||||
@bash -c 'source activate.sh && python -m cProfile -o prof.out projet.py && gprof2dot -f pstats prof.out | dot -T png -o output.png'
|
||||
|
||||
mrproper: reset
|
||||
@rm -r __pycache__ venv
|
||||
.PHONY: log
|
||||
log: $(DATA) reset | venv
|
||||
@sed -i 's/GPU_BOOSTED: Final = False/GPU_BOOSTED: Final = True/;s/COMPILE_WITH_C: Final = False/COMPILE_WITH_C: Final = True/' config.py
|
||||
@echo 'Logging GPU'
|
||||
@make -s start > log_gpu
|
||||
@sed -i 's/GPU_BOOSTED: Final = True/GPU_BOOSTED: Final = False/' config.py
|
||||
@echo 'Logging CPU'
|
||||
@make -s start > log_cpu
|
||||
@sed -i 's/GPU_BOOSTED: Final = False/GPU_BOOSTED: Final = True/;s/COMPILE_WITH_C: Final = True/COMPILE_WITH_C: Final = False/' config.py
|
||||
@echo 'Logging PGPU'
|
||||
@make -s start > log_pgpu
|
||||
@sed -i 's/GPU_BOOSTED: Final = True/GPU_BOOSTED: Final = False/' config.py
|
||||
@echo 'Logging PY'
|
||||
@make -s start > log_py
|
||||
@echo 'Cleaning up'
|
||||
@make -s reset
|
||||
|
||||
test:
|
||||
@bash -c 'source activate.sh && ls out | sed s/.pkl// | xargs -n1 python test_diff.py out'
|
||||
@bash -c 'source activate.sh && ls models | sed s/.pkl// | xargs -n1 python test_diff.py models'
|
||||
.PHONY: reset
|
||||
reset:
|
||||
@echo 'Deleting generated states and models'
|
||||
@rm -frv $(OUT_DIR)/* $(MODELS_DIR)/*
|
||||
#@ln -sv /mnt/pierre_stuffs/ViolaJones/python/models .
|
||||
#@ln -sv /mnt/pierre_stuffs/ViolaJones/python/out .
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -fv log_gpu log_cpu log_gpu log_py
|
||||
|
||||
.PHONY: mrproper
|
||||
mrproper: clean
|
||||
@rm -rfv __pycache__ venv
|
||||
|
||||
.PHONY: help
|
||||
help:
|
||||
@echo "all start reset mrproper help"
|
||||
@echo "Available targets:"
|
||||
@echo "\tall: alias for start, (default target)"
|
||||
@echo "\tvenv: Create python virtual environnement."
|
||||
@echo "\tstart: Start the ViolaJones algorithm, require data beforehand downloaded by the downloader."
|
||||
@echo "\tdebug: Debug the ViolaJones algorithm, require data beforehand downloaded by the downloader."
|
||||
@echo "\tprofile: Profile the ViolaJones algorithm functions timestamps, require data beforehand downloaded by the downloader."
|
||||
@echo "\treset: Will delete any saved models and processed data made by ViolaJones."
|
||||
@echo "\tmrproper: Will remove cpp binary files. Will execute reset target beforehand."
|
||||
|
||||
.PHONY: check-python-works
|
||||
check-python-works:
|
||||
@python --version >/dev/null 2>&1 || (echo 'Please install Python.' && exit 1)
|
||||
|
||||
.PHONY: check-pudb-works
|
||||
check-pudb-works:
|
||||
@pudb --version >/dev/null 2>&1 || (echo 'Please install pudb.' && exit 1)
|
||||
|
||||
.PHONY: check-gprof2dot-works
|
||||
check-gprof2dot-works:
|
||||
@gprof2dot --help >/dev/null 2>&1 || (echo 'Please install gprof2dot.' && exit 1)
|
||||
|
||||
.PHONY: check-dot-works
|
||||
check-dot-works:
|
||||
@dot --version >/dev/null 2>&1 || (echo 'Please install dot from graphviz.' && exit 1)
|
||||
|
Reference in New Issue
Block a user