def __init__(self) -> None: super().__init__() self.runcmd = 'ch-run' if not host.which(self.runcmd): inyp = 'Is it in your PATH?' notf = "'{}' not found. " + inyp errs = notf.format(self.runcmd) raise RuntimeError(errs)
def _check_env(self) -> None: ''' Build environment verification function. Raises OSError if the environment is unsatisfactory. ''' logger.emlog('# Checking your build environment...') inyp = 'Is it in your PATH?\n' notf = "'{}' not found. " + inyp errs = str() if not host.which(self.buildc): errs += notf.format(self.buildc) if not host.which(self.tarcmd): errs += notf.format(self.tarcmd) if errs: raise OSError(utils.chomp(errs))
def _emit_builder_info(self) -> None: ''' Emits builder information gathered at run-time. ''' binfo = dict() binfo['Builder'] = { 'which': host.which(self.buildc), 'version': host.capture('{} --version'.format(self.buildc)), } utils.yamlp(binfo, 'Builder') metadata.add_asset(metadata.YAMLDictAsset(binfo, 'builder'))
def _srun_staging_cmd_hook() -> str: cmd = 'srun' if host.which(cmd) is None: helps = 'A custom image stager can be set via ' \ 'ImageStager.staging_cmd_hook.' raise RuntimeError(F'{cmd} not found.\n{helps}') envvars = ['SLURM_JOB_NUM_NODES', 'SLURM_NNODES'] varvals = list( filter(lambda x: x is not None, [os.getenv(x) for x in envvars])) if not varvals: errs = 'Cannot determine the number of nodes in your job.' raise RuntimeError(errs) nnodes = varvals[0] return F'{cmd} -n {nnodes} -N {nnodes}'