Skip to content

Commit

Permalink
Feature/308 plus 307 improvements (#312)
Browse files Browse the repository at this point in the history
* #307 related improvements

* addresses #308, fixes #307

* fix trivy call (#313)

---------

Co-authored-by: Roland Schmid <[email protected]>
  • Loading branch information
sambles and RolandASc authored Nov 14, 2023
1 parent dc6d3ba commit 3b242b0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
exit-code: '1'
ignore-unfixed: true
severity: ${{ env.SEVERITY }}
security-checks: 'vuln'
scanners: 'vuln'
output: 'app_image.txt'

- name: Store CVE report
Expand Down
7 changes: 6 additions & 1 deletion BFE_RShiny/oasisui/R/exposurevalidation_summary_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,16 @@ exposurevalidationsummary <- function(input,
# note this will remain TRUE as the active tab when switching to step 3!
# We should get the analysis first to check the status and only continue
# if the status is > than NEW, otherwise subsequent queries won't work.
# Subsequent queries will also fail when creating a new analysis, in
# which case the status says "INPUTS_GENERATION_STARTED" at this point.
# There should be a second pass through here then when status changes
# to "READY", so this makes some sense.
anaStatus <- session$userData$oasisapi$api_return_query_res(
query_path = paste("analyses", analysisID(), sep = "/"),
query_method = "GET"
)[["status"]]
if (anaStatus == "NEW") {

if (anaStatus %in% c("NEW", "INPUTS_GENERATION_STARTED")) {
# chill
} else {
result$summary_tbl <- session$userData$data_hub$get_ana_validation_summary_content(analysisID())
Expand Down
18 changes: 15 additions & 3 deletions BFE_RShiny/oasisui/R/output_config_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ panelModelParams <- function(id) {
align = "left",
numericInput(ns("tinputnoofsample"), label = "Number of Samples:", value = 9),
numericInput(ns("tinputthreshold"), label = "Loss Threshold:", value = 0),
checkboxInput(ns("tinputpostlossampli"), label = "Post Loss Amplification", FALSE),
# 239: additional output cfg options (not part of modelsettings!)
textInput(ns("tinputreturnperiods"), label = "Return Periods:", value = "") %>%
bs_embed_tooltip(title = defineSingleAna_tooltips$tinputreturnperiods, placement = "right"),
Expand Down Expand Up @@ -912,10 +913,19 @@ def_out_config <- function(input,
# --> see "abuttonchoosetag")
# - copy settings from setting templates (new functionality as of July 2022)
if (is.null(ana_settings)) {
tbl_ana_settings <- session$userData$oasisapi$api_return_query_res(
query_path = paste("analyses", analysisID(), "settings", sep = "/"),
# check existence before calling on a freshly created analysis that lacks the settings and will result in a 404
check_settings_exist <- session$userData$oasisapi$api_return_query_res(
query_path = paste("analyses", analysisID(), sep = "/"),
query_method = "GET"
)
)[["settings"]]
if (is.null(check_settings_exist)) {
tbl_ana_settings <- NULL
} else {
tbl_ana_settings <- session$userData$oasisapi$api_return_query_res(
query_path = paste("analyses", analysisID(), "settings", sep = "/"),
query_method = "GET"
)
}
} else {
tbl_ana_settings <- ana_settings
}
Expand Down Expand Up @@ -964,6 +974,7 @@ def_out_config <- function(input,
else x
}
updateNumericInput(session, "tinputthreshold", value = tbl_ana_settings$gul_threshold)
updateCheckboxInput(session, "tinputpostlossampli", value = tbl_ana_settings$pla)
updateTextInput(session, "tinputreturnperiods", value = .null_to_empty(tbl_ana_settings$return_periods))
updateTextInput(session, "tinputeventids", value = .null_to_empty(tbl_ana_settings$event_ids))
updateTextInput(session, "tinputquantiles", value = .null_to_empty(tbl_ana_settings$quantiles))
Expand Down Expand Up @@ -1205,6 +1216,7 @@ def_out_config <- function(input,
"ui_config_tag" = input$sintag,
# potential new tag analysis_id
"gul_threshold" = as.integer(input$tinputthreshold),
"pla" = input$tinputpostlossampli,
# 239: insert additional output cfg options at the desired spot.
# these are explicitly lists because a single element would be converted
# differently to json otherwise
Expand Down
14 changes: 6 additions & 8 deletions BFE_RShiny/oasisui/R/step2_chooseAnalysis_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ step2_chooseAnalysis <- function(input, output, session,
# Create new Analysis --------------------------------------------------------
observeEvent(input$abuttonsubmit, {
if (input$anaName != "") {

post_portfolios_create_analysis <- session$userData$oasisapi$api_body_query(query_path = paste("analyses", sep = "/"),
query_body = list(name = input$anaName,
portfolio = portfolioID(),
Expand All @@ -684,15 +683,13 @@ step2_chooseAnalysis <- function(input, output, session,
result$analysisID <- content(post_portfolios_create_analysis$result)$id
result$analysisNAME <- content(post_portfolios_create_analysis$result)$name

logMessage(paste0("Calling api_post_analyses_generate_inputs with id", result$analysisID))

if (length(model_settings) > 0 && !is.null(model_settings$model_configurable) &&
model_settings$model_configurable && !is.null(sub_modules$buildCustom$fullsettings())) {
hasCustom <- length(model_settings) > 0 && !is.null(model_settings$model_configurable) && model_settings$model_configurable
if (hasCustom && !is.null(sub_modules$buildCustom$fullsettings())) {
post_analysis_settings <- session$userData$oasisapi$api_body_query(
query_path = paste("analyses", result$analysisID, "settings", sep = "/"),
query_body = sub_modules$buildCustom$fullsettings()
)
} else {
} else if (hasCustom && is.null(sub_modules$buildCustom$fullsettings())) {
gul_summaries <- summary_template

ana_settings_step_2 <- list(analysis_settings = c(
Expand All @@ -707,18 +704,19 @@ step2_chooseAnalysis <- function(input, output, session,

post_analysis_settings <- session$userData$oasisapi$api_body_query(
query_path = paste("analyses", result$analysisID, "settings", sep = "/"),
query_body = ana_settings_step_2
query_body = ana_settings_step_2 # should this be ana_settings_step_2[[1]]?
)
}

if (post_portfolios_create_analysis$status == "Success" && post_analysis_settings$status == "Success" && !is.null(model_settings$model_configurable) && model_settings$model_configurable) {
if (hasCustom && post_portfolios_create_analysis$status == "Success" && post_analysis_settings$status == "Success") {
fileids <- as.list(sub_modules$buildCustom$fileids())
patch_analyses <- session$userData$oasisapi$api_body_query(query_path = paste("analyses", result$analysisID, sep = "/"),
query_body = list(complex_model_data_files = fileids),
query_method = "PATCH")
# content(patch_analyses$result)
}

logMessage(paste0("Calling api_post_analyses_generate_inputs with id", result$analysisID))
input_generation <- session$userData$oasisapi$api_post_query(
query_path = paste("analyses", result$analysisID, "generate_inputs", sep = "/")
)
Expand Down

0 comments on commit 3b242b0

Please sign in to comment.