本文整理汇总了Python中Ganga.GPIDev.Lib.Job.Job.subjobs方法的典型用法代码示例。如果您正苦于以下问题:Python Job.subjobs方法的具体用法?Python Job.subjobs怎么用?Python Job.subjobs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ganga.GPIDev.Lib.Job.Job
的用法示例。
在下文中一共展示了Job.subjobs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getOutputDataLFNs
# 需要导入模块: from Ganga.GPIDev.Lib.Job import Job [as 别名]
# 或者: from Ganga.GPIDev.Lib.Job.Job import subjobs [as 别名]
def test_getOutputDataLFNs(db):
j = Job()
j.id = 0
j.backend = db
db._parent = j
#######################
class TestFile(object):
def __init__(self, lfn):
self.lfn = lfn
#######################
def fake_outputfiles_iterator(job, file_type):
assert isinstance(job, Job)
if subjob:
assert job.master is not None
else:
assert job.master is None
assert file_type == DiracFile
return [TestFile('a'), TestFile(''),
TestFile('b'), TestFile(''),
TestFile('c'), TestFile('')]
with patch('GangaDirac.Lib.Backends.DiracBase.outputfiles_iterator', fake_outputfiles_iterator):
subjob = False
assert db.getOutputDataLFNs() == ['a', 'b', 'c']
j.subjobs = [Job(), Job(), Job()]
for sj in j.subjobs:
sj._setParent(j)
subjob = True
assert db.getOutputDataLFNs() == ['a', 'b', 'c'] * 3
示例2: test_removeOutputData
# 需要导入模块: from Ganga.GPIDev.Lib.Job import Job [as 别名]
# 或者: from Ganga.GPIDev.Lib.Job.Job import subjobs [as 别名]
def test_removeOutputData(db):
from GangaDirac.Lib.Files.DiracFile import DiracFile
j = Job()
j.id = 0
j.backend = db
db._parent = j
#######################
class TestFile(object):
def __init__(self):
pass
def remove(self):
return 27
#######################
def fake_outputfiles_foreach(job, file_type, func):
import types
assert isinstance(job, Job)
if subjob:
assert job.master is not None
else:
assert job.master is None
assert file_type == DiracFile
assert isinstance(func, types.FunctionType)
assert func(TestFile()) == 27, 'Didn\'t call remove function'
with patch('GangaDirac.Lib.Backends.DiracBase.outputfiles_foreach', fake_outputfiles_foreach):
subjob = False
assert db.removeOutputData() is None
j.subjobs = [Job(), Job(), Job()]
for sj in j.subjobs:
sj._setParent(j)
subjob = True
assert db.removeOutputData() is None
示例3: test_getOutputData
# 需要导入模块: from Ganga.GPIDev.Lib.Job import Job [as 别名]
# 或者: from Ganga.GPIDev.Lib.Job.Job import subjobs [as 别名]
def test_getOutputData(db, tmpdir):
j = Job()
j.id = 0
j.backend = db
db._parent = j
with pytest.raises(GangaException):
db.getOutputData('/false/dir')
#######################
class TestFile(object):
def __init__(self, lfn, namePattern):
self.lfn = lfn
self.namePattern = namePattern
def get(self):
self.check = 42
test_files = [TestFile('a', 'alpha'), TestFile('', 'delta'),
TestFile('b', 'beta'), TestFile('', 'bravo'),
TestFile('c', 'charlie'), TestFile('', 'foxtrot')]
#######################
def fake_outputfiles_iterator(job, file_type):
assert isinstance(job, Job)
if subjob:
assert job.master is not None
else:
assert job.master is None
assert file_type == DiracFile
return test_files
with patch('GangaDirac.Lib.Backends.DiracBase.outputfiles_iterator', fake_outputfiles_iterator):
# master jobs
#######################
subjob = False
assert db.getOutputData() == ['a', 'b', 'c']
for f in test_files:
if f.lfn in ['a', 'b', 'c']:
assert f.localDir == j.getOutputWorkspace().getPath()
assert f.check, 42 == "didn't call get"
else:
assert not hasattr(f, 'localDir')
assert not hasattr(f, 'check')
assert db.getOutputData(None, ['alpha', 'charlie']) == ['a', 'c']
assert db.getOutputData(tmpdir.dirname, ['alpha', 'charlie']) == ['a', 'c']
# subjobs
########################
j.subjobs = [Job(), Job(), Job()]
i = 0
for sj in j.subjobs:
sj._setParent(j)
sj.id = i
i += 1
subjob = True
assert db.getOutputData() == ['a', 'b', 'c'] * 3
assert db.getOutputData(None, ['beta']) == ['b'] * 3
assert db.getOutputData(tmpdir.dirname, ['alpha', 'charlie']) == ['a', 'c'] * 3
for i in range(3):
assert os.path.isdir(os.path.join(tmpdir.dirname, '0.%d' % i))
os.rmdir(os.path.join(tmpdir.dirname, '0.%d' % i))