Skip to content

Commit 7c1b4da

Browse files
committed
add count_json_recs() to print total records for CI validation.
Signed-off-by: michael vincerra <michael.vincerra@intel.com>
1 parent 86f9ac8 commit 7c1b4da

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

src/db.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ def make_json_list(basedir:str):
2525
print(f"Error. Ensure root directory is oneAPI-samples repo. \n: {e}")
2626

2727
def merge_json_files(filepaths:list):
28-
'''Create pre-prod database from merged sample.json files from list of filenames'''
28+
'''From a list of filenames, output as json a pre-prod database of all sample.json files'''
2929
results_list = []
3030
try:
3131
for f in filepaths:
32-
print(f)
3332
with open(f, 'r') as infile:
3433
results_list.append(json.load(infile))
3534
# print(results_list)
@@ -85,13 +84,21 @@ def df_to_db(file_paths:list):
8584
db = df.to_json(rev_json, orient='records')
8685
return db
8786

87+
def count_json_recs(filename:str):
88+
try:
89+
with open(filename) as f:
90+
db = json.load(f)
91+
print("TOTAL RECORDS:",len(db))
92+
except Exception as e:
93+
print(f"{filename} not found. \n{e}")
94+
8895
def main():
8996
'''Orchestrate sequence of steps to output sample_db_prd.json'''
9097
rootdir = sys.argv[-1]
9198
file_paths = make_json_list(rootdir)
9299
merge_json_files(file_paths)
93100
json_db = df_to_db(file_paths)
94-
101+
count_json_recs("docs/_static/sample_db_prd.json")
95102
return json_db
96103

97104
if __name__ == "__main__":

0 commit comments

Comments
 (0)