예제 #1
0
def main(bb_root: tp.Optional[str] = None,
         test_projects: bool = False) -> None:
    """
    Main function for the benchbuild config creator.

    `vara-gen-bbconfig`
    """
    if vara_cfg()["config_file"].value is None:
        if cli_yn_choice("Error! No VaRA config found. Should we create one?"):
            save_config()
        else:
            sys.exit()

    if bb_root is not None:
        if os.path.isabs(str(bb_root)):
            bb_root_path = str(bb_root)
        else:
            bb_root_path = os.path.dirname(str(vara_cfg()["config_file"])) + \
                           "/" + str(bb_root)

        LOG.info(f"Setting BB path to: {bb_root_path}")
        vara_cfg()["benchbuild_root"] = bb_root_path
        save_config()

    if vara_cfg()["benchbuild_root"].value is None:
        vara_cfg()["benchbuild_root"] = os.path.dirname(str(
            vara_cfg()["config_file"])) \
                                        + "/benchbuild"
        LOG.info(f"Setting BB path to: {vara_cfg()['benchbuild_root']}")
        save_config()

    bb_cfg = create_new_bb_config(vara_cfg(), test_projects)
    save_bb_config(bb_cfg)
예제 #2
0
    def test_bb_run_slurm_and_container(self, mock_sbatch,
                                        mock_build_images) -> None:
        runner = CliRunner()
        vara_cfg()['paper_config']['current_config'] = "test_revision_lookup"
        # needed so we see the paper config
        load_paper_config()
        # needed so benchbuild sees the paper config
        save_config()

        bb_cfg()["slurm"]["template"] = str(
            Path(str(vara_cfg()["benchbuild_root"])) /
            "slurm_container.sh.inc")
        save_bb_config()

        # Easiest way to configure slurm + container is 'vara-container'
        # As a side-effect, this command is now even more tested :)
        prepare_result = runner.invoke(driver_container.main,
                                       ["prepare-slurm"])
        self.assertEqual(0, prepare_result.exit_code, prepare_result.exception)
        self.assertTrue(Path(str(bb_cfg()["slurm"]["template"])).exists())

        result = runner.invoke(driver_run.main,
                               ["--slurm", "--container", "-E", "JustCompile"])
        self.assertEqual(0, result.exit_code, result.exception)
        self.assertTrue((Path(str(vara_cfg()["benchbuild_root"])) /
                         "JustCompile-slurm.sh").exists())
예제 #3
0
def _unset_varats_source_mount(
        image_context: BaseImageCreationContext) -> None:
    mounts = bb_cfg()["container"]["mounts"].value
    mounts[:] = [
        mount for mount in mounts
        if mount[1] != str(image_context.varats_source_mount_target)
    ]
    save_bb_config()
예제 #4
0
    def _create_benchbuild_config() -> None:
        if vara_cfg()["config_file"].value is None:
            LOG.warning("No VaRA config found, please initialize a "
                        "VaRA config first.")
            return

        if vara_cfg()["benchbuild_root"].value is None:
            vara_cfg()["benchbuild_root"] = path.dirname(
                str(vara_cfg()["config_file"])) + "/benchbuild"
        create_missing_folders()

        bb_cfg = create_new_bb_config(vara_cfg())
        save_bb_config(bb_cfg)
예제 #5
0
    def __enter__(self) -> Path:
        os.chdir(self.__tmp_dir.name)
        vara_cfg = settings.create_new_varats_config()
        bb_settings.setup_config(vara_cfg)
        # pylint: disable=protected-access
        settings._CFG = vara_cfg
        settings.save_config()

        bb_cfg = create_new_bb_config(settings.vara_cfg(), True)
        # make new bb_cfg point to old tmp to avoid multiple git clones
        bb_cfg["tmp_dir"] = str(self.__old_bb_config["tmp_dir"])

        settings.save_bb_config(bb_cfg)
        # pylint: disable=protected-access
        settings._BB_CFG = bb_cfg

        for test_input in self.__test_inputs:
            test_input.copy_to_env(self.__tmp_path)

        return self.__tmp_path
예제 #6
0
def _set_varats_source_mount(image_context: BaseImageCreationContext,
                             mnt_src: str) -> None:
    bb_cfg()["container"]["mounts"].value[:] += [[
        mnt_src, str(image_context.varats_source_mount_target)
    ]]
    save_bb_config()