Skip to content
Snippets Groups Projects
Commit da5a83ec authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'fix-ATEAM-777-alt' into 'master'

Resolve ATEAM-777 "Fix  alt"

Closes ATEAM-777

See merge request atlas/athena!47247
parents f9cf69e4 8cb7ec28
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
__all__ = ['metadata', 'metadata_all_files', 'convert_itemList', 'convert_metadata_items']
__all__ = ['metadata', 'convert_itemList', 'convert_metadata_items']
metadata = {}
metadata_all_files = {}
def _setup():
from PyUtils.MetaReader import read_metadata
from AthenaCommon.Logging import logging
msg = logging.getLogger('MetaReader')
msg = logging.getLogger('MetaReaderPeeker')
global metadata
global metadata_all_files
# get input file name
from RecExConfig.RecoFunctions import InputFileNames
......@@ -32,24 +30,20 @@ def _setup():
if len(inFiles) < 1:
msg.warning("No input files specified yet! Cannot do anything.")
return
metadata_all_files = read_metadata(inFiles, mode='peeker', promote=True, ignoreNonExistingLocalFiles=True)
# use first non-empty file
first_filename = None
for file_name, file_info in metadata_all_files.items():
try:
if file_info["nentries"]:
first_filename = file_name
for inFile in inFiles:
metadatas = read_metadata(inFile, mode='peeker', promote=True, ignoreNonExistingLocalFiles=True)
for foundFile, metadata in metadatas.items():
metadata['file_name'] = inFile
if metadata.get("nentries"):
break
except KeyError:
continue
# default to first file name if all input files are empty
if not first_filename:
first_filename = inFiles[0]
metadata = metadata_all_files[first_filename]
metadata['file_name'] = first_filename
# if no nentries > 0 metadata is found, it will keep the last
# convert_itemList and convert_metadata_items have the same implementation as the one in MetaReaderPeekerFull.
......
#!/usr/bin/env python
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
__all__ = ['metadata', 'metadata_all_files', 'convert_itemList', 'convert_metadata_items']
__all__ = ['metadata','convert_itemList', 'convert_metadata_items']
metadata = {}
metadata_all_files = {}
def _setup():
......@@ -12,10 +11,9 @@ def _setup():
from PyUtils.MetaReader import read_metadata
from AthenaCommon.Logging import logging
msg = logging.getLogger('MetaReader')
msg = logging.getLogger('MetaReaderPeekerFull')
global metadata
global metadata_all_files
# get input file name
from RecExConfig.RecoFunctions import InputFileNames
......@@ -34,13 +32,19 @@ def _setup():
msg.warning("No input files specified yet! Cannot do anything.")
return
metadata_all_files = read_metadata(inFiles, mode='full', ignoreNonExistingLocalFiles=True)
first_filename = inFiles[-1] # take only the last input file from the infiles
for inFile in reversed(inFiles):
metadata = metadata_all_files[first_filename]
metadata['file_name'] = first_filename
metadatas = read_metadata(inFile, mode='full', ignoreNonExistingLocalFiles=True)
for foundFile, metadata in metadatas.items():
metadata['file_name'] = inFile
if metadata.get("nentries"):
break
# if no nentries > 0 metadata is found, it will keep the last
# convert_itemList and convert_metadata_items have the same implementation as the one in MetaReaderPeeker.
# If there are changes, these must be modified in both files.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment