-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
WIP: Use regex for job-id lookup #131
Changes from 20 commits
f0566c8
9fb1ca0
06a9f02
aab9a6e
d67e68e
c1604c8
b11e2c9
c50fe05
e904f0a
4dcb2e1
2602192
f72a7f1
6fda4c9
3f61dd9
9acf92d
f6240b7
f39f116
4fc5318
dcbe350
9c83c29
5463a1d
23e54fc
d5a9e57
a71c293
cb13919
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,50 @@ def test_forward_ip(): | |
with PBSCluster(walltime='00:02:00', processes=4, cores=8, memory='28GB', | ||
name='dask-worker') as cluster: | ||
assert cluster.local_cluster.scheduler.ip == default_ip | ||
|
||
|
||
@pytest.mark.parametrize('Cluster', [PBSCluster, MoabCluster, SLURMCluster, | ||
SGECluster, LSFCluster]) | ||
@pytest.mark.parametrize( | ||
'qsub_return_string', | ||
['{job_id}.admin01', | ||
'Request {job_id}.asdf was sumbitted to queue: standard.', | ||
'sbatch: Submitted batch job {job_id}', | ||
'{job_id};cluster', | ||
'Job <{job_id}> is submitted to default queue <normal>.', | ||
'{job_id}']) | ||
def test_job_id_from_qsub(Cluster, qsub_return_string): | ||
original_job_id = '654321' | ||
qsub_return_string = qsub_return_string.format(job_id=original_job_id) | ||
with Cluster(walltime='00:02:00', processes=4, cores=8, memory='28GB', | ||
name='dask-worker') as cluster: | ||
assert (original_job_id | ||
== cluster._job_id_from_submit_output(qsub_return_string)) | ||
|
||
|
||
@pytest.mark.parametrize('Cluster', [PBSCluster, MoabCluster, SLURMCluster, | ||
SGECluster, LSFCluster]) | ||
@pytest.mark.parametrize( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. General remark, for the error cases I would remove this parametrize and just test with something like this:
|
||
'qsub_return_string', | ||
['Request {job_id}.asdf was sumbitted to queue: standard.', | ||
'sbatch: Submitted batch job {job_id}', | ||
'{job_id};cluster', | ||
'Job <{job_id}> is submitted to default queue <normal>.', | ||
'{job_id}', | ||
pytest.param('{job_id}.admin01', marks=pytest.mark.xfail)]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot you could do something like this with parametrize, nice! Can you explain why it is xfail though? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case |
||
def test_job_id_error_handling(Cluster, qsub_return_string): | ||
|
||
# test for broken regexp | ||
with Cluster(walltime='00:02:00', processes=4, cores=8, memory='28GB', | ||
name='dask-worker') as cluster: | ||
with pytest.raises(ValueError, match="Could not parse job id"): | ||
cluster.job_id_regexp = r'(?P<job_id>XXXX)' | ||
return_string = qsub_return_string.format(job_id='654321') | ||
cluster._job_id_from_submit_output(return_string) | ||
|
||
# test for missing job_id (Will fail for return string w/ number.) | ||
with Cluster(walltime='00:02:00', processes=4, cores=8, memory='28GB', | ||
name='dask-worker') as cluster: | ||
with pytest.raises(ValueError, match="Could not parse job id"): | ||
return_string = qsub_return_string.format(job_id='XXXXX') | ||
cluster._job_id_from_submit_output(return_string) |
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.
Can you use
job_id = match.groupdict().get('job_id')
to have a better error as I mentioned (probably folded away in an outdated diff).Thinking about this it would be great to have a better error in the case when there is a match but no
job_id
named group, i.e. something like: