-
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
Scheduler
: abstract generation of submit script env variables
#5283
Scheduler
: abstract generation of submit script env variables
#5283
Conversation
9b11c69
to
f2963d9
Compare
In terms of backwards compatibility; I think the worst that can happen is that plugins out there that currently also generate the environment variables themselves in their |
Just two comments:
|
Well prepare to fight 🤼♂️ ;) Actually, I was aiming to replicate the current behavior. There are tests for the direct scheduler that compare the literal output of a generated script. When running tests locally, with the empty lines, the test fail. But now it fails remotely. I will look into it.
They won't end up writing the entire header twice. It will just include the environment variables declaration twice if they also copy pasted this from the |
The environment variables defined in the `JobTemplate` need to be written to the submit script header. The `Scheduler.get_submit_script` relied on the `__get_submit_script_header` abstract method to do this. This forces each plugin to write this code, even though this is very likely to be scheduler independent. Therefore it is best to abstract this functionality to the base class such that each scheduler plugin automatically has this implemented. If really needed, the plugin can still override the behavior by explicitly reimplementing the `_get_submit_script_environment_variables` method. Note that it looks that `_get_submit_script_environment_variables` could be a `staticmethod`, but unfortunately it is not possible to call the super when overriding the staticmethod in a subclass.
f2963d9
to
6d9199e
Compare
Codecov Report
@@ Coverage Diff @@
## develop #5283 +/- ##
===========================================
+ Coverage 81.46% 81.51% +0.05%
===========================================
Files 530 530
Lines 37139 37103 -36
===========================================
- Hits 30253 30241 -12
+ Misses 6886 6862 -24
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
@giovannipizzi the empty lines are fixed now. |
Yes, sure. Still it might be a problem if the environment variables depend on each other and are not idempotent? E.g. something like export VARIABLE=${VARIABLE}+xxx Running this twice is a problem.
As I said, we leave (as now) the responsibility to the plugin to write those lines calling the method that you now implemented in the super class. (i.e. for each plugin where you removed the code, you just add a 1-line call to the method In any case, the number of scheduler plugins is small, so maybe we can add to #5284 to create PRs or issues to fix all the scheduler plugins we are aware of (in the aiida registry), as well as add this information to the wiki page for 2.0. |
I.e.: if you still feel that the second approach is better, I'm OK to approve this and I'd kindly ask you to update both #5284 and the wiki. |
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.
Pre-approving for simplicity, but please dismiss this if instead you prefer to go with my other suggestion (each plugin should manually call the part to write the env vars).
bcf768b
to
ccb2850
Compare
Have `_get_submit_script_environment_variables` include the starting and end markers, and do not call it in `Scheduler.get_submit_script`, but instead let the subclasses call it in `_get_submit_script_header` themselves. This prevents existing external plugins printing the environment variables twice, and still the logic is provided in a single place. This still require external plugins to update to use the new method to print the environment variables for it to pick up the changes if `aiida-core` decides to improve the implementation.
ccb2850
to
5af8dce
Compare
I followed your suggestion @giovannipizzi and made the plugins call the new abstracted method. I agree that this is safer as it won't break existing functionality and we can suggest existing plugins to adopt the new method. |
The environment variables defined in the
JobTemplate
need to bewritten to the submit script header. The
Scheduler.get_submit_script
relied on the
__get_submit_script_header
abstract method to do this.This forces each plugin to write this code, even though this is very
likely to be scheduler independent.
Therefore it is best to abstract this functionality to the base class
such that each scheduler plugin automatically has this implemented. If
really needed, the plugin can still override the behavior by explicitly
reimplementing the
_get_submit_script_environment_variables
method.Note that it looks that
_get_submit_script_environment_variables
couldbe a
staticmethod
, but unfortunately it is not possible to call thesuper when overriding the staticmethod in a subclass.