patch_scenario_results_schema.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 # Copyright 2016 gRPC authors.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 # Use to patch schema of existing scenario results tables (after adding fields).
17 
18 from __future__ import print_function
19 
20 import argparse
21 import calendar
22 import json
23 import os
24 import sys
25 import time
26 import uuid
27 
28 gcp_utils_dir = os.path.abspath(
29  os.path.join(os.path.dirname(__file__), '../../gcp/utils'))
30 sys.path.append(gcp_utils_dir)
31 import big_query_utils
32 
33 _PROJECT_ID = 'grpc-testing'
34 
35 
36 def _patch_results_table(dataset_id, table_id):
38  with open(os.path.dirname(__file__) + '/scenario_result_schema.json',
39  'r') as f:
40  table_schema = json.loads(f.read())
41  desc = 'Results of performance benchmarks.'
42  return big_query_utils.patch_table(bq, _PROJECT_ID, dataset_id, table_id,
43  table_schema)
44 
45 
46 argp = argparse.ArgumentParser(
47  description='Patch schema of scenario results table.')
48 argp.add_argument('--bq_result_table',
49  required=True,
50  default=None,
51  type=str,
52  help='Bigquery "dataset.table" to patch.')
53 
54 args = argp.parse_args()
55 
56 dataset_id, table_id = args.bq_result_table.split('.', 2)
57 
58 _patch_results_table(dataset_id, table_id)
59 print('Successfully patched schema of %s.\n' % args.bq_result_table)
big_query_utils.create_big_query
def create_big_query()
Definition: tools/gcp/utils/big_query_utils.py:31
big_query_utils.patch_table
def patch_table(big_query, project_id, dataset_id, table_id, fields_schema)
Definition: tools/gcp/utils/big_query_utils.py:140
performance.patch_scenario_results_schema._patch_results_table
def _patch_results_table(dataset_id, table_id)
Definition: patch_scenario_results_schema.py:36
open
#define open
Definition: test-fs.c:46


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:50