Improve error message when cores or memory is not specified#331
Conversation
|
Thanks a lot for the PR! This definitely goes in the right direction. Could you add a test in @pytest.mark.parametrize(
"Cluster",
[PBSCluster, MoabCluster, SLURMCluster, SGECluster, LSFCluster, OARCluster],
)
def test_cluster_has_cores_and_memory(Cluster):
with pytest.raises(ValueError, match='cores=.+memory='):
with Cluster():
pass
with pytest.raises(ValueError, match='cores='):
with Cluster(memory='1GB'):
pass
with pytest.raises(ValueError, match='memory='):
with Cluster(cores=4):
pass |
|
FYI: you need to use "Fix #issueNumber" in your PR description (and not in the PR title), this way the associated issue gets closed automatically when the PR is merged. For more details, look at this. I edited your PR description for you. |
@lesteve I have added this test, please check if it is fine. |
lesteve
left a comment
There was a problem hiding this comment.
Thanks for the test, here are a few comments!
| "You must specify how many cores to use per job like ``cores=8``" | ||
| + "as well as how much memory to use per job like ``memory='24 GB'``" | ||
| ) | ||
| with pytest.raises(ValueError, match=error_message_string): |
There was a problem hiding this comment.
I would suggest using regexp as I hinted in my previous message. You don't want to check the exact full message but only parts of it. In case someone does a minor wording change of the error message, you'd like the test to still pass (in an ideal world).
| shebang = dask.config.get("jobqueue.%s.shebang" % config_name) | ||
|
|
||
| if cores is None: | ||
| if (cores is None) and (memory is None): |
There was a problem hiding this comment.
You don't need the parentheses: if cores is None and memory is None. It may look weird if you are used to language like C but when are used to Python removing parentheses feels less noisy.
| if cores is None: | ||
| if (cores is None) and (memory is None): | ||
| raise ValueError( | ||
| "You must specify how many cores to use per job like ``cores=8``" |
There was a problem hiding this comment.
I would tweak the error messages slightly, e.g. something like (not tested):
"You must specify how much cores and memory per job you want to use, for example:\n"
"cluster = {}(cores={}, memory='{!r}'".format(self.__class__, cores or 8, memory or '24GB')I would also use the same error message in all cases for simplicity reasons
|
Thank you, @lesteve. I have implemented changes according to your suggestions, please check. |
|
Almost there: the error message is not quite what we want: We want to recommend people to use this instead: |
|
Thank you, @lesteve. I have made that change. |
|
I pushed some tweaks but for some reason the CI has not been triggered, not sure why ... |
|
@rblcoder you should be able to trigger the CI again by pushing an empty commit. |
|
If the CI is green, I think this is fine to merge this one! |
…ask-jobqueue into error_message_cores_or_memory
|
I am going to merge this one since it looks like the CI eventually ran on my commit, thanks a lot! |
|
Thank you for your support @lesteve ! |
Hi,
Please let me know if the changes are fine.
Fix #329.