-
Notifications
You must be signed in to change notification settings - Fork 18
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
Replace check of empty string in unfilled template widgets to None
#650
Conversation
bb6fe75
to
6b38f0e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #650 +/- ##
==========================================
- Coverage 83.46% 83.45% -0.01%
==========================================
Files 17 17
Lines 3568 3566 -2
==========================================
- Hits 2978 2976 -2
Misses 590 590
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
6b38f0e
to
6544d18
Compare
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.
LGTM but I am not familiar with the template code at all so this better be reviewed by somebody that does :-)
Also thanks for following up on this @edan-bainglass! 🤟 |
100% why I tagged @unkcpz 😅 |
@unkcpz can you have a look at this? |
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 @edan-bainglass, I think it is a correct change, None
was what I didn't considered when initialize the widget value. This will for sure directly solve #648
Not sure it is easy to understand logic of testing, but when I created this widget, I tried to catch most of conditions with tests in
aiidalab-widgets-base/tests/test_computational_resources.py
Lines 318 to 372 in 7a93035
def test_template_variables_widget(): | |
"""Test template_variables_widget.""" | |
w = computational_resources.TemplateVariablesWidget() | |
w.templates = { | |
"label": "{{ label }}", | |
"hostname": "daint.cscs.ch", | |
"description": "Piz Daint supercomputer at CSCS Lugano, Switzerland, multicore partition.", | |
"transport": "core.ssh", | |
"scheduler": "core.slurm", | |
"work_dir": "/scratch/snx3000/{username}/aiida_run/", | |
"shebang": "#!/bin/bash", | |
"mpirun_command": "srun -n {tot_num_mpiprocs}", | |
"mpiprocs_per_machine": 36, | |
"prepend_text": "#SBATCH --partition={{ slurm_partition }}\n#SBATCH --account={{ slurm_account }}\n#SBATCH --constraint=mc\n#SBATCH --cpus-per-task=1\n\nexport OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK\nsource $MODULESHOME/init/bash\nulimit -s unlimited", | |
"metadata": { | |
"slurm_partition": { | |
"type": "text", | |
"key_display": "Slurm partition", | |
}, | |
}, | |
} | |
# Fill the template variables | |
for key, value in w._template_variables.items(): | |
if key == "label": | |
sub_widget = value.widget | |
sub_widget.value = "daint-mc-test" | |
# check the filled value is updated in the filled template | |
assert w.filled_templates["label"] == "daint-mc-test" | |
# Fill two template variables in one template line | |
for key, value in w._template_variables.items(): | |
if key == "slurm_partition": | |
sub_widget = value.widget | |
sub_widget.value = "normal-test" | |
elif key == "slurm_account": | |
sub_widget = value.widget | |
sub_widget.value = "newuser" | |
# check the filled value is updated in the filled template | |
assert ( | |
w.filled_templates["prepend_text"] | |
== "#SBATCH --partition=normal-test\n#SBATCH --account=newuser\n#SBATCH --constraint=mc\n#SBATCH --cpus-per-task=1\n\nexport OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK\nsource $MODULESHOME/init/bash\nulimit -s unlimited" | |
) | |
# Test the filled template is updated when the filled value is updated. | |
for key, value in w._template_variables.items(): | |
if key == "slurm_partition": | |
sub_widget = value.widget | |
sub_widget.value = "debug" | |
assert "debug" in w.filled_templates["prepend_text"] |
None
situation? I guess you can add #648 example as test and use the change of this PR to test it.
20e69aa
to
90e4ba5
Compare
This PR corrects a guard for unfilled template variables which checks if the value of the corresponding widget is an empty string. Empty widgets may also be represented by
None
, especially dropdown selectors. This PR addsNone
to the check by comparing the widget's value to both - replaces== ""
within ("", None)
.Resolves #648
Resolves #651
@superstar54 @danielhollas have a look 🙏
@unkcpz tagging you due to git blame (suggests you implemented these sections)