def setUp(self) -> None: super().setUp() self.repository_path = f"/tmp/{uuid4()}/" self.random_dirs = dict() # Create the root repository os.makedirs(self.repository_path) set_git_for_test(self.repository_path) run_test_init(selected_dir=self.repository_path) # Create files at the root of the repository to be added and removed for i in range(3): path = os.path.join(self.repository_path, f"{i}.txt") with open(path, "w+") as tmp_file: tmp_file.write("Your text goes here") # Create random directories in the root with random files in them. for _ in range(3): dir_name = str(uuid4()) path = os.path.join(self.repository_path, dir_name) self.random_dirs.update({dir_name: path}) os.makedirs(path) for i in range(3): file_path = os.path.join(path, f"{i}_{dir_name}.txt") with open(file_path, "w+") as tmp_file: tmp_file.write("Your text goes here")
def setUp(self) -> None: super().setUp() self.repository_path = f"/tmp/{uuid4()}/" # Remove if it exists shutil.rmtree(self.repository_path, ignore_errors=True) # Create the root repository os.makedirs(self.repository_path) set_git_for_test(self.repository_path) run_test_init(self.repository_path) f_name = f'{uuid4()}.txt' self.relative_path = f_name self.absolute_path = os.path.join(self.repository_path, f_name) with open(self.absolute_path, 'w') as f: f.write("Gibberish") self.absolute_path_outside_script = f"/tmp/{uuid4()}.txt" with open(self.absolute_path_outside_script, "w") as f: f.write("Your text goes here") self.parser = argparse.Namespace( files=[ self.relative_path, ], soft_delete=True, ) commands.run_add(self.parser, selected_dir=self.repository_path)
def setUp(self) -> None: super().setUp() # Create the root repository self.repository_path = f"/tmp/{uuid4()}/" os.makedirs(self.repository_path) set_git_for_test(self.repository_path) run_test_init(selected_dir=self.repository_path) self.ds = f"dataset.txt" file_path = os.path.join(self.repository_path, self.ds) with open(file_path, "w+") as tmp_file: tmp_file.write("Your dataset text goes here") proc = subprocess.Popen( [f"au data add {self.ds}", ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=self.repository_path, ) out, err = proc.communicate() if proc.returncode != 0: raise Exception(f"Failed: {err}, {out}, {proc.returncode}") else: logging.debug(f"au data add worked...{out}")
def setUp(self): self.repository_path = f"/tmp/{uuid4()}/" # Remove if it exists shutil.rmtree(self.repository_path, ignore_errors=True) # Create the root repository os.makedirs(self.repository_path) set_git_for_test(self.repository_path) run_test_init(self.repository_path)
def setUp(self) -> None: super().setUp() self.test_dir = f'/tmp/{uuid4()}' os.makedirs(self.test_dir) self.random_dirs = dict() set_git_for_test(self.test_dir) run_test_init(selected_dir=self.test_dir) f_name = f'{uuid4()}.txt' self.relative_path = f_name self.absolute_path = os.path.join(self.test_dir, f_name) with open(self.absolute_path, 'w') as f: f.write("Gibberish") self.absolute_path_outside_script = "/tmp/copy.txt" with open(self.absolute_path_outside_script, "w") as f: f.write("Your text goes here")
def setUp(self) -> None: super().setUp() self.repository_path = "/tmp/repository/" # Remove if it exists shutil.rmtree(self.repository_path, ignore_errors=True) # Create the root repository os.makedirs(self.repository_path) set_git_for_test(self.repository_path) run_test_init(selected_dir=self.repository_path) Theorem.instance = None # Needed so that we fake as if running from the au repo os.chdir(self.repository_path) # Creating a new experiment # Changing the requirements. proc = subprocess.Popen( [ "pip install minimal", ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=self.repository_path, ) o, _ = proc.communicate() self.assertEqual(proc.returncode, 0) b, b_hash = is_new_requirements() self.assertTrue(b) # Add code with open(os.path.join(self.repository_path, "src/experiment.py"), "w+") as f: f.write("print('Hello world')") self.assertTrue(is_new_code()) # Add dataset with open(os.path.join(self.repository_path, "dataset.txt"), "w+") as tmp_file: tmp_file.write("Your dataset text goes here") proc = subprocess.Popen( [ f"au --verbose data add dataset.txt", ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=self.repository_path, ) out, err = proc.communicate() if proc.returncode != 0: raise Exception(f"Failed: {err}") add_remote_proc = subprocess.Popen( [f"git remote add origin {self.repository_path}/.git "], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=self.repository_path, ) out, err = add_remote_proc.communicate() if add_remote_proc.returncode != 0: raise Exception(f"Failed: {err}") add_remote_proc = subprocess.Popen( [f"git push --set-upstream origin master "], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, cwd=self.repository_path, ) out, err = add_remote_proc.communicate() if add_remote_proc.returncode != 0: raise Exception(f"Failed: {err}") Theorem().requirements_did_change(b_hash) self.experiment_id = Theorem().experiment_id self.assertTrue(end_experiment())