CMS 3D CMS Logo

writedatasetfile.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import argparse
4 
5 from Alignment.CommonAlignment.tools.dataset import MultipleDatasets
6 
7 parser = argparse.ArgumentParser()
8 parser.add_argument("-d", "--dataset", required=True, help="dataset name on DAS (can give multiple)", action="append")
9 parser.add_argument("--hippy", help="output file name for HipPy")
10 parser.add_argument("-v", "--validation", help="output file name for validation")
11 parser.add_argument("-f", "--first-run", default=0, type=int)
12 parser.add_argument("-l", "--last-run", default=float("inf"), type=int)
13 parser.add_argument("-r", "--run", action="append", type=int)
14 parser.add_argument("-m", "--max-events", default=float("inf"), type=int)
15 parser.add_argument("-j", "--events-per-job", type=int)
16 parser.add_argument("--clear-cache", action="store_true")
17 
18 args = parser.parse_args()
19 dataset = MultipleDatasets(*args.dataset)
20 
21 if not args.validation and not args.hippy:
22  raise RuntimeError("have to provide --validation or --hippy")
23 if args.validation and not args.hippy and args.events_per_job:
24  raise RuntimeError("--events-per-job is only used for HipPy")
25 
26 if args.hippy:
27  dataset.writefilelist_hippy(firstrun=args.first_run, lastrun=args.last_run, runs=args.run, maxevents=args.max_events, eventsperjob=args.events_per_job, outputfile=args.hippy, usecache=not args.clear_cache)
28 if args.validation:
29  dataset.writefilelist_validation(firstrun=args.first_run, lastrun=args.last_run, runs=args.run, maxevents=args.max_events, outputfile=args.validation, usecache=not args.clear_cache)