ATLAS Offline Software
Loading...
Searching...
No Matches
periodInfo.AMIWrapper Class Reference
Collaboration diagram for periodInfo.AMIWrapper:

Public Member Functions

 __init__ (self)
 run (self, cmd)
 periods (self, period=None, level=None, project=None, status=None)
 runsForPeriod (self, period, project)
 runListsPerPeriod (self, location='/afs/cern.ch/user/a/atlidbs/nt/DataPeriods/')

Public Attributes

 ami = pyAMI.client.Client('atlas')
 configFileName = os.path.expanduser(options.config)

Detailed Description

Definition at line 29 of file periodInfo.py.

Constructor & Destructor Documentation

◆ __init__()

periodInfo.AMIWrapper.__init__ ( self)

Definition at line 30 of file periodInfo.py.

30 def __init__(self):
31 "Initalise AMI"
32 self.ami=pyAMI.client.Client('atlas')
33 #if options.config:
34 # self.configFileName = os.path.expanduser(options.config)
35 #else:
36 #sys.exit('No authentication file specified')
37 #self.ami.readConfig(self.configFileName)
38 if options.config:
39 self.configFileName = os.path.expanduser(options.config)
40 else:
41 sys.exit('No authentication file specified')
42 print (self.configFileName)
43 #self.ami=pyAMI.client.Client('atlas',key_file=self.configFileName,ignore_proxy=True,verbose=True)
44

Member Function Documentation

◆ periods()

periodInfo.AMIWrapper.periods ( self,
period = None,
level = None,
project = None,
status = None )

Definition at line 58 of file periodInfo.py.

58 def periods(self, period=None, level=None, project=None, status=None):
59 "Get list of periods. By default return all periods"
60
61 cmd = 'ListDataPeriods'
62 if period: cmd += ' period='+period
63 if level: cmd += ' periodLevel='+level
64 if project: cmd += ' projectName='+project
65 if status: cmd += ' status='+status
66 return self.run(cmd)
67

◆ run()

periodInfo.AMIWrapper.run ( self,
cmd )
Execute an AMI command given as a list of command and paramters (ami format) or
space separated string (for convenience)

Definition at line 45 of file periodInfo.py.

45 def run(self, cmd):
46 """
47 Execute an AMI command given as a list of command and paramters (ami format) or
48 space separated string (for convenience)
49 """
50 if isinstance(cmd, str):
51 cmd = cmd.split()
52
53 print ('PRINT AMI CMD', cmd )
54 results = self.ami.execute(cmd,format='dict_object')
55
56 return results.get_rows()
57
Definition run.py:1

◆ runListsPerPeriod()

periodInfo.AMIWrapper.runListsPerPeriod ( self,
location = '/afs/cern.ch/user/a/atlidbs/nt/DataPeriods/' )
Generate files containing run lists for periods if they don't already exist

Definition at line 76 of file periodInfo.py.

76 def runListsPerPeriod(self, location='/afs/cern.ch/user/a/atlidbs/nt/DataPeriods/'):
77 """
78 Generate files containing run lists for periods if they don't already exist
79 """
80 # Don't only update unlocked periods since they may change as looked so need to check at least once more
81 # Need to find a better way fo doing this but for now update all
82 periods = self.periods() #status='unlocked')
83 path = os.path
84 num = 0
85
86 for p in periods:
87 #print ('Looking at period: ', p )
88 projectDir =path.normpath(location + '/' + p['projectName'])
89
90 if not path.exists(projectDir):
91 os.makedirs(projectDir)
92
93 filename = '%s/%s.runs.list' % (projectDir,p['period'])
94
95 #if path.exists(filename): continue
96
97 # Need to remove the file as it might have changed from last time
98 if path.exists(filename):
99 os.system('rm ' + filename)
100
101 print ('* Creating run list for %(projectName)s %(period)s ...' % p)
102
103 num += 1
104 #if p['period'] == 'A1' and p['projectName'] == 'data15_1beam':
105 # continue
106 try:
107 runs = self.runsForPeriod(p['period'], p['projectName'])
108 except:
109 continue
110 runList = '\n'.join(sorted([r['runNumber'] for r in runs]))
111 runList += '\n' # Needed for cat to work!
112 print (runList)
113 with open(filename, 'w') as f:
114 f.write(runList)
115
116 print (' ... written to', filename, '\n' )
117
118 if not num:
119 print ('* No new period infomation to create')

◆ runsForPeriod()

periodInfo.AMIWrapper.runsForPeriod ( self,
period,
project )

Definition at line 68 of file periodInfo.py.

68 def runsForPeriod(self, period, project):
69 "Get info on runs for a particular period"
70
71 cmd = 'GetRunsForDataPeriod period='+period
72 cmd += ' projectName='+project
73 print (cmd)
74 return self.run(cmd)
75

Member Data Documentation

◆ ami

periodInfo.AMIWrapper.ami = pyAMI.client.Client('atlas')

Definition at line 32 of file periodInfo.py.

◆ configFileName

periodInfo.AMIWrapper.configFileName = os.path.expanduser(options.config)

Definition at line 39 of file periodInfo.py.


The documentation for this class was generated from the following file: