-
Notifications
You must be signed in to change notification settings - Fork 192
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
Consider using double quotes for the values in the metadata.options.environment_variables
dict
#4836
Comments
Hey @bosonie , sorry for the late reply! I see what you mean; however, I wonder if this might be an intentional decision to avoid (or discourage) environment contamination. For example, I know that we require absolute paths for code setup in order to not rely on the current environment. Thus perhaps the idea is that the I'll ask @sphuber and @giovannipizzi for clarification on this. |
All arguments in all commands in the submission scripts are always single quoted by AiiDA because otherwise they can be misinterpreted. For example, when a path contains spaces, if it is not quoted, it will be interpreted as multiple arguments instead of one. As far as I am aware, this is the main reason for the quoting and not for some security reasons, but this concept has been there from very early versions of AiiDA, so @giovannipizzi should now for sure. |
Ok, so in principle we could add an option to calcjobs to enable the use double commas instead of single commas? |
Let's say there are two reasons.
In practice, there might be reasons to use env vars from other env vars, anyway. There is at least another issue asking for the same. However, since adding this option might have unexpected results, the question for @bosonie is: is this an issue preventing you to run your simulations properly, or you can work around it? In any case, having an option that says "set env variables in double quotes rather than single quotes" would be ok with me, as long as it's optional and the default behaviour does not change. |
I would also vote to support this behavior if it addresses a concrete use case. |
The escape method will escape the string in the quotes. The defalut implementation is using single quotes to escape the string. However, single quotes will not eval the spacial shell parameters such as $ and @, this makes bash script not versatile to set the parameters in runtime. The `use_double_quotes` option is added to escape the string in the double quotes so the spacial parameters are still valid in the shell script. Using double escape option into environment variables of job templete setting address aiidateam#4836. User can now use double quotes escaping in calcjob option to escape the environment variables of scheduler.
If one specifies something like:
"environment_variables":{"MY_FILE":"$HOME/path/my_file"},
in the
metadata.options
, the submission script would include:This call is ineffective since the
$
would be considered a normal character.The desired behavior would be to return double quotes:
since within double quotes the special character
$
is recognized.For reference, here an extract of the bash manual:
The solution requires some improvements in the method
escape_for_bash
.aiida-core/aiida/common/escaping.py
Line 15 in 75310e0
The text was updated successfully, but these errors were encountered: