Skip to content

Commit 224967d

Browse files
committed
Infer log filename from the log manifest if needed.
1 parent f5d3347 commit 224967d

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • python/fusion_engine_client/utils

python/fusion_engine_client/utils/log.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fnmatch
22
import glob
3+
import json
34
import os
45

56
from . import trace as logging
@@ -303,11 +304,26 @@ def _search_directory(dir_path):
303304
_logger.info("File '%s' not found. Searching for a matching log." % input_path)
304305

305306
try:
307+
candidate_files = list(candidate_files) + [MANIFEST_FILE_NAME]
306308
matches = find_log_by_pattern(input_path, log_base_dir=log_base_dir,
307309
log_test_filenames=candidate_files, return_test_file=True)
308310
log_dir = matches[0][0]
309311
log_id = matches[0][1]
310312
input_path = matches[0][2]
313+
314+
# If we didn't find one of the recognized log filenames, but instead found a manifest file, load the
315+
# manifest and use that to infer the input filename.
316+
if os.path.basename(input_path) == MANIFEST_FILE_NAME:
317+
manifest_path = input_path
318+
input_path = None
319+
with open(manifest_path, 'rt') as f:
320+
manifest = json.load(f)
321+
channels = manifest.get('channels', [])
322+
if len(channels) > 0:
323+
input_path = os.path.join(log_dir, channels[0])
324+
if input_path is None or not os.path.exists(input_path):
325+
raise FileNotFoundError(
326+
"Found manifest file in '%s' but could not find corresponding log file." % log_dir)
311327
except RuntimeError as e:
312328
# Multiple matching directories found.
313329
raise e

0 commit comments

Comments
 (0)