-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
50 lines (43 loc) · 1.4 KB
/
main.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
"""
Main script for ETL process
"""
import asyncio
import concurrent.futures
import logging
import pandas as pd
from analysis import numerical_eda, visualize_data
from core import logging_config
from core.persistence_manager import PersistenceManager
from db.db import init_db
from engineering import extract_data, transform_data, load_to_db
logging_config.setup_logging()
logger: logging.Logger = logging.getLogger(__name__)
async def main() -> None:
"""
Main function to execute
:return: None
:rtype: NoneType
"""
logger.info("Running main method")
dataframe: pd.Dataframe = extract_data()
numerical_eda(dataframe)
transformed_df = transform_data(dataframe)
visualize_data(transformed_df)
PersistenceManager.save_to_pickle(transformed_df)
await init_db()
numerical_eda(transformed_df) # Check statistics for final df
try:
loaded: bool = await load_to_db(transformed_df)
except Exception as exc:
logger.error(exc)
raise exc
if loaded:
logger.info("Data loaded")
logger.info("ETL pipeline completed successfully")
if __name__ == '__main__':
logger.info("First log message")
with concurrent.futures.ThreadPoolExecutor() as executor:
logger.warning("Executing Thread Pool")
executor.submit(asyncio.run, main())
logger.warning("Executor submitted")
logger.info("End of the program execution")