Skip to content

Commit 09974cf

Browse files
committed
Support --raw; show all subsets
1 parent 47b616d commit 09974cf

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

Pilot1/Uno/topN_to_uno.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def parse_arguments():
2525
parser.add_argument('--output', type=str, default='topN.uno.h5',
2626
help='output filename')
2727
parser.add_argument('--show', action='store_true', help='Simply show the plan node')
28+
parser.add_argument('--raw', action='store_true', help='With --show, also show raw JSON')
2829

2930
args, unparsed = parser.parse_known_args()
3031
return args, unparsed
@@ -319,21 +320,34 @@ def show_list(L):
319320
print_line(line)
320321
print("")
321322

323+
def show_node(subtree):
324+
"""Write out the given plan subtree"""
325+
for partition in ["val", "train"]:
326+
partition_sets = len(subtree[partition])
327+
print("%s_sets: %i" % (partition, partition_sets))
328+
for index in range(0, len(subtree[partition])):
329+
print("index: %i" % index)
330+
dataset = subtree[partition][index]
331+
for key in ["CELL", "DRUG"]:
332+
if key not in dataset:
333+
continue
334+
partition_keys = dataset[key]
335+
print("%s %ss: count: %i" %
336+
(partition, key, len(partition_keys)))
337+
show_list(partition_keys)
338+
322339

323340
def show(args):
324341
"""Simply show the entry for this node"""
325342
if args.node is None:
326343
print("Provide a node to show!")
327344
exit(1)
328-
plan_dict = read_plan(args.plan, args.node)
329-
# print(str(plan_dict))
330-
val_cells = plan_dict['val'][0]['cell']
331-
print("val cells: count: %i" % len(val_cells))
332-
show_list(val_cells)
333-
train_cells = plan_dict['train'][0]['cell']
334-
print("train cells: count: %i" % len(train_cells))
335-
show_list(train_cells)
336-
345+
# Get the plan subtree for the given node
346+
subtree = read_plan(args.plan, args.node)
347+
if args.raw:
348+
print(str(subtree))
349+
print("node: " + args.node)
350+
show_node(subtree)
337351

338352
if __name__ == '__main__':
339353
parsed, unparsed = parse_arguments()

0 commit comments

Comments
 (0)