Skip to content

Commit

Permalink
change paths for dockerized app
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Jan 31, 2025
1 parent 6352498 commit bdbdb1a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
10 changes: 6 additions & 4 deletions assets/core/data_access_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,8 @@ loadLocalDataset <- function(filename){
#loadLocalCountryDatasets
#@deprecated
loadLocalCountryDatasets <- function(config){
country_dir <- sprintf("./data/country/%s", config$country_profile$iso3)
local_dir <- if(config$local) "../calipseo-data" else "data"
country_dir <- sprintf("%s/country/%s", local_dir, config$country_profile$iso3)
if(dir.exists(country_dir)){
files <- list.files(path = country_dir, full.names = TRUE)
for(file in files){
Expand All @@ -1028,8 +1029,8 @@ loadLocalCountryDatasets <- function(config){

#getLocalCountryDataset
getLocalCountryDataset <- function(config,filename){
#get(name, envir = CALIPSEO_SHINY_ENV)
country_dir <- sprintf("../calipseo-data/country/%s", config$country_profile$iso3)
local_dir <- if(config$local) "../calipseo-data" else "data"
country_dir <- sprintf("%s/country/%s", local_dir, config$country_profile$iso3)
filename <- file.path(country_dir, filename)
data <- switch(mime::guess_type(filename),
"application/json" = jsonlite::read_json(filename),
Expand All @@ -1042,7 +1043,8 @@ getLocalCountryDataset <- function(config,filename){
#@deprecated
getLocalCountryDatasets <- function(config){
out <- list()
country_dir <- sprintf("../calipseo-data/country/%s", config$country_profile$iso3)
local_dir <- if(config$local) "../calipseo-data" else "data"
country_dir <- sprintf("%s/country/%s", local_dir, config$country_profile$iso3)
if(dir.exists(country_dir)){
files <- list.files(path = country_dir, full.names = TRUE)
out <- lapply(files, function(file){
Expand Down
13 changes: 8 additions & 5 deletions global.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,29 @@ require(artfishr)
#config
#---------------------------------------------------------------------------------------
#default config_file path for DEPLOYMENT
config_file <- "/etc/shiny-server/config.yml"
config_file <- "/etc/calipseo-shiny/config.yml"

#local configuration
#If you are an R developer, you need to create a .REnviron file (no file extension) in /shiny-calipseo dir
#The file should include the local path for your shiny config file in that way:
#CALIPSEO_SHINY_CONFIG=<your config path>

local <- FALSE
local_config_file <- Sys.getenv("CALIPSEO_SHINY_CONFIG")
if(nzchar(local_config_file)) config_file <- local_config_file
if(nzchar(local_config_file)){
config_file <- local_config_file
local <- TRUE
}
appConfig <- suppressWarnings(yaml::read_yaml(config_file))
appConfig$local <- local

if(is.null(appConfig$auth)) appConfig$auth <- FALSE

#language (in case not part of configuration)
if(is.null(appConfig$language)) appConfig$language <- "en"

#shiny-storage check
default_store_dir <- "/srv/shiny-server/shiny-calipseo-store"
default_store_dir <- "/srv/calipseo-shiny-store"
#shiny-storage in dev (assume Windows OS for now)
if(Sys.info()[["sysname"]] == "Windows") default_store_dir <- "out"
if(is.null(appConfig$store)) appConfig$store <- default_store_dir
Expand Down Expand Up @@ -106,8 +111,6 @@ CALIPSEO_SHINY_ENV <- new.env()
core_assets <- list.files("assets/core", pattern = ".R", full.names = T)
for(core_asset in core_assets) source(core_asset)

#addResourcePath(prefix = "calipseo-data", directoryPath = "../calipseo-data")

#country R script utils
country_assets <- list.files(path = file.path("./assets/country", appConfig$country_profile$iso3),
pattern = ".R", recursive = TRUE, full.names = TRUE)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "shiny-calipseo",
"version": "2.0.0",
"date": "2025-01-30",
"version": "2.0.0-sp3",
"date": "2025-01-31",
"dependencies": [
{"package": "dotenv", "version": "1.0.3", "repos": "https://cran.r-project.org"},
{"package": "htmltools", "version": "0.5.2", "repos": "https://cloud.r-project.org"},
Expand Down

0 comments on commit bdbdb1a

Please sign in to comment.