PecanProject / pecan

The Predictive Ecosystem Analyzer (PEcAn) is an integrated ecological bioinformatics toolbox.
www.pecanproject.org
Other
203 stars 235 forks source link

How to deal with server aliases? #284

Closed dlebauer closed 9 years ago

dlebauer commented 9 years ago

I am not sure if this is a special case that we can ignore, or if we want to handle.

Currently, if I use the dbfile.file function on ebi-forecast, it works if I specify either localhost or ebi-forecast.igb.uiuc.edu but not ebi-forecast.igb.illinois.edu:

dbcon <- db.open(settings$database$bety)

print(dbfile.file("Model", 7, dbcon, "localhost"))
[1] "/home/dlebauer/dev/pecan/models/biocro/inst//biocro.Rscript"

print(dbfile.file("Model", 7, dbcon, "ebi-forecast.igb.uiuc.edu"))
[1] "/home/dlebauer/dev/pecan/models/biocro/inst//biocro.Rscript"

print(dbfile.file("Model", 7, dbcon, "ebi-forecast.igb.illinois.edu"))
2014-12-08 16:10:38 WARN   [dbfiles.R#299: logger.warn] : 
   no files found for 7 in database 
[1] NA

It comes down to this line returning NULL if the server is mis-specified

hostid <- db.query(paste0("SELECT id FROM machines WHERE hostname='", hostname, "'"), con)[['id']]

I can either a) write a quick gsub(x, 'illinois', 'uiuc') hack (my preferred approach) or b) stop using the alias (the cleaner approach) or c) find some other, more generic solution (e.g. return all server aliases) ... if this is a problem that others may encounter

Thoughts?

robkooper commented 9 years ago

no hacks is my approach, in this case pick the name that the machine returns using hostname -f.

robkooper commented 9 years ago

This will become more important if you use the scripts as well, the name will be used in the sync routines (see #149) as well.