-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
143 lines (114 loc) · 3.22 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# Default
all: test
.PHONY: all
OS := $(shell uname | tr '[:upper:]' '[:lower:]')
CURRENT_DIR=$(shell pwd)
ifeq (,$(shell which conda))
HAS_CONDA=False
else
HAS_CONDA=True
endif
###
# Package
###
install:
ifeq (True,$(HAS_CONDA))
@echo ">>> Detected conda, creating conda environment."
conda env create -f environment_$(OS).yml
@echo ">>> Conda env created."
git subomdule update --init
ln -s ${PWD}/hopfield-layers/modules ${PWD}/soc/models/hopfield
else
@echo ">>> Please install conda first: brew cask install anaconda"
endif
## Export conda environment
update_env:
ifeq (True,$(HAS_CONDA))
@echo ">>> Detected conda, exporting conda environment."
conda env update --name soc --file environment_$(OS).yml
@echo ">>> Conda env exported."
else
@echo ">>> Please install conda first: brew cask install anaconda"
endif
## Export conda environment
export_env:
ifeq (True,$(HAS_CONDA))
@echo ">>> Detected conda, exporting conda environment."
conda env export -n soc | grep -v "^prefix: " | grep -v libffi | grep -v "en-" > environment_$(OS).yml
ifeq (darwin,$(OS))
sed -i '' -e 's/numpy-stubs==0.0.1/git+https:\/\/github.com\/numpy\/numpy-stubs.git/g' environment_$(OS).yml
else
sed -i -e 's/numpy-stubs==0.0.1/git+https:\/\/github.com\/numpy\/numpy-stubs.git/g' environment_$(OS).yml
endif
@echo ">>> Conda env exported."
else
@echo ">>> Please install conda first: brew cask install anaconda"
endif
.PHONY: install export_env
###
# Test
###
dump_training_set:
python scripts/dump.py raw=1 dump_text=1
dump_fixtures:
python scripts/dump.py --multirun testing=1 raw=1 dump_text=0,1
.PHONY: dump_fixtures dump_training_set
###
# CI
###
typecheck:
mypy $(CURRENT_DIR)/soc $(CURRENT_DIR)/scripts
lint:
flake8 soc/. tests/. scripts/.
yapf:
yapf --style tox.ini -r -i soc/. tests/. scripts/.
TEST_FIXTURE_FILE=$(CURRENT_DIR)/tests/fixtures/soc_seq_3_fullseq.pt
FIXTURES_ZIP_FILE=$(CURRENT_DIR)/tests/fixtures/fixtures_data.zip
FIXTURES_FOLDER=$(CURRENT_DIR)/tests/fixtures
test:
ifeq ("$(wildcard $(TEST_FIXTURE_FILE))","")
unzip -o $(FIXTURES_ZIP_FILE) -d $(FIXTURES_FOLDER)
python $(FIXTURES_FOLDER)/dump_preprocessed_files.py
endif
PYTHONWARNINGS="ignore" pytest .
ci: lint typecheck test
.PHONY: typecheck yapf lint test ci
###
# Experiments
###
exp_clean:
rm -rf scripts/results/*
exp_hopfield_hp_check:
cd scripts &&\
python run_exp.py -m -cn 005_gpu_resnet18fusion_policy_full\
runner.lr=0.1,0.01,0.001\
runner.model.n_core_planes=2,8,24\
runner.model.fusion_num_heads=1,2,8\
runner.model.beta=0.25,0.5,1.,2.,8.\
runner.model.update_steps_max=0,3\
trainer.max_epochs=21
exp_005:
cd scripts &&\
python run_exp.py -m -cn 005_gpu_resnet18concat_policy_overfit
cd scripts &&\
python run_exp.py -m -cn 005_gpu_resnet18fusion_policy_overfit
cd scripts &&\
python run_exp.py -m -cn 005_gpu_resnet18fusion_policy_full
cd scripts &&\
python run_exp.py -m -cn 005_gpu_resnet18fusion_policy_pretraining
cd scripts &&\
python run_exp.py -m -cn 005_gpu_resnet18fusion_policy_fusionfinetuning
.PHONY: exp_clean
###
# Deploy
###
zip:
python setup.py sdist --format zip
zip_data:
zip $(CURRENT_DIR)/data/data.zip $(CURRENT_DIR)/data/*.pt
wheel:
python setup.py bdist_wheel
clean:
rm -rf build
rm -rf dist
.PHONY: zip wheel clean