-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtest_component.py
More file actions
59 lines (46 loc) · 1.58 KB
/
test_component.py
File metadata and controls
59 lines (46 loc) · 1.58 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
import os
import torch
import configs
import datasets
import models
class Test(object):
def __init__(self):
self.ci = configs.env.ci.run
configs.env.ci.run = True
self.dtype = torch.get_default_dtype()
torch.set_default_dtype(torch.float32)
def __del__(self):
configs.env.ci.run = self.ci
torch.set_default_dtype(self.dtype)
def _path(self, path):
full_path = configs.env.getdir(path)
if not os.path.exists(full_path):
os.makedirs(full_path)
configs.env.chdir(path)
def run(self):
self.test_models()
self.test_configs()
self.test_datasets()
def test_models(self):
self._path('models')
for model in models.functional.common.all():
models.BaseTest(model).run(rm_save_folder=True, one_dataset=True)
def test_configs(self):
self._path('res')
files = [os.path.join(os.getcwd(), file) for file in os.listdir(os.getcwd())]
index = 0
while index < len(files):
if os.path.isdir(files[index]):
files.extend([os.path.join(files[index], f) for f in os.listdir(files[index])])
files.remove(files[index])
else:
index += 1
for file in files:
configs.BaseTest(file).run()
def test_datasets(self):
self._path('datasets')
for dataset in datasets.functional.common.all():
if getattr(dataset, 'Testable', True):
datasets.BaseTest(dataset).run()
if __name__ == "__main__":
Test().run()