def create_job(build_command, easyconfig, output_dir=None, conn=None, ppn=None): """ Creates a job, to build a *single* easyconfig @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; $EASYBUILDTESTOUTPUT will be set inside the job with this variable @param conn: open connection to PBS server @param ppn: ppn setting to use (# 'processors' (cores) per node to use) returns the job """ if output_dir is None: output_dir = 'easybuild-build' # create command based on build_command template command = build_command % {'spec': easyconfig['spec']} # 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] others = ["PYTHONPATH", "MODULEPATH"] for env_var in others: 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) var = config.OLDSTYLE_ENVIRONMENT_VARIABLES['test_output_path'] easybuild_vars[var] = os.path.join(os.path.abspath(output_dir), name) # just use latest build stats repo = init_repository(get_repository(), get_repositorypath()) buildstats = repo.get_buildstats(*ec_tuple) resources = {} if buildstats: previous_time = buildstats[-1]['build_time'] resources['hours'] = int(math.ceil(previous_time * 2 / 60)) job = PbsJob(command, name, easybuild_vars, resources=resources, conn=conn, ppn=ppn) job.module = det_full_module_name(easyconfig['ec']) return job
def tokey(dep): """Determine key for specified dependency.""" return det_full_module_name(dep)