Cluster_job_id incorrect parsing

Hi,

We recently changed our LSF queue name from “cryoem” to “rhel8_cryoem”. I don’t think we will change the name to work around this issue. The issue seems to occur when there are multiple numeric strings in the output from the job submission statement, such as what follows:

Job <205677873> is submitted to queue <rhel8_cryoem>.

I looked at the issue below and was able to find that the affected lines are in the file cryosparc_master/cryosparc_command/command_core/init.py

Here are the affected lines in that file:

cluster_job_matches = re.findall('\d+', res)
                if len(cluster_job_matches) == 1:
                    cluster_job_id = cluster_job_matches[0]  # take the only numeric substring
                else:
                    cluster_job_id = res.strip().split()[-1]  # take the last token

The issue seems to be that the numeric substring is chosen only when there is no more than one occurrence. I ran the following to confirm:

import re
res="Job <205677873> is submitted to queue <rhel8_cryoem>."
cluster_job_matches = re.findall('\d+', res)

if len(cluster_job_matches) == 1:
    cluster_job_id = cluster_job_matches[0]  # take the only numeric substring
else:
    cluster_job_id = res.strip().split()[-1]  # take the last token

print(cluster_job_id)
<rhel8_cryoem>.
print(len(cluster_job_matches))
2
print(re.findall('\d+',res))
['205677873', '8']

I guess a simple fix but probably one that is not a catch-all is to change the ‘== 1’ to ‘>= 1’ in the block of code but I have numerous instances running and would prefer not to have to manually change code and instead wait for a fix. Please let me know your thoughts.

@shockacone Thank you for reporting your observation. May I suggest the following approach:

  1. Create an executable shell script bsub_wrapper.sh that wraps the command currently specified for your cluster targets qsub_cmd_tpl. When executed, the shell script shall
    1. submit its first argument ($1) as a cluster job script.
    2. print exactly the relevant number to stdout. The GNU grep --only-matching option may be helpful here.
  2. Update the relevant CryoSPARC cluster lane such that
    "qsub_cmd_tpl": "/path/to/bsub_wrapper.sh {{ script_path_abs }}",
    

@wtempel Thanks for your suggestion. I was already using a wrapper script so for me all it took was editing that script. Here’s the wrapper that worked for me:

#!/bin/bash

bsub_response=$(bsub < $1)

echo $bsub_response | grep --only-matching -E '<[0-9]+>' | sed "s/<\|>//g"

Thanks again! I’m guessing there won’t be changes made on your end but maybe some additional documentation around setting up clusters focused on wrappers would be helpful.

1 Like