-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (82 loc) · 2.67 KB
/
Makefile
File metadata and controls
97 lines (82 loc) · 2.67 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#
# venv
#
# init venv from imports
.PHONY: venv
venv:
test -f requirements.txt || (uvx pipreqs . --mode no-pin --encoding utf-8 --ignore .venv && mv requirements.txt requirements.in && uv pip compile requirements.in -o requirements.txt)
uv venv .venv --python 3.11
uv pip install -r requirements.txt
@echo "activate venv with: \033[1;33msource .venv/bin/activate\033[0m"
# dump + compile dependencies
.PHONY: lock
lock:
uv pip freeze > requirements.in
uv pip compile requirements.in -o requirements.txt
#
# docker
#
DOCKER_RUN = docker run --rm -p 9090:9090 -v $(PWD):/workspace main sh -c
.PHONY: docker-build
docker-build:
docker build -t main .
.PHONY: docker-run
docker-run:
$(DOCKER_RUN) "python3 /workspace/src/mnist.py"
.PHONY: docker-clean
docker-clean:
# docker compose down --rmi all --volumes --remove-orphans
# docker system prune -a -f
docker rmi -f main:latest
#
# conda
#
# generate environment.yml from requirements.txt (idempotent)
.PHONY: reqs-to-yaml
reqs-to-yaml:
conda update -n base -c defaults conda
conda config --env --set subdir osx-arm64 || true
conda config --set auto_activate_base false
conda info
bash -c '\
source $$(conda info --base)/etc/profile.d/conda.sh && conda activate base; \
conda create --yes --name con python=3.11; \
source $$(conda info --base)/etc/profile.d/conda.sh && conda activate con; \
pip install -r requirements.txt; \
conda env export --no-builds | grep -v "prefix:" > environment.yml; \
source $$(conda info --base)/etc/profile.d/conda.sh; conda deactivate; \
conda remove --yes --name con --all; \
'
# init conda from environment.yml file
.PHONY: conda
conda:
bash -c '\
source $$(conda info --base)/etc/profile.d/conda.sh; conda activate base; \
conda env create --file environment.yml --solver=libmamba; \
'
@echo "activate conda with: \033[1;33mconda activate con\033[0m"
.PHONY: conda-clean
conda-clean:
# conda clean --all
bash -c '\
source $$(conda info --base)/etc/profile.d/conda.sh; conda activate base; \
conda remove --yes --name con --all; \
source $$(conda info --base)/etc/profile.d/conda.sh; conda deactivate; \
'
#
# utils
#
.PHONY: precommit
precommit:
uvx isort .
uvx autoflake --remove-all-unused-imports --recursive --in-place .
uvx black --line-length 5000 .
uvx ruff check --fix .
.PHONY: md-to-pdf
md-to-pdf:
pandoc "$(filepath)" -o "$(basename $(filepath)).pdf"
.PHONY: rmd-to-pdf
rmd-to-pdf:
Rscript -e 'for(p in c("rmarkdown", "ISLR", "IRkernel")) if(!requireNamespace(p, quietly = TRUE)) install.packages(p, repos = "https://cran.rstudio.com")'
Rscript -e "rmarkdown::render('$(filepath)', output_format = 'pdf_document')"
rm -rf *.bib *.aux *.log *.out *.synctex.gz