-
Notifications
You must be signed in to change notification settings - Fork 0
/
dodo.py
92 lines (70 loc) · 2.3 KB
/
dodo.py
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
import os
import sys
from importlib import import_module
from timeit import default_timer
import doit
import matplotlib
from doit.reporter import ConsoleReporter
from tasks import Task
if sys.platform == "linux":
os.environ["R_LIBS_SITE"] = "/usr/lib/R/site-library"
matplotlib.use("Agg")
class Timer:
def __init__(self, task):
self.task = task
self._start = None
self.duration = 0.0
def start(self):
self._start = default_timer()
def finish(self):
if self._start is not None:
self.duration = default_timer() - self._start
self._start = None
class TimedConsoleReporter(ConsoleReporter):
def __init__(self, outstream, options):
super().__init__(outstream, options)
self.timers = {}
def get_status(self, task):
self.timers[task.name] = Timer(task)
def execute_task(self, task):
self.timers[task.name].start()
super().execute_task(task)
def add_failure(self, task, exception):
self.timers[task.name].finish()
self.write("X %.3fs %s\n" % (self.timers[task.name].duration, task.title()))
super().add_failure(task, exception)
def add_success(self, task):
self.timers[task.name].finish()
self.write("O %.3fs %s\n" % (self.timers[task.name].duration, task.title()))
super().add_success(task)
DOIT_CONFIG = {
"check_file_uptodate": "timestamp",
"num_process": 6 if sys.platform == "linux" else 3,
"reporter": TimedConsoleReporter,
"verbosity": 2,
}
def find_tasks(module_name):
module = import_module(module_name)
for name in dir(module):
obj = getattr(module, name)
if isinstance(obj, Task) or name.startswith("task_"):
globals()[name] = obj
find_tasks("analyze_data")
find_tasks("plot_data")
find_tasks("analyze_decoding")
find_tasks("plot_decoding")
find_tasks("analyze_linear")
find_tasks("plot_linear")
find_tasks("analyze_position")
find_tasks("plot_position")
find_tasks("analyze_replays")
find_tasks("plot_replays")
find_tasks("analyze_swrs")
find_tasks("plot_swrs")
find_tasks("analyze_trials")
find_tasks("plot_trials")
find_tasks("analyze_tuning_curves")
find_tasks("plot_tuning_curves")
find_tasks("combine") # make sure this is loaded last
if __name__ == "__main__":
doit.run(globals())