Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit only entrypoint #107

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
}
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")

Check warning on line 51 in R/run_pacta.R

View check run for this annotation

Codecov / codecov/patch

R/run_pacta.R#L51

Added line #L51 was not covered by tests

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

Check warning on line 55 in R/run_pacta.R

View check run for this annotation

Codecov / codecov/patch

R/run_pacta.R#L53-L55

Added lines #L53 - L55 were not covered by tests
}

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

Check warning on line 64 in R/run_pacta.R

View check run for this annotation

Codecov / codecov/patch

R/run_pacta.R#L58-L64

Added lines #L58 - L64 were not covered by tests
}

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

Check warning on line 72 in R/run_pacta.R

View check run for this annotation

Codecov / codecov/patch

R/run_pacta.R#L67-L72

Added lines #L67 - L72 were not covered by tests
}


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

Check warning on line 82 in R/run_pacta.R

View check run for this annotation

Codecov / codecov/patch

R/run_pacta.R#L76-L82

Added lines #L76 - L82 were not covered by tests
}


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"]]
)

Check warning on line 97 in R/run_pacta.R

View check run for this annotation

Codecov / codecov/patch

R/run_pacta.R#L86-L97

Added lines #L86 - L97 were not covered by tests
}

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.

Loading