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 __init__(self, stepModule, scriptModule): self.stepModule = stepModule self.module = scriptModule self.exitCode = 0 self.stepSpace = None self.script = None self.step = None self.task = None self.job = None currentDir = os.getcwd() Bootstrap.setupLogging(currentDir, useStdout=True) logging.info("Invoking scripts in current directory: %s", currentDir)
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")) task.completeTask(jobLocation = os.getcwd(), logLocation = logLocation) print("Startup.py : %s : shutting down monitor" % time.strftime("%Y-%m-%dT%H:%M:%S")) os.fchmod(1, 0o664) os.fchmod(2, 0o664) if monitor.isAlive(): monitor.shutdown()
3. the task space area, where the steps and cmsRun logs are """ from __future__ import print_function import logging import os import sys import WMCore.WMRuntime.Bootstrap as Bootstrap 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)
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")) task.completeTask(jobLocation=os.getcwd(), logLocation=logLocation) print("Startup.py : %s : shutting down monitor" % time.strftime("%Y-%m-%dT%H:%M:%S")) os.fchmod(1, 0o664) os.fchmod(2, 0o664) if monitor.isAlive():
Just a FYI, there are basically 3 important directories: 1. the pilot home area, where the condor wrapper logs are 2. the job space area, where the sandbox and the runtime log is created 3. the task space area, where the steps and cmsRun logs are """ from __future__ import print_function import logging import os import WMCore.WMRuntime.Bootstrap as Bootstrap 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("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())