geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smgol...@apache.org
Subject [geode-benchmarks] branch develop updated: Finish up unique identification of builds. (#73)
Date Tue, 09 Apr 2019 21:49:53 GMT
This is an automated email from the ASF dual-hosted git repository.

smgoller pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-benchmarks.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9639b6d  Finish up unique identification of builds. (#73)
9639b6d is described below

commit 9639b6d6d90bd6fd501e527720be698c5bf25c43
Author: Sean Goller <sean@goller.net>
AuthorDate: Tue Apr 9 14:49:49 2019 -0700

    Finish up unique identification of builds. (#73)
    
    Authored-by: Sean Goller <sgoller@pivotal.io>
---
 infrastructure/scripts/aws/submit_benchmark.py | 37 +++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 6 deletions(-)

diff --git a/infrastructure/scripts/aws/submit_benchmark.py b/infrastructure/scripts/aws/submit_benchmark.py
index 9cc9adf..60904f9 100755
--- a/infrastructure/scripts/aws/submit_benchmark.py
+++ b/infrastructure/scripts/aws/submit_benchmark.py
@@ -18,7 +18,11 @@
 # limitations under the License.
 
 import argparse
+import hashlib
 import json
+import os
+import re
+
 import psycopg2
 import creds
 import csv
@@ -31,12 +35,17 @@ parser.add_argument('--benchmark_dir', '-b',
 parser.add_argument('--identifier', '-i', help='Unique identifier for this benchmark result')
 parser.add_argument('--instance_id', '-I', help='instance id to use if not present in metadata')
 args = parser.parse_args()
-
+build_identifier = ""
 benchmark_dir = args.benchmark_dir.rstrip('/')
-build_identifier = args.identifier
+print("***************************")
+print(f"processing benchmark data set in {benchmark_dir}.")
 
-with open(f"{benchmark_dir}/metadata.json", "r") as read_file:
-    data = json.load(read_file)
+if args.identifier is not None:
+    build_identifier = args.identifier
+metadata_file = f"{benchmark_dir}/metadata.json"
+with open(metadata_file, "r") as read_file:
+    metadata_string = read_file.read()
+    data = json.loads(metadata_string)
 
 
 # what we need to create a benchmark_build entry
@@ -65,6 +74,22 @@ if data["testMetadata"] is not None:
             testmetadata["build_identifier"] is not None:
         build_identifier = testmetadata["build_identifier"]
 
+if build_identifier == "":
+    m = hashlib.sha1()
+    m.update(metadata_string.encode('utf-8'))
+    m.update(f"{os.path.getmtime(metadata_file):.9f}".encode('utf-8'))
+    build_identifier = m.hexdigest()
+
+print(f"The build identifier for this benchmark dataset is {build_identifier} ")
+
+if instance_id == "":
+    possible_benchmark_archive_dir = benchmark_dir + "/../.."
+    possible_instance_id = os.path.basename(os.path.abspath(possible_benchmark_archive_dir))
+    if re.search(r'Benchmark-\d+-\d+',possible_instance_id) is not None:
+        instance_id = possible_instance_id
+
+print(f"The instance id for this benchmark dataset is {instance_id}")
+
 # Set up a connection to the postgres server.
 conn_string = "host=" + creds.PGHOST + \
               " port=5432" + \
@@ -72,7 +97,7 @@ conn_string = "host=" + creds.PGHOST + \
               " user=" + creds.PGUSER + \
               " password=" + creds.PGPASSWORD
 conn = psycopg2.connect(conn_string)
-print("Connected!")
+print("Connected to database!")
 
 # Create a cursor object
 cursor = conn.cursor()
@@ -83,7 +108,7 @@ cursor.execute(identifier_command, (build_identifier,))
 rows = cursor.fetchall()
 
 if len(rows) > 0:
-    print("This build data has already been submitted to the database.")
+    print("* This build data has already been submitted to the database.")
     exit(1)
 
 


Mime
View raw message