golem icon indicating copy to clipboard operation
golem copied to clipboard

cannot open file 'data-raw/config.yaml': No such file or directory with golem shiny app

Open gabrielburcea opened this issue 3 years ago • 4 comments

hello all,

I am getting some error

cannot open file 'data-raw/config.yaml': No such file or directory

config.yaml is a file with paths, app version , variable renaming etc. which I have placed it into data-raw. I am not sure how to work with these types of files. This is where the repo is: https://github.com/gabrielburcea/gtdepmap/tree/devel_golem

TO NOTE: I did not work yet with modules, thus keep in mind, as I need to understand how complex is, will take it step by step , after I succeed runing the app the way I set it as of now, then I will add the modules.

gabrielburcea avatar Aug 11 '22 19:08 gabrielburcea

Hey,

data-raw is supposed to contain the script to build the internal dataset, so this is not where you'll put your external resources.

In a golem app, if you have an external resource to include, you can add it to inst/

Then,

L inst/
  L this.yaml

can be read with app_sys("this.yaml")

L inst/
  L that / 
    L this.yaml

can be read with app_sys("that/this.yaml")

ColinFay avatar Aug 11 '22 19:08 ColinFay

Hey Colin,

I have added the file to inst. And read it like this:

my_yaml = yaml::yaml.load_file(app_sys("inst/config.yaml"))

But I get an error:

Error: object 'path_to_bem' not found

In app_server path_to_bem isn't recognized although it is within config.yaml

in app_server , line 23, where the path_to_bem appears isn't recognised:

CCLECRISPRAchilles = data.frame(fread(file=file.path(path_to_bem,ccle_crispr_file_reldir), sep=","), row.names=1, check.names=F)

gabrielburcea avatar Aug 11 '22 21:08 gabrielburcea

I have added the features of my own config.yaml to golem-config.yaml . Yet, I get warnings and errors when testing the package through build function:

Warning (test-golem-recommended.R:43:5): golem-config works
incomplete final line found on '/home/kkwf800/gtdepmap/inst/golem-config.yml'
Backtrace:
 1. testthat::expect_false(...)
      at test-golem-recommended.R:43:4
 4. gtdepmap::get_golem_config("app_prod", config = "dev", file = config_file)
 5. config::get(value = value, config = config, file = file, use_parent = use_parent)
      at gtdepmap/R/app_config.R:38:2
 6. yaml::yaml.load_file(file, eval.expr = FALSE, handlers = list(expr = function(x) parse(text = x)))
 9. base::readLines(con, warn = readLines.warn)

Warning (test-golem-recommended.R:55:1): (code run outside of test_that()) cannot open file 'inst/golem-config.yaml': No such file or directory Backtrace:

  1. shiny::testServer(...) at test-golem-recommended.R:55:0
  2. gtdepmap server(input = session$input, output = session$output, session = session)
  3. yaml::yaml.load_file("inst/golem-config.yaml") at gtdepmap/R/app_server.R:31:2
  4. base::readLines(con, warn = readLines.warn)

Error (test-golem-recommended.R:55:1): (code run outside of test_that()) Error: cannot open the connection Backtrace:

  1. shiny::testServer(...) at test-golem-recommended.R:55:0
  2. gtdepmap server(input = session$input, output = session$output, session = session)
  3. yaml::yaml.load_file("inst/golem-config.yaml") at gtdepmap/R/app_server.R:31:2
  4. base::readLines(con, warn = readLines.warn)

gabrielburcea avatar Aug 12 '22 10:08 gabrielburcea

I am reading here https://engineering-shiny.org/golem.html but I cannot see anything about where I can set my paths to the data directory that is external to the app package I am building.

gabrielburcea avatar Aug 12 '22 12:08 gabrielburcea