def get_script_object(config_file, job_selector_str, only_success=False, require_task=False): config = gc_create_config(config_file=config_file, load_only_old_config=True) (task, job_selector) = _get_job_selector_and_task(config, job_selector_str, require_task) if only_success: job_selector = JobSelector.create_instance('AndJobSelector', ClassSelector(JobClass.SUCCESS), job_selector) new_config = gc_create_config(config_file=config_file) jobs_config = new_config.change_view(set_sections=['jobs']) job_db = jobs_config.get_plugin('job database', 'TextFileJobDB', cls='JobDB', pkwargs={'job_selector': job_selector}, on_change=None) class ScriptObject(object): def __init__(self, config, new_config, task, job_db): (self.config, self.new_config) = (config, new_config) (self.task, self.job_db) = (task, job_db) return ScriptObject(config, new_config, task, job_db)
def __init__(self, workdir, outdir, currentdir): # , xml_base, n_xml): gridconfig = gridconfig_base with open("temp.conf", 'w') as file_: file_.write(gridconfig) print "grid-control config was written, starting grid-control..." if 'Settings' in locals(): raise Exception( 'This file is supposed to be run directly by python - not by go.py!' ) try: from grid_control_api import gc_create_config, gc_create_workflow except ImportError: raise Exception( 'grid-control is not correctly installed ' + 'or the gc package directory is not part of the PYTHONPATH.') from grid_control.utils import abort gcconfig = gc_create_config( config_file="temp.conf", config_dict={ 'global': { 'workdir': '/nfs/dust/cms/user/garbersc/forBaconJets/workdirs/' + workdir }, 'UserTask': { 'dataset': currentdir + "/" + workdir + "/*.xml" }, 'storage': { 'se path': outdir + "/" + workdir, } }) workflow = gc_create_workflow(gcconfig) workflow.run() abort(False) print "grid-control was closed"
#!/usr/bin/env python import logging # Throw exceptions if the file is executed in the wrong way or grid-control is incorrectly installed if 'Settings' in locals(): raise Exception('This file is supposed to be run directly by python - not by go.py!') try: from grid_control_api import gc_create_config, gc_create_workflow from grid_control_settings import Settings except ImportError: raise Exception('grid-control is not correctly installed ' + 'or the gc package directory is not part of the PYTHONPATH.') setup = Settings() setup.Global.report = 'null' setup.Global.backend = 'Host' setup.Global.task = 'UserTask' setup.Global.duration = -1 setup.jobs.jobs = 1 setup.jobs.wall_time = 1 setup.task.executable = 'Example02_local.sh' setup.interactive.default = False config = gc_create_config(config_dict=setup.get_config_dict()) logging.getLogger().setLevel(logging.CRITICAL) logging.getLogger('jobs').setLevel(logging.INFO) workflow = gc_create_workflow(config) workflow.run()
'This file is supposed to be run directly by python - not by go.py!') try: from grid_control_api import gc_create_config, gc_create_workflow except ImportError: # .. or if grid-control is incorrectly installed raise Exception( 'grid-control is not correctly installed ' + 'or the gc package directory is not part of the PYTHONPATH.') # Setup workflow config = gc_create_config( config_dict={ 'interactive': { 'default': False }, 'global': { 'backend': 'Host', 'task': 'UserTask' }, 'task': { 'executable': 'Example02_local.sh' }, 'jobs': { 'wall time': '1:00', 'jobs': 2 }, }) # Create and run workflow with GUI output workflow = gc_create_workflow(config) workflow.run(duration=-1)
import logging # Throw exceptions if the file is executed in the wrong way or grid-control is incorrectly installed if 'Settings' in locals(): raise Exception( 'This file is supposed to be run directly by python - not by go.py!') try: from grid_control_api import gc_create_config, gc_create_workflow from grid_control_settings import Settings except ImportError: raise Exception( 'grid-control is not correctly installed ' + 'or the gc package directory is not part of the PYTHONPATH.') setup = Settings() setup.Global.report = 'null' setup.Global.backend = 'Host' setup.Global.task = 'UserTask' setup.Global.duration = -1 setup.jobs.jobs = 1 setup.jobs.wall_time = 1 setup.task.executable = 'Example02_local.sh' setup.interactive.default = False config = gc_create_config(config_dict=setup.get_config_dict()) logging.getLogger().setLevel(logging.CRITICAL) logging.getLogger('jobs').setLevel(logging.INFO) workflow = gc_create_workflow(config) workflow.run()
#!/usr/bin/env python if 'Settings' in locals(): # Throw exceptions if the file is executed in the wrong way raise Exception('This file is supposed to be run directly by python - not by go.py!') try: from grid_control_api import gc_create_config, gc_create_workflow except ImportError: # .. or if grid-control is incorrectly installed raise Exception('grid-control is not correctly installed ' + 'or the gc package directory is not part of the PYTHONPATH.') # Setup workflow config = gc_create_config(config_dict={ 'interactive': {'default': False}, 'global': {'backend': 'Host', 'task': 'UserTask'}, 'task': {'executable': 'Example02_local.sh'}, 'jobs': {'wall time': '1:00', 'jobs': 2}, }) # Create and run workflow with GUI output workflow = gc_create_workflow(config) workflow.run(duration=-1)
def install_activity_monitor(): config = gc_create_config(config_dict={'global': {'activity max length': 1000}}) GCStreamHandler.push_std_stream( ActivityMonitor.create_instance('DefaultActivityMonitor', config, sys.stdout, True), ActivityMonitor.create_instance('DefaultActivityMonitor', config, sys.stderr))