本文整理汇总了Python中Ganga.Lib.LCG.Grid类的典型用法代码示例。如果您正苦于以下问题:Python Grid类的具体用法?Python Grid怎么用?Python Grid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Grid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __mt_bulk_submit__
def __mt_bulk_submit__(self, node_jdls):
'''submitting jobs in multiple threads'''
job = self.getJobObject()
logger.warning(
'submitting %d subjobs ... it may take a while' % len(node_jdls))
# the algorithm for submitting a single bulk job
class MyAlgorithm(Algorithm):
def __init__(self, cred_req, masterInputWorkspace, ce, delid):
Algorithm.__init__(self)
self.inpw = masterInputWorkspace
self.cred_req = cred_req
self.ce = ce
self.delid = delid
def process(self, jdl_info):
my_sj_id = jdl_info[0]
my_sj_jdl = jdl_info[1]
my_sj_jid = Grid.cream_submit(my_sj_jdl, self.ce, self.delid, self.cred_req)
if not my_sj_jid:
return False
else:
self.__appendResult__(my_sj_id, my_sj_jid)
return True
mt_data = []
for id, jdl in node_jdls.items():
mt_data.append((id, jdl))
myAlg = MyAlgorithm(cred_req=self.credential_requirements,
masterInputWorkspace=job.getInputWorkspace(),
ce=self.CE,
delid=self.delegation_id)
myData = Data(collection=mt_data)
runner = MTRunner(name='cream_jsubmit', algorithm=myAlg,
data=myData, numThread=config['SubmissionThread'])
runner.start()
runner.join(timeout=-1)
if len(runner.getDoneList()) < len(mt_data):
# not all bulk jobs are successfully submitted. canceling the
# submitted jobs on WMS immediately
logger.error(
'some bulk jobs not successfully (re)submitted, canceling submitted jobs on WMS')
Grid.cancel_multiple(runner.getResults().values())
return None
else:
return runner.getResults()
示例2: master_bulk_kill
def master_bulk_kill(self):
'''GLITE bulk resubmission'''
job = self.getJobObject()
# killing the individually re-submitted subjobs
logger.debug('cancelling running/submitted subjobs.')
# 1. collect job ids
ids = []
for sj in job.subjobs:
if sj.status in ['submitted', 'running'] and sj.backend.id:
ids.append(sj.backend.id)
# 2. cancel the collected jobs
ck = Grid.arc_cancel_multiple(ids, self.credential_requirements)
if not ck:
logger.warning('Job cancellation failed')
return False
else:
for sj in job.subjobs:
if sj.backend.id in ids:
sj.updateStatus('killed')
return True
示例3: __setup_sandboxcache__
def __setup_sandboxcache__(self, job):
'''Sets up the sandbox cache object to adopt the runtime configuration of the LCG backend'''
re_token = re.compile('^token:(.*):(.*)$')
self.sandboxcache.timeout = config['SandboxTransferTimeout']
if self.sandboxcache._name == 'LCGSandboxCache':
if not self.sandboxcache.lfc_host:
self.sandboxcache.lfc_host = Grid.__get_lfc_host__()
if not self.sandboxcache.se:
token = ''
se_host = config['DefaultSE']
m = re_token.match(se_host)
if m:
token = m.group(1)
se_host = m.group(2)
self.sandboxcache.se = se_host
if token:
self.sandboxcache.srm_token = token
if (self.sandboxcache.se_type in ['srmv2']) and (not self.sandboxcache.srm_token):
self.sandboxcache.srm_token = config['DefaultSRMToken']
return True
示例4: process
def process(self, jdl_info):
my_sj_id = jdl_info[0]
my_sj_jdl = jdl_info[1]
my_sj_jid = Grid.cream_submit(my_sj_jdl, self.ce, self.delid)
if not my_sj_jid:
return False
else:
self.__appendResult__(my_sj_id, my_sj_jid)
return True
示例5: process
def process(self, jdl_info):
my_sj_id = jdl_info[0]
my_sj_jdl = jdl_info[1]
my_sj_jid = Grid.arc_submit(my_sj_jdl, self.ce, self.arcverbose, self.cred_req)
if not my_sj_jid:
return False
else:
self.__appendResult__(my_sj_id, my_sj_jid)
return True
示例6: kill
def kill(self):
'''Kill the job'''
job = self.getJobObject()
logger.info('Killing job %s' % job.getFQID('.'))
if not self.id:
logger.warning('Job %s is not running.' % job.getFQID('.'))
return False
return Grid.cream_cancelMultiple([self.id])
示例7: kill
def kill(self):
'''Kill the job'''
job = self.getJobObject()
logger.info('Killing job %s' % job.getFQID('.'))
if not self.id:
logger.warning('Job %s is not running.' % job.getFQID('.'))
return False
return Grid.arc_cancel([self.id], self.credential_requirements)
示例8: __setup_sandboxcache__
def __setup_sandboxcache__(self, job):
'''Sets up the sandbox cache object to adopt the runtime configuration of the LCG backend'''
re_token = re.compile('^token:(.*):(.*)$')
self.sandboxcache.vo = config['VirtualOrganisation']
self.sandboxcache.timeout = config['SandboxTransferTimeout']
if self.sandboxcache._name == 'LCGSandboxCache':
if not self.sandboxcache.lfc_host:
self.sandboxcache.lfc_host = Grid.__get_lfc_host__()
if not self.sandboxcache.se:
token = ''
se_host = config['DefaultSE']
m = re_token.match(se_host)
if m:
token = m.group(1)
se_host = m.group(2)
self.sandboxcache.se = se_host
if token:
self.sandboxcache.srm_token = token
if (self.sandboxcache.se_type in ['srmv2']) and (not self.sandboxcache.srm_token):
self.sandboxcache.srm_token = config['DefaultSRMToken']
elif self.sandboxcache._name == 'DQ2SandboxCache':
# generate a new dataset name if not given
if not self.sandboxcache.dataset_name:
from GangaAtlas.Lib.ATLASDataset.DQ2Dataset import dq2outputdatasetname
self.sandboxcache.dataset_name, unused = dq2outputdatasetname(
"%s.input" % get_uuid(), 0, False, '')
# subjobs inherits the dataset name from the master job
for sj in job.subjobs:
sj.backend.sandboxcache.dataset_name = self.sandboxcache.dataset_name
elif self.sandboxcache._name == 'GridftpSandboxCache':
if config['CreamInputSandboxBaseURI']:
self.sandboxcache.baseURI = config['CreamInputSandboxBaseURI']
elif self.CE:
ce_host = re.sub(r'\:[0-9]+', '', self.CE.split('/cream')[0])
self.sandboxcache.baseURI = 'gsiftp://%s/opt/glite/var/cream_sandbox/%s' % (
ce_host, self.sandboxcache.vo)
else:
logger.error('baseURI not available for GridftpSandboxCache')
return False
return True
示例9: test_submit_no_proxy
def test_submit_no_proxy(mocker):
"""
Test that the lack of a proxy object causes the submit to fail
"""
check_proxy = mocker.patch('Ganga.Lib.LCG.Grid.check_proxy', return_value=False)
from Ganga.Lib.LCG import Grid
job_url = Grid.submit('/some/path')
assert check_proxy.call_count == 1
assert job_url is None
示例10: test_submit_bad_output
def test_submit_bad_output(mocker):
"""
Test that the external command returning bad data causes the job to fail
"""
__set_submit_option__ = mocker.patch('Ganga.Lib.LCG.Grid.__set_submit_option__', return_value=' ')
mocker.patch('Ganga.Lib.LCG.Grid.getShell', return_value=Shell)
cmd1 = mocker.patch('Ganga.Utility.GridShell.Shell.cmd1', return_value=(0, 'some bad output', False))
from Ganga.Lib.LCG import Grid
job_url = Grid.submit('/some/path', cred_req=FakeCred())
assert __set_submit_option__.call_count == 1
assert cmd1.call_count == 1
assert job_url is None
示例11: test_submit_expired_proxy
def test_submit_expired_proxy(mocker):
"""
Test that an invalid proxy object causes the submit to fail
"""
check_proxy = mocker.patch('Ganga.Lib.LCG.Grid.check_proxy', return_value=True)
credential = mocker.patch('Ganga.Lib.LCG.Grid.credential', return_value=mocker.MagicMock())
credential.return_value.isValid.return_value = False
from Ganga.Lib.LCG import Grid
job_url = Grid.submit('/some/path')
assert check_proxy.call_count == 1
assert credential.call_count == 1
assert job_url is None
示例12: submit
def submit(self, subjobconfig, master_job_sandbox):
'''Submit the job to the grid'''
ick = False
xrslpath = self.preparejob(subjobconfig, master_job_sandbox)
if xrslpath:
self.id = Grid.arc_submit(xrslpath, self.CE, self.verbose, self.credential_requirements)
if self.id:
self.actualCE = self.CE
ick = True
return ick
示例13: submit
def submit(self, subjobconfig, master_job_sandbox):
'''Submit the job to the grid'''
ick = False
jdlpath = self.preparejob(subjobconfig, master_job_sandbox)
if jdlpath:
self.id = Grid.cream_submit(jdlpath, self.CE, self.delegation_id)
if self.id:
self.actualCE = self.CE
ick = True
return ick
示例14: test_submit
def test_submit(mocker):
"""
Test that a job submit succeeds with valid input
"""
__set_submit_option__ = mocker.patch('Ganga.Lib.LCG.Grid.__set_submit_option__', return_value=' ')
mocker.patch('Ganga.Lib.LCG.Grid.getShell', return_value=Shell)
cmd1 = mocker.patch('Ganga.Utility.GridShell.Shell.cmd1', return_value=(0, 'https://example.com:9000/some_url', False))
from Ganga.Lib.LCG import Grid
job_url = Grid.submit('/some/path', cred_req=FakeCred())
assert __set_submit_option__.call_count == 1
assert cmd1.call_count == 1
assert '/some/path' in cmd1.call_args[0][0], 'JDL path was not passed correctly'
assert job_url == 'https://example.com:9000/some_url'
示例15: process
def process(self, item):
"""
downloads output of one LCG job
"""
pps_check = (True, None)
job = item.jobObj
# it is very likely that the job's downloading task has been
# created and assigned in a previous monitoring loop
# ignore such kind of cases
if job.status in ['completing', 'completed', 'failed']:
return True
# it can also happen that the job was killed/removed by user between
# the downloading task was created in queue and being taken by one of
# the downloading thread. Ignore suck kind of cases
if job.status in ['removed', 'killed']:
return True
job.updateStatus('completing')
outw = job.getOutputWorkspace()
pps_check = Grid.get_output(job.backend.id, outw.getPath(), job.backend.credential_requirements)
if pps_check[0]:
job.updateStatus('completed')
job.backend.exitcode = 0
else:
job.updateStatus('failed')
# update the backend's reason if the failure detected in the
# Ganga's pps
if pps_check[1] != 0:
job.backend.reason = 'non-zero app. exit code: %s' % pps_check[
1]
job.backend.exitcode = pps_check[1]
# needs to update the master job's status to give an up-to-date status
# of the whole job
if job.master:
job.master.updateMasterJobStatus()
self.__appendResult__(job.getFQID('.'), True)
return True