Skip to content

Commit

Permalink
Audit only entrypoint (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAxthelm authored Dec 19, 2024
1 parent 7f1a47d commit c923fb6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 29 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: workflow.pacta
Title: Run PACTA
Version: 0.0.0.9013
Version: 0.0.0.9014
Authors@R:
c(person(given = "CJ",
family = "Yetman",
Expand Down
79 changes: 51 additions & 28 deletions R/run_pacta.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@
#' \item timeHorizon: Time horizon for analysis.
#' }
#' }
#' @param run_audit logical: Run the audit process
#' @param run_analysis logical: Run the analysis process
#' @param pacta_data_dir filepath: Directory with "pacta-data"
#' @param output_dir filepath: Directory to save outputs.
#' @param portfolio_dir filepath: Directory with portfolio files
#' @return No return value. Saves outputs to output_dir.
#' @export
run_pacta <- function(
params,
run_audit = TRUE,
run_analysis = TRUE,
pacta_data_dir = Sys.getenv("PACTA_DATA_DIR"),
output_dir = Sys.getenv("ANALYSIS_OUTPUT_DIR"),
portfolio_dir = Sys.getenv("PORTFOLIO_DIR")
Expand All @@ -44,35 +48,54 @@ run_pacta <- function(
}
log_info("Running PACTA")

audit_prechecks(
portfolio_files = params[["portfolio"]][["files"]],
pacta_data_dir = pacta_data_dir,
portfolio_dir = portfolio_dir,
output_dir = output_dir
)
analysis_prechecks(
pacta_data_dir = pacta_data_dir,
output_dir = output_dir,
check_portfolio = FALSE
)
audit_file_path <- file.path(output_dir, "audit_file.rds")

run_audit(
portfolio_files = params[["portfolio"]][["files"]],
pacta_data_dir = pacta_data_dir,
portfolio_dir = portfolio_dir,
output_dir = output_dir
)
run_analysis(
pacta_data_dir = pacta_data_dir,
output_dir = output_dir,
equity_market_list = params[["analysis"]][["equityMarketList"]],
scenario_sources_list = params[["analysis"]][["scenarioSourcesList"]],
scenario_geographies_list =
params[["analysis"]][["scenarioGeographiesList"]],
sector_list = params[["analysis"]][["sectorList"]],
start_year = params[["analysis"]][["startYear"]],
time_horizon = params[["analysis"]][["timeHorizon"]]
)
if (!file.exists(audit_file_path)) {
log_warn("Audit file not found. Running audit.")
run_audit <- TRUE
}

if (run_audit) {
audit_prechecks(
portfolio_files = params[["portfolio"]][["files"]],
pacta_data_dir = pacta_data_dir,
portfolio_dir = portfolio_dir,
output_dir = output_dir
)
}

if (run_analysis) {
analysis_prechecks(
pacta_data_dir = pacta_data_dir,
output_dir = output_dir,
check_portfolio = FALSE
)
}


if (run_audit) {
run_audit(
portfolio_files = params[["portfolio"]][["files"]],
pacta_data_dir = pacta_data_dir,
portfolio_dir = portfolio_dir,
output_dir = output_dir
)
}


if (run_analysis) {
run_analysis(
pacta_data_dir = pacta_data_dir,
output_dir = output_dir,
equity_market_list = params[["analysis"]][["equityMarketList"]],
scenario_sources_list = params[["analysis"]][["scenarioSourcesList"]],
scenario_geographies_list =
params[["analysis"]][["scenarioGeographiesList"]],
sector_list = params[["analysis"]][["sectorList"]],
start_year = params[["analysis"]][["startYear"]],
time_horizon = params[["analysis"]][["timeHorizon"]]
)
}

log_info("PACTA run complete.")
return(
Expand Down
6 changes: 6 additions & 0 deletions man/run_pacta.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c923fb6

Please sign in to comment.