pecan icon indicating copy to clipboard operation
pecan copied to clipboard

Eliminate model/ID-specific hacks in create_execute_test_xml (well, and everywhere)

Open infotroph opened this issue 11 months ago • 1 comments

@mdietze in https://github.com/PecanProject/pecan/pull/3407#discussion_r1905592352 :

Not sure what the aim or this overall function is, or where it's called from, but this sort of deeply-buried hard-coded hack is something we should really avoid. I know you didn't add this and are just reformatting it, but I wonder if we could take the opportunity to fix it? First, this bit won't work if we're moving away from BETY being required (and never would have worked on a machine lacking this input ID). Second, as we move towards more people passing in ensemble soil inputs, this is going to break things (especially if a soil input is already present, which the code never checks for)

The code in question, from PEcAn.workflow::create_execute_test_xml:

model_specific_tags <- function(settings, model.info) {
  # some extra settings for LPJ-GUESS
  if (model.info$model_name == "LPJ-GUESS") {
    settings$run$inputs <- c(
      settings$run$inputs,
      list(soil = list(id = 1000000903))

infotroph avatar Jan 07 '25 19:01 infotroph

Maybe retrieve a dynamic value from the database? But wouldn;t that make the model MORE DB Dependent which is the opposite of what we want. Another approach would be examining a constant value within the xml structure being built from settings. Then maybe we can use any param as substitute to the ID or use it to construct a UID? Do you happen to know any xml we can take as reference for the LPJ-GUESS model params here?

Sweetdevil144 avatar Jan 18 '25 20:01 Sweetdevil144