diff --git a/xexe/cli.py b/xexe/cli.py index dbed5d8..94b81a5 100644 --- a/xexe/cli.py +++ b/xexe/cli.py @@ -10,7 +10,7 @@ from dotenv import load_dotenv from xexe.constants import PATHS, RATES_SOURCES from xexe.inputs_handling import handle_get_rates_inputs -from xexe.processes import run_get_rates, run_xe_healthcheck +from xexe.processes import run_dwh_healthcheck, run_get_rates, run_xe_healthcheck logging.basicConfig( level=logging.DEBUG, @@ -51,6 +51,13 @@ def xe_healthcheck(): logger.info("Healthcheck attempt finished.") +@cli.command() +def dwh_healthcheck(): + logger.info("Running healthcheck against dwh API.") + run_dwh_healthcheck() + logger.info("Healthcheck attempt finished.") + + @cli.command() @click.option( "--start-date", diff --git a/xexe/processes.py b/xexe/processes.py index 0974989..159161d 100644 --- a/xexe/processes.py +++ b/xexe/processes.py @@ -8,13 +8,8 @@ from xecd_rates_client import XecdClient from xexe.constants import RATES_SOURCES from xexe.exchange_rates import ExchangeRates, add_equal_rates, add_inverse_rates -from xexe.rate_fetching import ( - MockRateFetcher, - RateFetcher, - XERateFetcher, - build_rate_fetcher, -) -from xexe.rate_writing import CSVRateWriter, RateWriter, build_rate_writer +from xexe.rate_fetching import build_rate_fetcher +from xexe.rate_writing import build_rate_writer from xexe.utils import DateRange, generate_currency_and_dates_combinations logger = logging.getLogger() @@ -58,6 +53,18 @@ def run_xe_healthcheck() -> None: logger.info(account_info_response) +def run_dwh_healthcheck(): + """ + Try to connect to the DWH and perform some pre-requisites checks. + + If this doesn't pass, don't even try to fetch rates because you won't be + able to write them into the DWH. + """ + logger.info("Connecting to DWH and looking for schema.") + dwh_rate_writer = build_rate_writer(output="dwh") + logger.info("DWH reached successfully.") + + def run_get_rates( date_range: DateRange, currencies: List[Currency],