Skip to content

Commit

Permalink
SgeScheduler: fix bug where sanitized job title was not used (#4994)
Browse files Browse the repository at this point in the history
The job title was actually sanitized, removing characters that are not
supported by the SGE scheduler, but the original string was used
accidentally, which was not caught due to missing tests.
  • Loading branch information
Matt Clarke authored Jun 21, 2021
1 parent 97a7fa9 commit f2367e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aiida/schedulers/plugins/sge.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def _get_submit_script_header(self, job_tmpl):
if not job_title or (job_title[0] not in string.ascii_letters):
job_title = f'j{job_title}'

lines.append(f'#$ -N {job_tmpl.job_name}')
lines.append(f'#$ -N {job_title}')

if job_tmpl.import_sys_environment:
lines.append('#$ -V')
Expand Down
13 changes: 13 additions & 0 deletions tests/schedulers/test_sge.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,16 @@ def _parse_time_string(string, fmt='%Y-%m-%dT%H:%M:%S'):
# the seconds since epoch, as suggested on stackoverflow:
# http://stackoverflow.com/questions/1697815
return datetime.datetime.fromtimestamp(time.mktime(time_struct))

def test_job_name_cleaning(self):
"""Test that invalid characters are cleaned from job name."""
from aiida.schedulers.datastructures import JobTemplate

scheduler = SgeScheduler()

job_tmpl = JobTemplate()
job_tmpl.job_resource = scheduler.create_job_resource(parallel_env='mpi8', tot_num_mpiprocs=16)
job_tmpl.job_name = 'Some/job:name@with*invalid-characters.'

header = scheduler._get_submit_script_header(job_tmpl)
self.assertTrue('#$ -N Somejobnamewithinvalid-characters.' in header, header)

0 comments on commit f2367e9

Please sign in to comment.