13 from __future__
import print_function
17 import pyAMI.atlas.api
as AtlasAPI
18 from subprocess
import call
20 client = pyAMI.client.Client(
29 for i
in grl.split(
','):
30 import xml.etree.ElementTree
31 listGRL += [atype.text.split(
',')
for atype
in xml.etree.ElementTree.parse(grl).getroot().
find(
'NamedLumiRange').findall(
'Metadata')
if atype.get(
'Name') ==
'RunList']
35 def __init__(self, project, derivation, period, acceptTags, sTag, autoCreate=False, grl=None):
47 x0 = AtlasAPI.list_datasets(client, patterns = [c1.project+
'.%.physics_Main.merge.AOD%'], fields = [
'run_number',
'ldn',
'events',
'total_size'], order=
None, limit=
None, show_archived=
False, grl=c1.grl, data_period=c1.period)
48 runs =
set([a[
'run_number']
for a
in x0])
51 print (
'no run in period'+c1.period+
' is listed in GRL:', c1.grl)
55 x = AtlasAPI.list_datasets(client, patterns = [c1.project+
'.%.physics_Main.merg%'+c1.derivation+
'%'], fields = [
'run_number',
'ldn',
'events',
'total_size'], order=
None, limit=
None, show_archived=
False, grl=c1.grl, data_period=c1.period)
60 print (a[
'run_number'], a[
'ldn'])
62 dic1[a[
'ldn'].
split(
'_')[-1]].
append((a[
'run_number'],a[
'ldn']))
64 dic1[a[
'ldn'].
split(
'_')[-1]] = [(a[
'run_number'],a[
'ldn'])]
67 allTags =
sorted(dic1.keys(), key=
lambda k: len(dic1[k]),reverse=
True)
69 print (tag,
':', end=
'')
75 t_acceptTags = c1.acceptTags
if c1.acceptTags
else allTags
79 for t
in t_acceptTags:
80 for a
in dic1.get(t,[]):
91 print (
'No dataset in period',c1.period+
', exiting...')
103 print (
'MISSING ',
' '.
join(runs))
106 dlist=
','.
join([d[1]
for d
in ds])
107 superTag =
'period'+c1.period+
','+c1.sTag+ds[0][1][-5:]
108 comments = superTag+
','+c1.derivation
110 cmd=
'ami cmd COMAPopulateSuperProductionDataset -rucioRegistration="yes" -creationComment="'+comments+
'" -selectionType="run_config" -superTag="'+superTag+
'" -containedDatasets="'+dlist+
'" -separator="," '
111 print (
'command:',cmd)
115 with open(c1.outScript,
'a')
as f1:
120 if not c1.autoCreate:
122 x = raw_input(
"create contianer: y[es]/N[o]/e[xit]")
123 if x ==
'e' or x==
'N':
return
126 call(cmd, shell=
True)
130 grl15 =
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data15_13TeV/20160720/physics_25ns_20.7.xml'
131 grl16 =
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data16_13TeV/20160916/physics_25ns_20.7_ignoreToroidStatus.xml'
132 c1 =
config1(
'data16_13TeV',
'MUON0',
'A', sTag=
'grp16_v01_', acceptTags=[
'p2769',
'p2689',
'p2667'], autoCreate=
False, grl=grl16)
133 c1.outScript =
'createIt_15.sh'
137 periods = AtlasAPI.list_dataperiods(client, 2, 15)
138 c1.project =
'data15_13TeV'
140 c1.acceptTags=[
'p2667']
143 pds =[p[
'period']
for p
in periods
if p[
'status']==
'frozen']
148 for d
in [
'MUON0',
'MUON1',
'MUON2',
'MUON3']:
155 grl15 =
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data15_13TeV/20160720/physics_25ns_20.7.xml'
156 c1 =
config1(
'data15_13TeV',
'MUON0',
'A', sTag=
'grp15_v01_', acceptTags=
None, autoCreate=
False, grl=
None)
157 c1.outScript =
'createIt_15v2.sh'
159 periods = AtlasAPI.list_dataperiods(client, 2, 15)
160 c1.project =
'data15_13TeV'
162 c1.acceptTags=[
'p2889']
165 pds =[p[
'period']
for p
in periods
if p[
'status']==
'frozen']
170 for d
in [
'MUON0',
'MUON1',
'MUON2',
'MUON3']:
177 grl16 =
'/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data16_13TeV/20161101/physics_25ns_20.7_ignoreToroidStatus.xml'
178 c1 =
config1(
'data16_13TeV',
'MUON0',
'A', sTag=
'grp16_v01_', acceptTags=[
'p2769',
'p2689',
'p2667'], autoCreate=
False, grl=grl16)
179 c1.outScript =
'createIt_16Later2.sh'
181 periods = AtlasAPI.list_dataperiods(client, 2, 16)
183 c1.project =
'data16_13TeV'
191 pds = [
'J',
'K',
'L']
194 for d
in [
'MUON0',
'MUON1',
'MUON2',
'MUON3']:
199 if __name__ ==
'__main__':