def miniStartup(dir = os.getcwd()): """ This is an imitation of the startup script I don't want to try sourcing the main() of the startup Or run this in subprocess """ job = Bootstrap.loadJobDefinition() task = Bootstrap.loadTask(job) Bootstrap.createInitialReport(job = job, task = task, logLocation = "Report.0.pkl") monitor = Bootstrap.setupMonitoring(logPath = "Report.0.pkl") Bootstrap.setupLogging(dir) task.build(dir) task.execute(job) task.completeTask(jobLocation = os.path.join(dir, 'WMTaskSpace'), logLocation = "Report.0.pkl") if monitor.isAlive(): monitor.shutdown() return
def boot(self): """ _boot_ Import the Step Module & get the stepSpace object from it. Get an instance of the Script from the Script Factory """ self.job = Bootstrap.loadJobDefinition() self.task = Bootstrap.loadTask(self.job) stepSpaceMod = __import__(self.stepModule, globals(), locals(), ['stepSpace'], -1) self.stepSpace = stepSpaceMod.stepSpace self.step = self.task.getStep(self.stepSpace.stepName) self.script = getScript(scriptModule) self.script.task = self.task self.script.step = self.step self.script.job = self.job self.script.stepSpace = self.stepSpace
""" _Startup_ Runtime environment startup script """ from __future__ import print_function import os import time import WMCore.WMRuntime.Bootstrap as Bootstrap if __name__ == '__main__': print("Startup.py : %s : loading job definition" % time.strftime("%Y-%m-%dT%H:%M:%S")) job = Bootstrap.loadJobDefinition() print("Startup.py : %s : loading task" % time.strftime("%Y-%m-%dT%H:%M:%S")) task = Bootstrap.loadTask(job) print("Startup.py : %s : setting up monitoring" % time.strftime("%Y-%m-%dT%H:%M:%S")) logLocation = "Report.%i.pkl" % job['retry_count'] Bootstrap.createInitialReport(job = job, task = task, logLocation = logLocation) monitor = Bootstrap.setupMonitoring(logPath = logLocation) print("Startup.py : %s : setting up logging" % time.strftime("%Y-%m-%dT%H:%M:%S")) Bootstrap.setupLogging(os.getcwd()) print("Startup.py : %s : building task" % time.strftime("%Y-%m-%dT%H:%M:%S")) task.build(os.getcwd()) print("Startup.py : %s : executing task" % time.strftime("%Y-%m-%dT%H:%M:%S")) task.execute(job) print("Startup.py : %s : completing task" % time.strftime("%Y-%m-%dT%H:%M:%S"))
if __name__ == '__main__': logging.info( "This log line goes to a parallel universe, but ... setting up logging" ) # WMAgent log has to be written to the pilot area in order to be transferred back Bootstrap.setupLogging(os.path.join(os.getcwd(), '../')) logging.info("Process id: %s\tCurrent working directory: %s", os.getpid(), os.getcwd()) logging.info("Python version: %s", sys.version) logging.info("Python path: %s", sys.path) logging.info("Loading job definition") job = Bootstrap.loadJobDefinition() logging.info("Loading task") task = Bootstrap.loadTask(job) logging.info("Setting up monitoring") reportName = "Report.%i.pkl" % job['retry_count'] Bootstrap.createInitialReport(job=job, reportName=reportName) monitor = Bootstrap.setupMonitoring(logName=reportName) logging.info("Building task at directory: %s", os.getcwd()) task.build(os.getcwd()) logging.info("Executing task at directory: %s", os.getcwd()) task.execute(job) logging.info("Completing task at directory: %s", os.getcwd()) finalReport = task.completeTask(jobLocation=os.getcwd(),