morinlab / GAMBLR

Set of standardized functions to operate with genomic data
https://morinlab.github.io/GAMBLR/
MIT License
3 stars 2 forks source link

Return a useful error when config is missing #153

Closed Kdreval closed 1 year ago

Kdreval commented 1 year ago

Currently we would get some cryptic errors similar to:

Joining, by = "sample_id"
Error in file(con, "rb") : cannot open the connection
In addition: Warning messages:
1: In file(con, "rb") :
  'raw = FALSE' but '/projects/rmorin/projects/gambl-repos/gambl-kdreval' is not a regular file
2: In file(con, "rb") :
  cannot open file '/projects/rmorin/projects/gambl-repos/gambl-kdreval': it is a directory

or

Error in file(con, "rb") : cannot open the connection
In addition: Warning messages:
1: In file(con, "rb") :
  'raw = FALSE' but '/projects/nhl_meta_analysis_scratch/gambl/results_local' is not a regular file
2: In file(con, "rb") :
  cannot open file '/projects/nhl_meta_analysis_scratch/gambl/results_local': it is a directory

and I think it is related to missing config when setwd is not set or not set properly. It will be helpful if this is checked globally and returns a useful error when config is missing.

mattssca commented 1 year ago

I was not able to reproduce this error, based on the suggested cause for these cryptic errors. The error message that gets returned when setting the working directory outside of the package repo where the config lives, seems to give a reasonable error message:

setwd("../../")
get_gambl_metadata()
Error in config::get("repo_base") : 
  Config file config.yml not found in current working directory or parent directories 

The error up top does look familiar, but I am not sure what to do with this until we can pinpoint the origin of this error. Do you have a fully reproducible example of how this error gets returned?

lkhilton commented 1 year ago

I just ran into this error and the issue was an outdated config that was missing the newer template values. I think it's not missing config, but that functions that look for template values don't throw an error message when the expected template is missing, which means that they try to glue wildcards into the repo_base instead of the full assembled template file path.

I think we need some kind of check to ensure that the template value is not NULL to handle this.

mattssca commented 1 year ago

indeed, it's on the way. Please see this post if you have not yet @lkhilton