Each config file can (in theory - limited to the data config and core at present) contain file paths, which could be relative. If so, those are assumed to be relative, to the referring config file. The problem is that the referring file path is lost when the configs are merged.
@alexdewar has tackled this for existing cases in #269, but it leaves a hanging issue which might affect later configs that contain paths. An example might be a path to a plant PFT file or something similar.
One way this could be tackled is to introduce an isPath = true property on appropriate JSONSchema entries. That way, the code can unambiguously identify paths that need to be made absolute using an existing canonical source of validation information.
However, I think that then requires two passes and a new Validator:
- Merge the original config content to identify the modules and hence build the schema.
- Run a PathResolverValidator using that schema over the individual files in
self.toml_contents: this validates contents but also look for entries with isPath=true and updates the value with the absolute paths of the toml_contents keys. It doesn't add defaults though, because has to happen on the last validation pass to avoid creating clashes.
- Now merge the updated
toml_contents again and then run this through the current default filling validation.
This is a lot more complex but is also explicit about which inputs are paths.
Originally posted by @davidorme in #269 (review)
Each config file can (in theory - limited to the
dataconfig andcoreat present) contain file paths, which could be relative. If so, those are assumed to be relative, to the referring config file. The problem is that the referring file path is lost when the configs are merged.@alexdewar has tackled this for existing cases in #269, but it leaves a hanging issue which might affect later configs that contain paths. An example might be a path to a plant PFT file or something similar.
One way this could be tackled is to introduce an
isPath = trueproperty on appropriate JSONSchema entries. That way, the code can unambiguously identify paths that need to be made absolute using an existing canonical source of validation information.However, I think that then requires two passes and a new Validator:
self.toml_contents: this validates contents but also look for entries withisPath=trueand updates the value with the absolute paths of thetoml_contentskeys. It doesn't add defaults though, because has to happen on the last validation pass to avoid creating clashes.toml_contentsagain and then run this through the current default filling validation.This is a lot more complex but is also explicit about which inputs are paths.
Originally posted by @davidorme in #269 (review)