Example #1
0
 def __init__(self, fixed=False, runs=5, lumis=5):
     DataProvider.__init__(self, fixed)
     self.runs_per_file = runs
     self.lumis_per_run = lumis
     #initial start values for run and lumi generation
     self._run_num = int('1' + generate_uid(5, '1234567890', self._fixed))
     self._lumi_num = random.randint(1, 100)
Example #2
0
 def __init__(self, fixed=False, runs=5, lumis=5):
     DataProvider.__init__(self, fixed)
     self.runs_per_file = runs
     self.lumis_per_run = lumis
     #initial start values for run and lumi generation
     self._run_num  = int('1' + generate_uid(5, '1234567890', self._fixed))
     self._lumi_num = random.randint(1, 100)
Example #3
0
def main():
    "Main function"
    optmgr = GeneratorOptionParser()
    opts, _args = optmgr.get_opt()

    if opts.system == 'dbs':
        mgr = DBSDataProvider(opts.fixed, opts.runs, opts.lumis)
    elif opts.system == 'phedex':
        mgr = PhedexDataProvider(opts.fixed)
    else:
        mgr = DataProvider(opts.fixed)
    if opts.system and not opts.action and not opts.generate:
        members = [n for n, _ in inspect.getmembers(mgr) if n[0] != '_']
        actions = [
            m for m in members if m.find('gen_') != -1 or m.find('add_') != -1
        ]
        generators = set(members) - set(actions)
        print opts.system, 'actions    :', ', '.join(actions)
        print opts.system, 'generators :', ', '.join(generators)
        sys.exit(0)
    number = opts.number  # number of entities to generate/add
    infile = opts.input  # input JSON file
    action = opts.action  # action to apply, e.g. add_blocks
    what = opts.generate  # method to gererate, e.g. datasets
    outdata = []  # output data going to output JSON
    attrs = {}  # additional attributes
    if opts.prim:
        attrs.update({'prim': opts.prim})
    if opts.proc:
        attrs.update({'proc': opts.proc})
    if opts.tier:
        attrs.update({'tier': opts.tier})
    if infile and what:
        msg = 'You cannot mix --generate and --input options, '
        msg += 'they are exclusive'
        print msg
        sys.exit(1)
    if what:
        outdata = getattr(mgr, what)(number, **attrs)
    if infile:
        if not action:
            msg = 'Please provide action to use'
            print msg
            sys.exit(1)
        with open(infile, 'r') as data_file:
            indata = json.load(data_file)
            for row in indata:
                res = getattr(mgr, action)(row, number)
                if isinstance(res, list):
                    outdata += res
                else:
                    outdata.append(res)
    outfile = what + '.json' if what else action + '.json'
    outfile = outfile.replace('add_', '').replace('gen_', '')
    if outdata:
        fname = opts.output if opts.output else outfile
        if infile and infile == fname:
            print "Input and output file names are identical, exit 1"
            sys.exit(1)
        with open(fname, 'w') as json_file:
            json_file.write(json.dumps(outdata))
    if opts.toprint:
        pprint.pprint(outdata)
Example #4
0
 def __init__(self, fixed=False):
     DataProvider.__init__(self, fixed)
Example #5
0
 def __init__(self, fixed=False):
     DataProvider.__init__(self, fixed)