From b1a91d767e890e078af341a6d5383de993aa0493 Mon Sep 17 00:00:00 2001 From: bergalli Date: Fri, 22 Mar 2024 19:09:26 +0000 Subject: [PATCH] wip --- app/logic/cloud_logic.R | 3 +-- app/main.R | 17 ++--------------- scripts/trisk_knative/Dockerfile | 4 ++-- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/app/logic/cloud_logic.R b/app/logic/cloud_logic.R index fa2862e..abba3c3 100644 --- a/app/logic/cloud_logic.R +++ b/app/logic/cloud_logic.R @@ -74,10 +74,9 @@ get_data_from_postgres <- function( } -get_possible_trisk_combinations_from_api <- function(){ +get_possible_trisk_combinations_from_api <- function(trisk_api_service){ # Define the URL # by defaylt trisk_api_service should be equalt to "trisk-api-service" - trisk_api_service <- Sys.getenv("TRISK_API_SERVICE") url <- paste0("http://", trisk_api_service, ":80/get_possible_trisk_combinations") # Make the POST request with a 6-minute timeout response <- httr::GET(url, httr::timeout(360)) diff --git a/app/main.R b/app/main.R index 715c84d..c74b276 100644 --- a/app/main.R +++ b/app/main.R @@ -16,6 +16,7 @@ box::use( app / view / crispy_loans, # logic app / logic / constant[ + TRISK_API_SERVICE, trisk_input_path, s3_folder_path, backend_trisk_run_folder, @@ -197,23 +198,9 @@ server <- function(id) { shiny::observeEvent(c(authorized_access_r()), ignoreInit = TRUE, { if (Sys.getenv("CRISPY_APP_ENV") == "dev") { - # Download data if not already available - if (!dir.exists(trisk_input_path)) { - download_files_from_s3( - local_folder_path = trisk_input_path, - s3_url = Sys.getenv("S3_URL_CRISPY"), - s3_folder_path = Sys.getenv("ST_FOLDER_CRISPY"), - s3_access_key = Sys.getenv("S3_ACCESS_KEY"), - s3_secret_key = Sys.getenv("S3_SECRET_KEY"), - s3_bucket = Sys.getenv("S3_BUCKET_CRISPY"), - s3_region = Sys.getenv("S3_REGION_CRISPY") - ) - } else { - message(sprintf("Folder '%s' already exists at '%s'. No download needed.", s3_folder_path, trisk_input_path)) - } possible_trisk_combinations <- r2dii.climate.stress.test::get_scenario_geography_x_ald_sector(trisk_input_path) } else if (Sys.getenv("CRISPY_APP_ENV") == "prod") { - possible_trisk_combinations <- get_possible_trisk_combinations_from_api() + possible_trisk_combinations <- get_possible_trisk_combinations_from_api(trisk_api_service=TRISK_API_SERVICE) } else { stop("must set environment variable CRISPY_APP_ENV to 'dev' or 'prod'") } diff --git a/scripts/trisk_knative/Dockerfile b/scripts/trisk_knative/Dockerfile index 7c05a18..ed86d6a 100644 --- a/scripts/trisk_knative/Dockerfile +++ b/scripts/trisk_knative/Dockerfile @@ -5,9 +5,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libcurl4-gnutls-dev \ libpq-dev \ zlib1g-dev \ - libsodium-dev + libsodium-dev \ # libssl-dev \ -# libxml2-dev \ + libxml2-dev # liblzma-dev \ # libbz2-dev \ # libpcre2-dev \