-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
78 lines (61 loc) · 2.83 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
help: ## Show help
@grep -E '^[.a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
clean: ## Clean autogenerated files
rm -rf dist
find . -type f -name "*.DS_Store" -ls -delete
find . | grep -E "(__pycache__|\.pyc|\.pyo)" | xargs rm -rf
find . | grep -E ".pytest_cache" | xargs rm -rf
find . | grep -E ".ipynb_checkpoints" | xargs rm -rf
rm -f .coverage
clean-logs: ## Clean logs
rm -rf hydra_outputs/**
format: ## Run pre-commit hooks
pre-commit run -a
sync: ## Merge changes from main branch to your current branch
git pull
git pull origin main
test: ## Run not slow tests
pytest -k "not slow"
test-full: ## Run all tests
pytest
# Define variables with default values
CFG ?= job
ARGS ?=
train: ## Train model, arguments is CFG={, train, all, job}. By default CFG=job
python src/supertrainer/train.py $(if $(filter-out train,$(CFG)),--cfg $(CFG)) $(ARGS)
dir_tree: ## Print directory tree
find . | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
dir_tree_configs: ## Print directory tree for configs
find configs/ | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
dir_tree_supertrainer: ## Print directory tree for supertrainer
find src/supertrainer/ | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
# Define variables with default values
CONDA_ENV ?= supertrainer
ENV_FILE ?= environment.yaml
OUTPUT_FILE ?= environment.yaml
export_conda_env: ## export conda environment to specified file. OUTPUT_FILE=<file_name>?environment.yaml
bash ./scripts/export_conda_env.sh $(OUTPUT_FILE)
install_conda_env: ## install conda environment. CONDA_ENV=<env_name>?supertrainer ENV_FILE=<file_name>?environment.yaml
bash ./scripts/install_conda_env.sh $(CONDA_ENV) $(ENV_FILE)
CODE_FILE ?= *.py
OUTPUT_FILE ?= code_output.txt
copy_code: ## Copy code to a single file, mainly for copying code to ChatGPT or Aider. CODE_FILE=<file_name>?*.py OUTPUT_FILE=<file_name>?code_output.txt
for file in $(CODE_FILE); do echo "File: $$file"; cat "$$file"; echo ""; done > $(OUTPUT_FILE)
@echo "Code has been copied to $(OUTPUT_FILE)."
replace_name: ## Replace string in filenames, STRING1=<old_string> STRING2=<new_string>
@if [ -z "$(STRING1)" ] || [ -z "$(STRING2)" ]; then \
echo "Error: Both STRING1 and STRING2 must be provided and non-empty."; \
echo "Usage: make replace STRING1=<old_string> STRING2=<new_string>"; \
exit 1; \
fi
@echo "Replacing '$(STRING1)' with '$(STRING2)' in filenames..."
@find . -type f -name "*$(STRING1)*" | while read file; do \
newname=$$(echo $$file | sed 's/$(STRING1)/$(STRING2)/g'); \
if [ "$$file" != "$$newname" ]; then \
mv "$$file" "$$newname"; \
echo "Renamed: $$file -> $$newname"; \
fi; \
done
@echo "Rename operation completed."
openai_batch: ## List OpenAI batch job
export $(cat .env | xargs) && instructor batch list --limit 9