-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsynchronizer.py
More file actions
42 lines (34 loc) · 2.01 KB
/
Copy pathsynchronizer.py
File metadata and controls
42 lines (34 loc) · 2.01 KB
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
import argparse
import importlib
MODEL_SYNC_MAP = {
"company" : ("tables.company" , "sync_company"),
"company_performance" : ("tables.company_performance" , "sync_company_performance"),
"company_financials" : ("tables.company_financials" , "sync_company_financials"),
"company_ownership" : ("tables.company_ownership" , "sync_process_ownership"),
"commodity_price" : ("tables.commodity_price" , "sync_commodity_price"),
"mining_contract" : ("tables.mining_contract" , "sync_mining_contract"),
"export_destination" : ("tables.export_destination" , "sync_export_destination"),
"sales_destination" : ("tables.sales_destination" , "sync_sales_destination"),
"global_commodity_data" : ("tables.global_commodity" , "sync_global_commodity_data"),
"mining_site" : ("tables.mining_site" , "sync_mining_site"),
"resources_and_reserves" : ("tables.reserves_resources" , "sync_resources_and_reserves"),
"total_commodities_production" : ("tables.total_commodities_production", "sync_total_commodities_production"),
"peers" : ("scripts.compute_peers" , "compute_all_peers"),
}
def main():
parser = argparse.ArgumentParser(description="Data sync CLI")
parser.add_argument(
"action", choices=["sync"], help="Action to perform (only 'sync' supported)"
)
parser.add_argument(
"model", choices=MODEL_SYNC_MAP.keys(), help="Specify the model to sync"
)
args = parser.parse_args()
if args.action == "sync":
module_path, func_name = MODEL_SYNC_MAP[args.model]
module = importlib.import_module(module_path)
sync_func = getattr(module, func_name)
sync_func()
print(f"{args.model} synced.")
if __name__ == "__main__":
main()