pwg, ## this is how one passes it in the first place 'pwg': pwg, 'requests': chunk, 'notes': TICKET_NOTE, 'chains': [chain_prepid], 'repetitions': repeat, 'block': PRIORITY_BLOCK } all_ticket.append(copy.deepcopy(mccm_ticket)) print mccm_ticket ## you'll be able to re-read all tickets from the created json open(ticketfilename, 'w').write(json.dumps(all_ticket)) #all_ticket = json.loads(open('all_tickets_pythia_nooutput.json').read()) for ticket in all_ticket: ### flip the switch if not is_dry_run: res = mcm.put('mccms', ticket) print "Create ticket" print res ticket_prepid = res.get('prepid', None) print "Ticket prepid: ", ticket_prepid if ticket_prepid: mcm.get('restapi/mccms/generate/%s/reserve' % (ticket_prepid)) else: print "Error: no ticket" print ticket time.sleep(60) pass
def Run(idx_row): output_msg = '' KEY = '1bAdzoB9bg6nbyxCOBsTAWSSJy6FHNfmkrIDqY-Nmdi0' sheet = '2016' title_list = GetTitleFromSpreadsheet(KEY, sheet, i_column="A", f_column="Z") info_list = GetInfoFromSpreadsheet(idx_row, KEY, sheet, i_column="A", f_column="Z") this_dic = {} for i in range(0, len(title_list)): title = title_list[i] #print title value = info_list[i] #print value this_dic[title] = value FullFragment = MakeFullFragment(this_dic["gridpackPATH"], this_dic["PSfragment"], this_dic["card_ref"]) generator_parameters=Make_generator_parameters(this_dic["cross_section"],\ this_dic["filter_efficiency"],\ this_dic["filter_efficiency_error"],\ this_dic["match_efficiency"],\ this_dic["match_efficiency_error"],\ this_dic["negative_weights_fraction"]) print this_dic['dataset_name'] new_request = { 'pwg': 'HIG', 'member_of_campaign': this_dic['member_of_campaign'], 'dataset_name': this_dic['dataset_name'], 'generators': this_dic['generators'].split(','), "fragment": FullFragment, 'generator_parameters': generator_parameters, 'total_events': int(this_dic['total_events']), 'mcdb_id': 0, 'size_event': [600], 'time_event': [60.] } if this_dic["PrepID"] != '': #print "ALREADY" mcm = McM(dev=False) this_request = mcm.get("requests", this_dic["PrepID"]) for key in new_request: this_request[key] = new_request[key] update = mcm.update('requests', this_request) return str(update) # push it to McM #mcm = McM(dev=False,cookie="dev-cookie.txt") #mcm = McM(dev=False,cookie='prod-cookie.txt') mcm = McM(dev=False) put_answer = mcm.put('requests', new_request) if put_answer.get('results'): prepid = put_answer['prepid'] print('New PrepID: %s' % (prepid)) #f.write(prepid+'\n') output_msg = str(prepid) else: print('Something went wrong while creating a request. %s' % (dumps(put_answer))) #f.write("fail,idx_row-->"+this_dic['dataset_name']+'\n') output_msg = "fail" + str(idx_row) + "-->" + this_dic['dataset_name'] #print output_msg return output_msg
mcm = McM(dev=False) # Script creates a new ticket in MccM. # Fefine list of modifications step = [40, 40, 40, 36] a = 1972 for i in range(len(step)): b = a + step[i] print("HIG-RunIISummer20UL16wmLHEGEN-0" + str(a) + ", RunIISummer20UL16wmLHEGEN-0" + str(b)) new_mccm = { 'pwg': 'HIG', 'prepid': 'HIG', 'requests': [[ 'HIG-RunIISummer20UL16wmLHEGEN-0' + str(a), 'HIG-RunIISummer20UL16wmLHEGEN-0' + str(b) ]], 'chains': [ 'chain_RunIISummer20UL16wmLHEGEN_flowRunIISummer20UL16SIM_flowRunIISummer20UL16DIGIPremix_flowRunIISummer20UL16HLT_flowRunIISummer20UL16RECO_flowRunIISummer20UL16MiniAODv2_flowRunIISummer20UL16NanoAODv9' ], 'block': '3' } mcm.put('mccms', new_mccm) a = b + 1
value = info_list[i] print value this_dic[title] = value FullFragment = MakeFullFragment(this_dic["gridpackPATH"], this_dic["PSfragment"], this_dic["card_ref"]) generator_parameters=Make_generator_parameters(this_dic["cross_section"],\ this_dic["filter_efficiency"],\ this_dic["filter_efficiency_error"],\ this_dic["match_efficiency"],\ this_dic["match_efficiency_error"],\ this_dic["negative_weights_fraction"]) new_request = { 'pwg': 'HIG', 'member_of_campaign': this_dic['member_of_campaign'], 'dataset_name': this_dic['dataset_name'], 'generators': this_dic['generators'], "fragment": FullFragment, 'generator_parameters': generator_parameters } # push it to McM put_answer = mcm.put('requests', new_request) if put_answer.get('results'): print('New PrepID: %s' % (put_answer['prepid'])) else: print('Something went wrong while creating a request. %s' % (dumps(put_answer)))
def Run(idx_row,KEY,sheet): output_msg='' #KEY='1bAdzoB9bg6nbyxCOBsTAWSSJy6FHNfmkrIDqY-Nmdi0' #sheet='2018' info_list=GetInfoFromSpreadsheet(idx_row,KEY,sheet,i_column="A",f_column="Z") if len(info_list)==0: print "pass" return title_list=GetTitleFromSpreadsheet(KEY,sheet,i_column="A",f_column="Z") this_dic={} for i in range(0,len(title_list)): title=title_list[i] #print title value=info_list[i] #print value if not value.replace(' ','')=='': #print title this_dic[title]=value ##Combine card refs if 'card_ref2' in this_dic: this_dic['card_ref']=this_dic['card_ref']+'\n'+this_dic['card_ref2'] if not 'size_event' in this_dic: this_dic['size_event']=[600] elif this_dic['size_event'].replace(' ','')=='': this_dic['size_event']=[600] if not 'time_event' in this_dic: this_dic['time_event']=[60] elif this_dic['time_event'].replace(' ','')=='': this_dic['time_event']=[60.] FullFragment=MakeFullFragment(this_dic["gridpackPATH"], this_dic["PSfragment"],this_dic["card_ref"]) generator_parameters=Make_generator_parameters(float(this_dic["cross_section"]),\ float(this_dic["filter_efficiency"]),\ float(this_dic["filter_efficiency_error"]),\ float(this_dic["match_efficiency"]),\ float(this_dic["match_efficiency_error"]),\ float(this_dic["negative_weights_fraction"])) print this_dic['dataset_name'] #print this_dic['PrepID'] new_request = {'pwg': 'HIG', 'member_of_campaign': this_dic['member_of_campaign'],'dataset_name':this_dic['dataset_name'],'generators':this_dic['generators'].split(','),"fragment":FullFragment,'generator_parameters':generator_parameters,'total_events':int(this_dic['total_events']),'mcdb_id':0,'size_event':this_dic['size_event'],'time_event':this_dic['time_event']} check_reqeust_info(this_dic) if 'PrepID' in this_dic: #print "ALREADY" mcm = McM(dev=False) this_request=mcm.get("requests",this_dic["PrepID"]) for key in new_request: this_request[key]=new_request[key] if not this_request['approval'] == 'none': print "already submiited" return this_dic["PrepID"]+'not None status, not updated' update=mcm.update('requests', this_request) return this_dic["PrepID"]+str(update['results']) # push it to McM #mcm = McM(dev=False,cookie="dev-cookie.txt") #mcm = McM(dev=False,cookie='prod-cookie.txt') mcm = McM(dev=False) put_answer = mcm.put('requests', new_request) if put_answer.get('results'): prepid=put_answer['prepid'] print('New PrepID: %s' % (prepid)) #f.write(prepid+'\n') output_msg=str(prepid) else: print('Something went wrong while creating a request. %s' % (dumps(put_answer))) #f.write("fail,idx_row-->"+this_dic['dataset_name']+'\n') output_msg="fail"+str(idx_row)+"-->"+this_dic['dataset_name'] #print output_msg return output_msg