-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcompatibility_test.py
48 lines (43 loc) · 1.84 KB
/
compatibility_test.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
'''
This function is meant to be called from nwb_table_readme.py script to test NWBE compatibility
'''
import sys
import argparse
import datetime
from multiprocessing import Process
def limit_time(func, args, kwargs, time):
p = Process(target=func, args=args, kwargs=kwargs)
p.start()
p.join(time)
if p.is_alive():
p.terminate()
return False
return True
def test_nwbe_compatibility(nwbfile_path, docker_arg):
if docker_arg:
try:
sys.path.insert(0, '/home/jovyan/nwb-explorer/nwb_explorer')
from nwb_model_interpreter import NWBModelInterpreter,GeppettoModelAccess
except ImportError:
print ('NWBE docker container not setup as the program expects')
else:
from nwb_explorer.nwb_model_interpreter import NWBModelInterpreter, \
GeppettoModelAccess
nwb_interpreter = NWBModelInterpreter(nwbfile_path)
geppetto_model = nwb_interpreter.create_model()
geppetto_model_access = GeppettoModelAccess(geppetto_model)
variable_type = geppetto_model.variables[0].types[0]
imported_type = nwb_interpreter.importType('DUMMY', 'nwbfile',
variable_type.eContainer(), geppetto_model_access)
geppetto_model_access.swap_type(variable_type, imported_type)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='cap limit on downloaded file size')
parser.add_argument('--test_docker', default=False, action='store_true',
help='test using the NWBE docker container')
parser.add_argument('text', action='store', type=str, help='The text to parse.')
args = parser.parse_args()
counter = limit_time(test_nwbe_compatibility, (args.text,args.test_docker, ), {}, 100)
if counter:
print(" -- NWBE compatibility passed!")
else:
print(" -- NWBE compatibility failed!")