forked from M-Labs/artiq
1
0
Fork 0

artiq_run: HDF5 output support

This commit is contained in:
Sebastien Bourdeauducq 2015-02-04 18:46:55 +08:00
parent f308bf6c12
commit 0e65f71705
1 changed files with 17 additions and 5 deletions

View File

@ -6,6 +6,8 @@ from inspect import isclass
from operator import itemgetter from operator import itemgetter
from itertools import chain from itertools import chain
import h5py
from artiq.language.db import * from artiq.language.db import *
from artiq.protocols import pyon from artiq.protocols import pyon
from artiq.protocols.file_db import FlatFileDB from artiq.protocols.file_db import FlatFileDB
@ -44,6 +46,9 @@ def get_argparser():
help="run ELF binary") help="run ELF binary")
parser.add_argument("-u", "--unit", default=None, parser.add_argument("-u", "--unit", default=None,
help="unit to run") help="unit to run")
parser.add_argument("-o", "--hdf5", default=None,
help="write results to specified HDF5 file"
" (default: print them)")
parser.add_argument("file", parser.add_argument("file",
help="file containing the unit to run") help="file containing the unit to run")
parser.add_argument("arguments", nargs="*", parser.add_argument("arguments", nargs="*",
@ -107,6 +112,13 @@ def main():
unit_inst = unit(dbh, **arguments) unit_inst = unit(dbh, **arguments)
unit_inst.run() unit_inst.run()
if args.hdf5 is not None:
f = h5py.File(args.hdf5, "w")
try:
rdb.write_hdf5(f)
finally:
f.close()
else:
if rdb.data.read or rdb.realtime_data.read: if rdb.data.read or rdb.realtime_data.read:
print("Results:") print("Results:")
for k, v in chain(rdb.realtime_data.read.items(), for k, v in chain(rdb.realtime_data.read.items(),