def create_job(job_backend, build_command, easyconfig, output_dir='easybuild-build'): """ Creates a job to build a *single* easyconfig. :param job_backend: A factory object for querying server parameters and creating actual job objects :param build_command: format string for command, full path to an easyconfig file will be substituted in it :param easyconfig: easyconfig as processed by process_easyconfig :param output_dir: optional output path; --regtest-output-dir will be used inside the job with this variable returns the job """ # capture PYTHONPATH, MODULEPATH and all variables starting with EASYBUILD easybuild_vars = {} for name in os.environ: if name.startswith("EASYBUILD"): easybuild_vars[name] = os.environ[name] for env_var in ["PYTHONPATH", "MODULEPATH"]: if env_var in os.environ: easybuild_vars[env_var] = os.environ[env_var] _log.info("Dictionary of environment variables passed to job: %s" % easybuild_vars) # obtain unique name based on name/easyconfig version tuple ec_tuple = (easyconfig['ec']['name'], det_full_ec_version(easyconfig['ec'])) name = '-'.join(ec_tuple) # determine whether additional options need to be passed to the 'eb' command add_opts = '' if easyconfig['hidden']: add_opts += ' --hidden' # create command based on build_command template command = build_command % { 'add_opts': add_opts, 'output_dir': os.path.join(os.path.abspath(output_dir), name), 'spec': easyconfig['spec'], } # just use latest build stats repo = init_repository(get_repository(), get_repositorypath()) buildstats = repo.get_buildstats(*ec_tuple) extra = {} if buildstats: previous_time = buildstats[-1]['build_time'] extra['hours'] = int(math.ceil(previous_time * 2 / 60)) if build_option('job_cores'): extra['cores'] = build_option('job_cores') job = job_backend.make_job(command, name, easybuild_vars, **extra) job.module = easyconfig['ec'].full_mod_name return job