-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvement on loading and expanding YAML setting variables. #3891
Conversation
- Added `_expand_strings` to handle environment and user variables in YAML. - Introduced `_load_yaml_file` for loading YAML files with variable expansion. - Updated `_load_pmg_settings` to use `_load_yaml_file`.
…iables, and tilde (~) expansion
Maybe I am a bit unclear of the use case for this. What problem is this trying to solve? |
@shyuep For adding VASP setting for the dftd4 vdW functional, see here: |
I understand the proposed improvement. I am just not clear on the benefits over the current settings YAML loading. As far as I know, no one has ever had any issue with the current settings file with regards to things like path expansion etc. |
For example, in my case, the following configuration doesn't work without my PR due to the
|
When you create the yaml file using the pmg config command, all paths are absolute. Anyway, I don't have a problem with adding path expansion. But this is a lot of additional code for a simple variable expansion. |
I agree with you: the path should be checked and correctly expanded with the absolute path when running the |
@shyuep @janosh Anyway, I just canceled this PR on my local machine and kept it in my GitHub repo and here, so that everyone can discuss and deliberate on how to handle it. The sub-commit in this PR for |
i think this PR is worth having. |
However, this also brings up the following issue: when using In any case, supporting as many possible forms as possible, including both the actual variable values and their unexpanded forms, should be the most flexible solution. |
In general, config files are supposed to be machine specific. It is reasonable to assume that a person would take the one time effort to set up .pmgrc.yaml for each cluster. Also, most people keep the same user name across different clusters, in which case even the absolute paths would be the same. |
not the case e.g. for Lambda, GCP and AWS. they have different root directories preceding the user name for $HOME and $SCRATCH. would be nice if you could just carbon copy the |
I reiterate my final point: In any case, supporting as many possible forms as possible, including the actual variable values and their unexpanded forms, should be the most flexible solution. |
I am fine with adding path expansion. But the solution implemented is just too complicated. There are very minimal settings in the pmgrc file. We do not need a recursive function to handle lists, dicts, etc. I am a believer in implementing the simplest solution possible for practical problems. Personally, I am not convinced that being able to scp setting files over from machine to machine is a must-have. Like I said - it is a one time setup per machine, not something you do on a daily basis. But I will live with supporting path and user expansion for that esoteric purpose. However, that's all the support I am willing to add the the settings file. nested lists and dicts should not exist in the settings at the present moment. Until the day that that particular scenario actually manifests itself, we do not write code for hypothetical things. |
_expand_strings
to handle environment and user variables in YAML._load_yaml_file
for loading YAML files with variable expansion._load_pmg_settings
to use_load_yaml_file
.