From 42914ffba6b4d873ee58fe9a0b78782e8a4f16bb Mon Sep 17 00:00:00 2001 From: Andrew Ferlitsch Date: Wed, 8 Nov 2023 13:46:03 -0800 Subject: [PATCH] fix: read from local file (#2474) * fix: read from local file * fix: GCS file --- .cloud-build/utils/build_results_viewer.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.cloud-build/utils/build_results_viewer.py b/.cloud-build/utils/build_results_viewer.py index 7c4f5aa0b..6681fe7ec 100644 --- a/.cloud-build/utils/build_results_viewer.py +++ b/.cloud-build/utils/build_results_viewer.py @@ -5,14 +5,22 @@ Cloud Storage location: gs://cloud-build-notebooks-presubmit/build_results/ ''' import argparse import json +from util import download_file parser = argparse.ArgumentParser() parser.add_argument('--file', dest='file', default='build.json', type=str, help='build results file') -import json +args = parser.parse_args() -with open('build.json', 'r') as f: +if args.file.startswith("gs://"): + path = args.file[5:] + bucket = path.split('/')[0] + file = path[len(bucket)+1:] + download_file(bucket, file, "build.json") + args.file = "build.json" + +with open(args.file, 'r') as f: results = json.load(f) for item in results.items():