ATLAS Offline Software
Loading...
Searching...
No Matches
integration_gridpack_creator.py
Go to the documentation of this file.
1# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
3from AthenaCommon import Logging
4from ...decorators import timed
5import glob
6import os
7import subprocess
8
9
10logger = Logging.logging.getLogger("PowhegControl")
11
12
13@timed("integration gridpack creator")
14def integration_gridpack_creator(process):
15 """! Create tarball containing integration grids for future use.
16
17 Tar up integration grids
18
19 @author James Robinson <james.robinson@cern.ch>
20 """
21 output_tarball_name = "integration_grids.tar.gz"
22 file_names = sum([glob.glob(_f) for _f in process.integration_file_names], [])
23
24# removing duplicates
25 file_names = list(dict.fromkeys(file_names))
26
27 if file_names:
28 logger.info("Tar-ing {} integration grids into {}".format(len(file_names), output_tarball_name))
29 for line in subprocess.check_output(["tar", "cvzf", output_tarball_name] + file_names, stderr=subprocess.STDOUT).splitlines():
30 logger.info(line)
31 for file_name in file_names:
32 try:
33 os.remove(file_name)
34 except OSError:
35 logger.warning("... could not clean up {}".format(file_name))