-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal_history_ingest.py
53 lines (39 loc) · 1.2 KB
/
local_history_ingest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import argparse
import logging
import os
from typing import List
from pymongo import MongoClient
import mcs_history_ingest
"""
Use for testing ingest changes locally (not for use in production)
"""
def find_history_files(folder: str) -> dict:
history_files = [
f for f in os.listdir(
folder) if str(f).endswith(".json")]
history_files.sort()
return history_files
def ingest_history_files(
folder: str) -> None:
client = MongoClient(
'mongodb://mongomcs:mongomcspassword@localhost:27017/mcs')
history_files = find_history_files(folder)
for file in history_files:
mcs_history_ingest.automated_history_ingest_file(
file, folder, "mcs", client)
def main() -> None:
parser = argparse.ArgumentParser(
description='Ingest MCS History JSON files into Elasticsearch')
parser.add_argument(
'--folder',
required=True,
help='Folder location of files to important')
args = parser.parse_args()
ingest_history_files(
args.folder
)
if __name__ == '__main__':
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
main()