-
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
Double quote escape for bash script #5280
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with the principle of adding a new option that can change the default behavior. Just have a question about the name and the fact that each subclass explicitly has to be updated to respect the new option. I think this requires a change in the setup of Scheduler._get_submit_script_header
.
@@ -244,6 +244,8 @@ def define(cls, spec: CalcJobProcessSpec) -> None: # type: ignore[override] | |||
help='If set to true, the submission script will load the system environment variables',) | |||
spec.input('metadata.options.environment_variables', valid_type=dict, default=lambda: {}, | |||
help='Set a dictionary of custom environment variables for this calculation',) | |||
spec.input('metadata.options.use_double_quotes', valid_type=bool, default=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this only applies to the environment_variables
option, should we name this option more explicitly, like environment_variables_double_quotes
? This makes it a lot clearer that it only affects that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe envvar_double_quotes
instead of environment_variables
to avoid to have a super-long name that users have to type? I'm not 100% sure of this name though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it is not precise to naming it as use_double_quotes
but environment_variables_double_quotes
really too long. My initial consideration is that use_double_quotes
also influent other parts like command line parameters. Do you think it is too much to do this in the calcjob metadata setting with one option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing that is missing is how to use double quotes for the computer and code properties. E.g. the mpirun
command (this is what we need for the hyperqueue plugin). Pinging also @mbercx.
Would a simple, backward-compatible option be to add a _USE_DOUBLE_QUOTES class variable for scheduler plugins? And AiiDA checks if it exists and honours it if present (going back to single quotes if it's not present of if the value is False).
Or even, if we want to give more flexibility, we could have _QUOTE_MODE
variable that accepts a value from an Enum, e.g. SINGLE
(default), DOUBLE
(new option), or even NONE
. @sphuber what do you think?
@@ -244,6 +244,8 @@ def define(cls, spec: CalcJobProcessSpec) -> None: # type: ignore[override] | |||
help='If set to true, the submission script will load the system environment variables',) | |||
spec.input('metadata.options.environment_variables', valid_type=dict, default=lambda: {}, | |||
help='Set a dictionary of custom environment variables for this calculation',) | |||
spec.input('metadata.options.use_double_quotes', valid_type=bool, default=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe envvar_double_quotes
instead of environment_variables
to avoid to have a super-long name that users have to type? I'm not 100% sure of this name though
If the point of this is really to affect quoting in general, then having an option called Anyway, I opened PR #5283 to abstract the environment variable part to solve that, but if we extend the quoting also to other things of the script, such as the |
I implement this in order to affect the quotes style in general, just thought @bosonie feature request is another case that can be addressed by extra parameter of |
It's needed at least for the |
e0b9b13
to
f85cac4
Compare
@sphuber Thanks for the updating! I rebased this pr and make the changes. |
Codecov Report
@@ Coverage Diff @@
## develop #5280 +/- ##
===========================================
+ Coverage 82.13% 82.14% +0.02%
===========================================
Files 533 533
Lines 38485 38515 +30
===========================================
+ Hits 31605 31635 +30
Misses 6880 6880
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @unkcpz . Some changes to the docstrings, but the rest of the implementation is ok. I have to admit that I am still not a fan of envvar_double_quotes
. It may very well be a bit shorter, but I tend to think that shorter is not better if you are sacrificing consistency and clarity. But if others think this is the best option then I won't stop it.
@sphuber Thanks, I make the changes as per your advice. For |
Mmm, I see the point on the naming - I realise that there is also an So I see two options (for the variable indicating whether to escape with double quotes (instead of single quotes) the value of the environment variables:
Maybe someone else who'd be actually using this feature might be interested in chipping in? E.g. @bosonie @mbercx More generally - I see this PR is only about env vars. What about telling to use double quotes e.g. for the command line arguments of a code (will this be a new attribute in the CalcInfo returned by the plugin?), or to the mpirun_command of the computer (will this be an option in the computer setup?). I imagine this is the (partial) focus of #5250 - just asking to make sure we don't want this option defined in this PR also control escaping of other parts of the script (thinking to it, I think this is OK as it is, and the other properties are not specific to CalcJob but to either Code, CalcInfo or Computer). |
I add an extra commit 8d3463d to this PR to enable double-quotes setting for calcjob job script code command. This option is a computer property and can be set by To summary, the main dilemma in adding this double-quotes setting is where this option should be set, if it is set in multiple places below what is the order of override?
|
3c800d6
to
4758dbb
Compare
The way of command execute line in script generating from code_info and code is now shaped to:
|
58493be
to
4adcef8
Compare
3b212fd
to
ba40f5a
Compare
for more information, see https://pre-commit.ci
Close this PR since it is included in the containerized PR and will be separated into different small PRs include #5349 |
I separate the implementation out from the container code PR. Also slightly touch and trying to address the issue of
environment_variables
of calcjob mentioned at #4836.I make a demo change on SGE scheduler and found a bug there (please see the second commit 9d2f639e6). If you think this is the right direction for #4836. I will continue on implement this for other schedulers.
pinning @bosonie for comment since you open the issue mentioned @giovannipizzi to double-check this is the right way to do the escape. Also @mbercx since maybe you need more magic about escape in you hyperqueue plugin?