Skip to content
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

Use sanitised variable name in SGE scheduler job title #4994

Merged
merged 5 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)