diff --git a/config.yml b/config.yml index 3c540f2..d1c632f 100644 --- a/config.yml +++ b/config.yml @@ -2,6 +2,7 @@ default: data_prep_outputs_path: "" # a single, absolute or relative path to a directory where the outputs will be saved asset_impact_data_path: "" # a single, absolute or relative path to a directory that contains the AI inputs (can be the same as `factset_data_path`) factset_data_path: "" # a single, absolute or relative path to a directory that contains the FactSet inputs (can be the same as `asset_impact_data_path`) + preflight_data_path: "" # a single, absolute or relative path to a directory that contains a previous "currencies.rds" file and/or will be used to save a copy of pre-flight data files generated on-the-fly (by default [""], this is set the same path as `data_prep_outputs_path`) masterdata_ownership_filename: "" # a single filename of the intended masterdata_ownership CSV (must exist in the `asset_impact_data_path` directory) masterdata_debt_filename: "" # a single filename of the intended masterdata_debt CSV (must exist in the `asset_impact_data_path` directory) ar_company_id__factset_entity_id_filename: "" # a single filename of the intended ar_company_id__factset_entity_id CSV (must exist in the `asset_impact_data_path` directory) diff --git a/run_pacta_data_preparation.R b/run_pacta_data_preparation.R index bce53d1..90b8a28 100644 --- a/run_pacta_data_preparation.R +++ b/run_pacta_data_preparation.R @@ -96,9 +96,16 @@ factset_manual_pacta_sector_override_path <- # pre-flight filepaths --------------------------------------------------------- +preflight_data_path <- config$preflight_data_path +if (preflight_data_path == "") { + preflight_data_path <- data_prep_outputs_path +} + +currencies_preflight_data_path <- file.path(preflight_data_path, "currencies.rds") currencies_data_path <- file.path(data_prep_outputs_path, "currencies.rds") index_regions_data_path <- file.path(data_prep_outputs_path, "index_regions.rds") +index_regions_preflight_data_path <- file.path(preflight_data_path, "index_regions.rds") # computed options ------------------------------------------------------------- @@ -157,10 +164,16 @@ if (update_currencies) { currencies <- pacta.data.scraping::get_currency_exchange_rates( quarter = imf_quarter_timestamp ) + saveRDS(currencies, currencies_preflight_data_path) +} else { + logger::log_info("Using pre-existing currency data.") + # This requires the preflight path to be defined in the config + currencies <- readRDS(currencies_preflight_data_path) } logger::log_info("Scraping index regions.") index_regions <- pacta.data.scraping::get_index_regions() +saveRDS(index_regions, index_regions_preflight_data_path) logger::log_info("Fetching pre-flight data done.")