Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Report in mongo #383

Merged
merged 15 commits into from
Feb 22, 2019
5 changes: 4 additions & 1 deletion Unified/addHoc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
from utils import workflowInfo, getWorkflows, sendEmail, componentInfo, monitor_dir, reqmgr_url, siteInfo, sendLog, getWorkflowById, isHEPCloudReady, agentInfo, unifiedConfiguration, monitor_eos_dir, base_eos_dir, batchInfo
from utils import workflowInfo, getWorkflows, sendEmail, componentInfo, monitor_dir, reqmgr_url, siteInfo, sendLog, getWorkflowById, isHEPCloudReady, agentInfo, unifiedConfiguration, monitor_eos_dir, base_eos_dir, batchInfo, reportInfo

from assignSession import *
import reqMgrClient
Expand Down Expand Up @@ -104,6 +104,9 @@
print "wf that can have logs"
print '\n'.join(sorted(may_have_one))

RI = reportInfo()
RI.purge( grace = 30 )

for (the_dir,logtype) in [(monitor_eos_dir,'report'),
(monitor_dir,'report'),
(monitor_eos_dir,'joblogs'),
Expand Down
90 changes: 90 additions & 0 deletions Unified/rulor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env python
from collections import deque
from assignSession import *
from utils import closeoutInfo, reportInfo, reqmgr_url, componentInfo, moduleLock
from wtcClient import wtcClient
from JIRAClient import JIRAClient
import optparse
import json


def majority_of_139_nanoaod(wfi, record, report):
## check on the main error, and bypass the request
return []

def rulor(spec=None, options=None):

mlock = moduleLock()
if mlock(): return

up = componentInfo(soft=['mcm','wtc'])
if not up.check(): return

if spec:
wfs = session.query(Workflow).filter(Workflow.status.contains('manual')).filter(Workflow.name.contains(spec)).all()
else:
wfs = session.query(Workflow).filter(Workflow.status.contains('manual')).all()

COI = closeoutInfo()
RI = reportInfo()
WC = wtcClient()
JC = JIRAClient()

## a list of function with a given trace ( wfi, record, report) => (action dict list)
rules = [
majority_of_139_nanoaod,
]

for wfo in wfs:
wfi = workflowInfo( reqmgr_url, wfo.name )
record = COI.get( wfo.name )
report = RI.get( wfo.name )
if not record:
print "no information to look at"
continue
print "close out information as in the assistance page"
print json.dumps(record, indent=2)
print "report information as in the unified report"
print json.dumps(report, indent=2)


## parse the information and produce an action document
### a rule for on-going issue with memory in campaign ...
acted = False
for condition in rules:
acts = condition( wfi, record, report):
if acts:
print "list of actions being taken for",wfo.name
for a in acts:
print json.dumps(a, indent=2)
if not options.test:
acted = True
WC.set_actions( acts )
wfo.status = wfo.status.replace('manual','acting')
session.commit()
break

if acted: continue
if "some conditions":
action_doc = { 'workflow' : wfo.name,
'name' : "a task name",
'parameters' : { 'action' : 'acdc',
'memory' : 5000}
}
acted = True
if acted: continue
if "majority of 139":

pass
if acted: continue

if __name__ == "__main__":
url = reqmgr_url

print "yup"
parser = optparse.OptionParser()
parser.add_option('--test',help="Dry run, only show what you want to do", default=False, action="store_true")
(options,args) = parser.parse_args()
spec= args[0] if len(args)!=0 else None

rulor(spec, options)
Loading