本文整理汇总了Python中Ganga.GPIDev.Lib.Job.Job.getOutputWorkspace方法的典型用法代码示例。如果您正苦于以下问题:Python Job.getOutputWorkspace方法的具体用法?Python Job.getOutputWorkspace怎么用?Python Job.getOutputWorkspace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ganga.GPIDev.Lib.Job.Job
的用法示例。
在下文中一共展示了Job.getOutputWorkspace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getOutputSandbox
# 需要导入模块: from Ganga.GPIDev.Lib.Job import Job [as 别名]
# 或者: from Ganga.GPIDev.Lib.Job.Job import getOutputWorkspace [as 别名]
def test_getOutputSandbox(db):
j = Job()
j.id = 0
j.backend = db
db._parent = j
db.id = 1234
temp_dir = j.getOutputWorkspace().getPath()
with patch('GangaDirac.Lib.Backends.DiracBase.execute', return_value={'OK': True}) as execute:
assert db.getOutputSandbox(), 'didn\'t run'
execute.assert_called_once_with("getOutputSandbox(1234,'%s')" % temp_dir)
test_dir = 'test_dir'
with patch('GangaDirac.Lib.Backends.DiracBase.execute', return_value={'OK': True}) as execute:
assert db.getOutputSandbox(test_dir), 'didn\'t run with modified dir'
execute.assert_called_once_with("getOutputSandbox(1234,'%s')" % test_dir)
with patch('GangaDirac.Lib.Backends.DiracBase.execute') as execute:
assert not db.getOutputSandbox(test_dir), 'didn\'t fail gracefully'
execute.assert_called_once()
示例2: test_getOutputSandbox
# 需要导入模块: from Ganga.GPIDev.Lib.Job import Job [as 别名]
# 或者: from Ganga.GPIDev.Lib.Job.Job import getOutputWorkspace [as 别名]
def test_getOutputSandbox(db, mocker):
mocker.patch('Ganga.GPIDev.Credentials.credential_store')
j = Job()
j.id = 0
j.backend = db
db._parent = j
db.id = 1234
temp_dir = j.getOutputWorkspace().getPath()
with patch('GangaDirac.Lib.Backends.DiracBase.execute', return_value=True) as execute:
assert db.getOutputSandbox(), 'didn\'t run'
execute.assert_called_once_with("getOutputSandbox(1234,'%s')" % temp_dir, cred_req=mocker.ANY)
test_dir = 'test_dir'
with patch('GangaDirac.Lib.Backends.DiracBase.execute', return_value=True) as execute:
assert db.getOutputSandbox(test_dir), 'didn\'t run with modified dir'
execute.assert_called_once_with("getOutputSandbox(1234,'%s')" % test_dir, cred_req=mocker.ANY)
with patch('GangaDirac.Lib.Backends.DiracBase.execute', side_effect=GangaDiracError('test Exception')) as execute:
assert not db.getOutputSandbox(test_dir), 'didn\'t fail gracefully'
execute.assert_called_once()
示例3: test_getOutputData
# 需要导入模块: from Ganga.GPIDev.Lib.Job import Job [as 别名]
# 或者: from Ganga.GPIDev.Lib.Job.Job import getOutputWorkspace [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))