mirror of
https://github.com/GoogleCloudPlatform/vertex-ai-samples.git
synced 2026-09-26 14:42:04 +00:00
feat: auto find latest build results (#2517)
This commit is contained in:
@@ -7,11 +7,16 @@ import argparse
|
||||
import json
|
||||
from util import download_file
|
||||
import csv
|
||||
import datetime
|
||||
from google.cloud import storage
|
||||
|
||||
BUILD_BUCKET = "cloud-build-notebooks-presubmit"
|
||||
BUILD_FOLDER = "build_results"
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--file', dest='file',
|
||||
default='build.json', type=str, help='build results file')
|
||||
default=None, type=str, help='build results filei (local or GCS)')
|
||||
args = parser.parse_args()
|
||||
|
||||
investigate = {}
|
||||
@@ -20,6 +25,19 @@ with open('investigate.csv', 'r') as csvfile:
|
||||
for row in reader:
|
||||
investigate[row[0][:-6]] = row[1]
|
||||
|
||||
if not args.file:
|
||||
client = storage.Client()
|
||||
blobs = client.list_blobs(BUILD_BUCKET, prefix=BUILD_FOLDER)
|
||||
newest_time = datetime.datetime(2000, 1, 1)
|
||||
for blob in blobs:
|
||||
# individual PR
|
||||
if blob.size < 2000:
|
||||
continue
|
||||
time_created = blob.time_created.replace(tzinfo=None)
|
||||
if time_created > newest_time:
|
||||
newest_time = time_created
|
||||
args.file = f"gs://{BUILD_BUCKET}/{blob.name}"
|
||||
|
||||
if args.file.startswith("gs://"):
|
||||
path = args.file[5:]
|
||||
bucket = path.split('/')[0]
|
||||
|
||||
Reference in New Issue
Block a user