-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurator.py
159 lines (124 loc) · 4.41 KB
/
curator.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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
import flywheel
import abc
class Curator(abc.ABC):
def __init__(self, depth_first=True):
"""An abstract class to be implemented in the input python file"""
self.depth_first = depth_first
self.input_file_one = None
self.input_file_two = None
self.input_file_three = None
self.context = None
def curate_container(self, container):
"""Curates a generic container.
Args:
container (flywheel.Container| flywheel.FileEntry)
"""
try:
container_type = container.container_type
except AttributeError:
# element is a file and has no children
return self.curate_file(container)
if container_type == 'project':
return self.curate_project(container)
elif container_type == 'subject':
return self.curate_subject(container)
elif container_type == 'session':
return self.curate_session(container)
elif container_type == 'acquisition':
return self.curate_acquisition(container)
elif container_type == 'file':
return self.curate_file(container)
else:
return self.curate_analysis(container)
@abc.abstractmethod
def curate_project(self, project):
"""Updates a project.
Args:
project (flywheel.Project): The project object to curate
"""
raise NotImplementedError
@abc.abstractmethod
def curate_subject(self, subject):
"""Updates a subject.
Args:
subject (flywheel.Subject): The subject object to curate
"""
raise NotImplementedError
@abc.abstractmethod
def curate_session(self, session):
"""Updates a session.
Args:
session (flywheel.Session): The session object to curate
"""
raise NotImplementedError
@abc.abstractmethod
def curate_acquisition(self, acquisition):
"""Updates an acquisition.
Args:
acquisition (flywheel.Acquisition): The acquisition object to
curate
"""
raise NotImplementedError
@abc.abstractmethod
def curate_analysis(self, analysis):
"""Updates an analysis.
Args:
analysis (flywheel.Analysis): The analysis object to curate
"""
raise NotImplementedError
@abc.abstractmethod
def curate_file(self, file_):
"""Updates a file.
Args:
file_ (flywheel.FileEntry): The file entry object to curate
"""
raise NotImplementedError
def validate_project(self, project):
"""Validates if a project has been correctly curated.
Args:
project (flywheel.Project): The project object to validate
Returns:
bool: Whether or not the project is curated correctly
"""
return False
def validate_subject(self, subject):
"""Validates if a subject has been correctly curated.
Args:
subject (flywheel.Subject): The subject object to validate
Returns:
bool: Whether or not the subject is curated correctly
"""
return False
def validate_session(self, session):
"""Validates if a session has been correctly curated.
Args:
session (flywheel.Session): The session object to validate
Returns:
bool: Whether or not the session is curated correctly
"""
return False
def validate_acquisition(self, acquisition):
"""Validates if a acquisition has been correctly curated.
Args:
acquisition (flywheel.Acquisition): The acquisition object to
validate
Returns:
bool: Whether or not the acquisition is curated correctly
"""
return False
def validate_analysis(self, analysis):
"""Validates if a analysis has been correctly curated.
Args:
analysis (flywheel.Analysis): The analysis object to validate
Returns:
bool: Whether or not the analysis is curated correctly
"""
return False
def validate_file(self, file_):
"""Validates if a file_ has been correctly curated.
Args:
file_ (flywheel.FileEntry): The file entry object to validate
Returns:
bool: Whether or not the file_ is curated correctly
"""
return False