From c69802f11feb40f15601aa3b8a8dd55c3ba55d01 Mon Sep 17 00:00:00 2001 From: Frank Berghaus <frank.berghaus@cern.ch> Date: Tue, 14 Jul 2020 17:02:37 +0200 Subject: [PATCH] Refactor CA bytestream write configuration Make the bytestream write configuration compliant with the style found in the Athena configuration modules. Update the one client. Executing the configuration now copies 10 events from the default RAW input into a new bytestream file to test the configuration. --- .../python/ByteStreamConfig.py | 82 +++++++++++++------ 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/Event/ByteStreamCnvSvc/python/ByteStreamConfig.py b/Event/ByteStreamCnvSvc/python/ByteStreamConfig.py index ccda176c396..9f4ef0857bf 100644 --- a/Event/ByteStreamCnvSvc/python/ByteStreamConfig.py +++ b/Event/ByteStreamCnvSvc/python/ByteStreamConfig.py @@ -6,14 +6,19 @@ from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator from AthenaConfiguration.ComponentFactory import CompFactory from AthenaConfiguration.AllConfigFlags import ConfigFlags from AthenaConfiguration.TestDefaults import defaultTestFiles +from AthenaConfiguration.MainServicesConfig import MainServicesCfg from AthenaCommon.Configurable import Configurable +from AthenaCommon.Logging import logging from AthenaServices.MetaDataSvcConfig import MetaDataSvcCfg +LOG = logging.getLogger('ByteStreamConfig') + def ByteStreamReadCfg(flags, type_names=None): """Creates resultumulator for BS reading """ result = ComponentAccumulator() + bytestream_conversion = CompFactory.ByteStreamCnvSvc() result.addService(bytestream_conversion) @@ -69,45 +74,70 @@ def ByteStreamReadCfg(flags, type_names=None): return result -def ByteStreamWriteCfg(flags, type_names=[]): +def ByteStreamWriteCfg(flags, type_names=None): + """func level docstring goes here + """ + all_runs = set(flags.Input.RunNumber) + assert ( + len(all_runs) == 1 + ), "Input is from multiple runs, do not know which one to use {}".format( + all_runs + ) + result = ComponentAccumulator("AthOutSeq") - outputSvc = CompFactory.ByteStreamEventStorageOutputSvc() - outputSvc.MaxFileMB = 15000 - # event (beyond which it creates a new file) - outputSvc.MaxFileNE = 15000000 - outputSvc.OutputDirectory = "./" - outputSvc.AppName = "Athena" + + event_storage_output = CompFactory.ByteStreamEventStorageOutputSvc( + MaxFileMB=15000, + MaxFileNE=15000000, # event (beyond which it creates a new file) + OutputDirectory="./", + AppName="Athena", + RunNumber=all_runs.pop(), + ) + result.addService(event_storage_output) # release variable depends the way the env is configured # FileTag = release - allRuns = set(flags.Input.RunNumber) - assert ( - len(allRuns) == 1 - ), "The input is from multiple runs, do not know which one to use {}".format( - allRuns - ) - outputSvc.RunNumber = allRuns.pop() - bytestream_conversion = CompFactory.ByteStreamCnvSvc("ByteStreamCnvSvc") + bytestream_conversion = CompFactory.ByteStreamCnvSvc( + name="ByteStreamCnvSvc", + ByteStreamOutputSvcList=[event_storage_output.getName()], + ) + result.addService(bytestream_conversion) - bytestream_conversion.ByteStreamOutputSvcList = [outputSvc.getName()] - streamAlg = CompFactory.AthenaOutputStream( - "BSOutputStreamAlg", - EvtConversionSvc=bytestream_conversion.getName(), + output_stream = CompFactory.AthenaOutputStream( + name="BSOutputStreamAlg", + EvtConversionSvc=bytestream_conversion.name, OutputFile="ByteStreamEventStorageOutputSvc", - ItemList=type_names, + ItemList=type_names if type_names else list(), ) + result.addEventAlgo(output_stream, primary=True) - result.addService(outputSvc) - result.addService(bytestream_conversion) - result.addEventAlgo(streamAlg, primary=True) return result -if __name__ == "__main__": +def main(): + """Implement running simple functional test""" Configurable.configurableRun3Behavior = True ConfigFlags.Input.Files = defaultTestFiles.RAW + ConfigFlags.Output.doWriteBS = True + ConfigFlags.lock() - acc = ByteStreamReadCfg(ConfigFlags) - acc.store(open("test.pkl", "wb")) + read = ByteStreamReadCfg(ConfigFlags) + read.store(open("test.pkl", "wb")) print("All OK") + + write = ByteStreamWriteCfg(ConfigFlags) + write.printConfig() + LOG.info("Write setup OK") + + acc = MainServicesCfg(ConfigFlags) + acc.merge(read) + acc.merge(write) + acc.printConfig() + LOG.info("Config OK") + + acc.run(10) + + +if __name__ == "__main__": + main() -- GitLab