Skip to content

Commit bf795b5

Browse files
authored
Merge branch 'develop' into release-7.1.2
2 parents d56b628 + 09b017a commit bf795b5

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

ganga/GangaDirac/Lib/Backends/DiracBase.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,11 +700,29 @@ def removeOutputData(self):
700700
# Note when the API can accept a list for removeFile I will change
701701
# this.
702702
j = self.getJobObject()
703+
logger.info("Removing all DiracFile output for job %s" % j.id)
704+
lfnsToRemove = []
703705
if j.subjobs:
704706
for sj in j.subjobs:
705-
outputfiles_foreach(sj, DiracFile, lambda x: x.remove())
707+
outputfiles_foreach(sj, DiracFile, lambda x: lfnsToRemove.append(x.lfn))
706708
else:
707-
outputfiles_foreach(j, DiracFile, lambda x: x.remove())
709+
outputfiles_foreach(j, DiracFile, lambda x: lfnsToRemove.append(x.lfn))
710+
dirac_cmd = "removeFile(%s)" % lfnsToRemove
711+
try:
712+
result = execute(dirac_cmd, cred_req=self.credential_requirements)
713+
except GangaDiracError as err:
714+
msg = 'Problem removing files: %s' % str(err)
715+
logger.warning(msg)
716+
return False
717+
def clearFileInfo(f):
718+
f.lfn = ""
719+
f.locations = []
720+
f.guid = ''
721+
if j.subjobs:
722+
for sj in j.subjobs:
723+
outputfiles_foreach(sj, DiracFile, lambda x: clearFileInfo(x))
724+
else:
725+
outputfiles_foreach(j, DiracFile, lambda x: clearFileInfo(x))
708726

709727
def getOutputData(self, outputDir=None, names=None, force=False):
710728
"""Retrieve data stored on SE to dir (default=job output workspace).

ganga/GangaDirac/test/Unit/Backends/TestDiracBase.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def test_removeOutputData(db):
300300

301301
class TestFile(object):
302302
def __init__(self):
303-
pass
303+
self.lfn = 27
304304

305305
def remove(self):
306306
return 27
@@ -316,18 +316,18 @@ def fake_outputfiles_foreach(job, file_type, func):
316316
assert job.master is None
317317
assert file_type == DiracFile
318318
assert isinstance(func, types.FunctionType)
319-
assert func(TestFile()) == 27, 'Didn\'t call remove function'
320319

321320
with patch('GangaDirac.Lib.Backends.DiracBase.outputfiles_foreach', fake_outputfiles_foreach):
322-
subjob = False
323-
assert db.removeOutputData() is None
321+
with patch('GangaDirac.Lib.Backends.DiracBase.execute', return_value=True):
322+
subjob = False
323+
assert db.removeOutputData() is None
324324

325-
j.subjobs = [Job(), Job(), Job()]
326-
for sj in j.subjobs:
327-
sj._setParent(j)
325+
j.subjobs = [Job(), Job(), Job()]
326+
for sj in j.subjobs:
327+
sj._setParent(j)
328328

329-
subjob = True
330-
assert db.removeOutputData() is None
329+
subjob = True
330+
assert db.removeOutputData() is None
331331

332332

333333
def test_getOutputData(db, tmpdir):

0 commit comments

Comments
 (0)