def _download_private(self): external_repo.download_and_extract_repo( "twosixlabs/armory-private", external_repo_dir=self.external_repo_dir) self.extra_env_vars.update({ "ARMORY_PRIVATE_S3_ID": os.getenv("ARMORY_PRIVATE_S3_ID"), "ARMORY_PRIVATE_S3_KEY": os.getenv("ARMORY_PRIVATE_S3_KEY"), })
def test_download(self): repo = "twosixlabs/armory-example" repo_name = repo.split("/")[-1] download_and_extract_repo(repo) self.assertTrue(os.path.exists(f"{paths.EXTERNAL_REPOS}/{repo_name}")) self.assertTrue( os.path.isfile(f"{paths.EXTERNAL_REPOS}/{repo_name}/README.md")) shutil.rmtree(f"{paths.EXTERNAL_REPOS}/{repo_name}")
def test_download(): set_github_token() test_external_repo_dir = pathlib.Path(HOST_PATHS.tmp_dir, "test-external-repo-subdir") repo = "twosixlabs/armory-example" repo_name = repo.split("/")[-1] download_and_extract_repo(repo, external_repo_dir=test_external_repo_dir) basedir = test_external_repo_dir / repo_name assert os.path.exists(basedir) assert os.path.isfile(basedir / "README.md") shutil.rmtree(basedir) os.remove(test_external_repo_dir / (repo_name + ".tar.gz")) os.rmdir(test_external_repo_dir)
def test_download_branch(): set_github_token() tmp_subdir = pathlib.Path(paths.host().tmp_dir, "test-external-repo-subdir") external_repo_dir = pathlib.Path(paths.get_external(tmp_subdir)) repo = "twosixlabs/[email protected]" org_repo_name = repo.split("@")[0] repo_name = org_repo_name.split("/")[-1] download_and_extract_repo(repo, external_repo_dir=external_repo_dir) basedir = external_repo_dir / repo_name assert os.path.exists(basedir) assert os.path.isfile(basedir / "README.md") shutil.rmtree(basedir) os.remove(external_repo_dir / (repo_name + ".tar.gz")) os.rmdir(external_repo_dir) os.rmdir(tmp_subdir)
def _scenario_setup(config: dict): """ Creates scenario specific tmp and output directiories. Also pulls external repositories ahead of running the scenario in case the scenario itself is found in the external repository. """ runtime_paths = paths.runtime_paths() scenario_output_dir = os.path.join(runtime_paths.output_dir, config["eval_id"]) scenario_tmp_dir = os.path.join(runtime_paths.tmp_dir, config["eval_id"]) os.makedirs(scenario_output_dir, exist_ok=True) os.makedirs(scenario_tmp_dir, exist_ok=True) logger.warning(f"Outputs will be written to {scenario_output_dir}") # Download any external repositories and add them to the sys path for use if config["sysconfig"].get("external_github_repo", None): external_repo_dir = os.path.join(scenario_tmp_dir, "external") external_repo.download_and_extract_repo( config["sysconfig"]["external_github_repo"], external_repo_dir=external_repo_dir, )
def _download_external(self): external_repo.download_and_extract_repo( self.config["sysconfig"]["external_github_repo"], external_repo_dir=self.external_repo_dir, )
def _download_external(self): external_repo.download_and_extract_repo( self.config["external_github_repo"])