From 7b851fb830dfcb649bb0f63214074144fbb2e4a1 Mon Sep 17 00:00:00 2001 From: Federico Stagni Date: Fri, 24 May 2024 16:38:47 +0200 Subject: [PATCH] fix: adding log headers to InputDataResolution modules --- .../Client/DownloadInputData.py | 19 ++++++++----------- .../Client/InputDataByProtocol.py | 6 +++--- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/DIRAC/WorkloadManagementSystem/Client/DownloadInputData.py b/src/DIRAC/WorkloadManagementSystem/Client/DownloadInputData.py index b1798a39b6c..95b9cda7ea5 100644 --- a/src/DIRAC/WorkloadManagementSystem/Client/DownloadInputData.py +++ b/src/DIRAC/WorkloadManagementSystem/Client/DownloadInputData.py @@ -38,15 +38,17 @@ class DownloadInputData: def __init__(self, argumentsDict): """Standard constructor""" self.name = COMPONENT_NAME - self.log = gLogger.getSubLogger(self.name) - self.log.showHeaders(True) self.inputData = argumentsDict["InputData"] self.configuration = argumentsDict["Configuration"] + self.jobID = self.configuration.get("JobID") # Warning: this contains not only the SEs but also the file metadata self.fileCatalogResult = argumentsDict["FileCatalog"] # By default put each input data file into a separate directory self.inputDataDirectory = argumentsDict.get("InputDataDirectory", "PerFile") - self.jobID = None + + self.log = gLogger.getSubLogger(f"[{self.jobID}]{self.__class__.__name__}") + self.log.showHeaders(True) + self.counter = 1 self.availableSEs = DMSHelpers().getStorageElements() @@ -57,16 +59,9 @@ def execute(self, dataToResolve=None): to leave room for any produced files. """ - print("in execute") - gLogger.always("in execute, gLogger") - print(self.log) - self.log.always("in execute, self.log") - # Define local configuration options present at every site localSESet = set(self.configuration["LocalSEList"]) - self.jobID = self.configuration.get("JobID") - if dataToResolve: self.log.verbose("Data to resolve passed directly to DownloadInputData module") self.inputData = dataToResolve # e.g. list supplied by another module @@ -179,10 +174,12 @@ def execute(self, dataToResolve=None): self.log.error(error, lfn) result = {"OK": False} else: - self.log.info("Preliminary checks OK", f"download {lfn} from {seName}:") + self.log.info("Preliminary checks OK", f": now downloading {lfn} from {seName}") result = self._downloadFromSE(lfn, seName, reps, guid) if not result["OK"]: self.log.error("Download failed", f"Tried downloading from SE {seName}: {result['Message']}") + else: + self.log.info(f"Download of {lfn} from {seName} finalized") else: result = {"OK": False} diff --git a/src/DIRAC/WorkloadManagementSystem/Client/InputDataByProtocol.py b/src/DIRAC/WorkloadManagementSystem/Client/InputDataByProtocol.py index 4bbba282aed..3acedc0beb1 100644 --- a/src/DIRAC/WorkloadManagementSystem/Client/InputDataByProtocol.py +++ b/src/DIRAC/WorkloadManagementSystem/Client/InputDataByProtocol.py @@ -19,11 +19,12 @@ class InputDataByProtocol: def __init__(self, argumentsDict): """Standard constructor""" self.name = COMPONENT_NAME - self.log = gLogger.getSubLogger(self.name) self.inputData = argumentsDict["InputData"] self.configuration = argumentsDict["Configuration"] + self.jobID = self.configuration.get("JobID") self.fileCatalogResult = argumentsDict["FileCatalog"] - self.jobID = None + self.log = gLogger.getSubLogger(f"[{self.jobID}]{self.__class__.__name__}") + self.log.showHeaders(True) # This is because replicas contain SEs and metadata keys! # FIXME: the structure of the dictionary must be fixed to avoid this mess self.metaKeys = { @@ -52,7 +53,6 @@ def execute(self, dataToResolve=None): # Define local configuration options present at every site localSEList = self.configuration["LocalSEList"] - self.jobID = self.configuration.get("JobID") allReplicas = self.configuration.get("AllReplicas", False) if allReplicas: self.log.info("All replicas will be used in the resolution")