|
| 1 | +import os |
| 2 | +import subprocess |
| 3 | + |
| 4 | +from easybuild.framework.easystack import EasyStackParser |
| 5 | + |
| 6 | +CPU_TARGET_A64FX = 'aarch64/a64fx' |
| 7 | + |
| 8 | + |
| 9 | +def get_orig_easystack(easystack, repo_path): |
| 10 | + """ write the original easystack file (before the diff was applied) """ |
| 11 | + orig_easystack = f'{easystack}.orig' |
| 12 | + git_cmd = f'git -C {repo_path} show HEAD:{easystack}'.split() |
| 13 | + with open(os.path.join(repo_path, orig_easystack), 'w', encoding='utf-8') as outfile: |
| 14 | + subprocess.run(git_cmd, check=True, stdout=outfile) |
| 15 | + return orig_easystack |
| 16 | + |
| 17 | + |
| 18 | +def det_submit_opts(job): |
| 19 | + """ |
| 20 | + determine submit options from added easyconfigs |
| 21 | + Args: |
| 22 | + job (Job): namedtuple containing all information about job to be submitted |
| 23 | +
|
| 24 | + Returns: |
| 25 | + (string): string containing extra submit options |
| 26 | + """ |
| 27 | + easystack = 'easystacks/software.eessi.io/2023.06/a64fx/eessi-2023.06-eb-4.9.4-2023a.yml' |
| 28 | + repo_path = job.working_dir |
| 29 | + orig_easystack = get_orig_easystack(easystack, repo_path) |
| 30 | + |
| 31 | + esp = EasyStackParser() |
| 32 | + orig_ecs = {x[0] for x in esp.parse(os.path.join(repo_path, orig_easystack)).ec_opt_tuples} |
| 33 | + pr_ecs = {x[0] for x in esp.parse(os.path.join(repo_path, easystack)).ec_opt_tuples} |
| 34 | + added_ecs = pr_ecs - orig_ecs |
| 35 | + print(f'added easyconfigs: {added_ecs}') |
| 36 | + |
| 37 | + submit_opts = [job.slurm_opts] |
| 38 | + for ec in added_ecs: |
| 39 | + # remove OS part from arch_target |
| 40 | + arch_name = '/'.join(job.arch_target.split('/')[1:]) |
| 41 | + # set walltime limit to 2 days when R-bundle-CRAN should be built on a64fx |
| 42 | + if ec.startswith('R-bundle-CRAN-2023.12-foss-2023a') and arch_name == CPU_TARGET_A64FX: |
| 43 | + submit_opts.append('--time=2-00:00:00') |
| 44 | + |
| 45 | + return ' '.join(submit_opts) |
0 commit comments