init
This commit is contained in:
75
forecasting_model.py
Normal file
75
forecasting_model.py
Normal file
@ -0,0 +1,75 @@
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import time
|
||||
|
||||
# Import necessary components from your project structure
|
||||
from data_analysis.utils.config_model import load_settings, Settings # Import loading function and model
|
||||
from data_analysis.analysis.pipeline import run_eda_pipeline # Import the pipeline entry point
|
||||
|
||||
# Silence overly verbose libraries if needed (e.g., matplotlib)
|
||||
mpl_logger = logging.getLogger('matplotlib')
|
||||
mpl_logger.setLevel(logging.WARNING) # Example: set to WARNING or ERROR
|
||||
|
||||
# --- Basic Logging Setup ---
|
||||
# Configure logging early to catch basic issues.
|
||||
# The level might be adjusted after config loading.
|
||||
logging.basicConfig(level=logging.INFO,
|
||||
format='%(asctime)s - %(levelname)-7s - %(message)s',
|
||||
datefmt='%H:%M:%S')
|
||||
# Get the root logger
|
||||
logger = logging.getLogger()
|
||||
|
||||
# --- Argument Parsing ---
|
||||
def parse_arguments():
|
||||
"""Parses command-line arguments."""
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Run the Energy Forecasting EDA pipeline.",
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
||||
)
|
||||
parser.add_argument(
|
||||
'-c', '--config',
|
||||
type=str,
|
||||
default='config.yaml', # Provide a default config file name
|
||||
help="Path to the YAML configuration file."
|
||||
)
|
||||
# Add other potential command-line overrides here if needed later
|
||||
# parser.add_argument('--debug', action='store_true', help="Override log level to DEBUG.")
|
||||
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
# --- Main Execution ---
|
||||
def main():
|
||||
"""Main execution function."""
|
||||
args = parse_arguments()
|
||||
config_path = Path(args.config)
|
||||
start_time = time.perf_counter()
|
||||
|
||||
# --- Configuration Loading ---
|
||||
_ = load_settings(config_path)
|
||||
logger.info(f"Using configuration from: {config_path.resolve()} (or defaults if loading failed)")
|
||||
|
||||
# --- Pipeline Execution ---
|
||||
try:
|
||||
# Call the main function from your pipeline module
|
||||
run_eda_pipeline()
|
||||
|
||||
end_time = time.perf_counter()
|
||||
logger.info(f"Main script finished successfully in {end_time - start_time:.2f} seconds.")
|
||||
|
||||
except SystemExit as e:
|
||||
# Catch SystemExit if pipeline runner exits intentionally
|
||||
logger.warning(f"Pipeline exited with code {e.code}.")
|
||||
sys.exit(e.code) # Propagate exit code
|
||||
except Exception as e:
|
||||
logger.critical(f"An critical error occurred during pipeline execution: {e}", exc_info=True)
|
||||
end_time = time.perf_counter()
|
||||
logger.info(f"Main script failed after {end_time - start_time:.2f} seconds.")
|
||||
sys.exit(1)
|
||||
return
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
exit(1)
|
Reference in New Issue
Block a user