Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bergalli committed Mar 22, 2024
1 parent dff50d5 commit b1a91d7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
3 changes: 1 addition & 2 deletions app/logic/cloud_logic.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
17 changes: 2 additions & 15 deletions app/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'")
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/trisk_knative/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit b1a91d7

Please sign in to comment.