def test_experiment_outputs_path_creation_deletion(self): experiment_outputs_path = stores.get_experiment_outputs_path( persistence=self.experiment.persistence_outputs, experiment_name=self.experiment.unique_name) assert os.path.exists(experiment_outputs_path) is False stores.create_experiment_outputs_path( persistence=self.experiment.persistence_outputs, experiment_name=self.experiment.unique_name) assert os.path.exists(experiment_outputs_path) is True stores_schedule_outputs_deletion(persistence=None, subpath=self.experiment.subpath) assert os.path.exists(experiment_outputs_path) is False
def test_copying_an_experiment(self): with patch('scheduler.tasks.experiments.experiments_build.apply_async') as _: # noqa experiment1 = ExperimentFactory() # We create some outputs files for the experiment path = stores.create_experiment_outputs_path( persistence=experiment1.persistence_outputs, experiment_name=experiment1.unique_name) open(os.path.join(path, 'file'), 'w+') # Create a new experiment that is a clone of the previous with patch('scheduler.tasks.experiments.experiments_build.apply_async') as _: # noqa experiment2 = ExperimentFactory(original_experiment=experiment1) # Check that outputs path for experiment2 does not exist yet experiment2_outputs_path = stores.get_experiment_outputs_path( persistence=experiment2.persistence_outputs, experiment_name=experiment2.unique_name) assert os.path.exists(experiment2_outputs_path) is False # Handle restart should create the outputs and copy the content of experiment 1 copy_experiment(experiment2) assert os.path.exists(experiment2_outputs_path) is True assert os.path.exists(os.path.join(experiment2_outputs_path, 'file')) is True
def test_experiment_group_outputs_path_creation_deletion(self): experiment = ExperimentFactory(user=self.project.user, project=self.project, experiment_group=self.experiment_group) stores.create_experiment_outputs_path( persistence=experiment.persistence_outputs, experiment_name=experiment.unique_name) experiment_outputs_path = stores.get_experiment_outputs_path( persistence=experiment.persistence_outputs, experiment_name=experiment.unique_name) experiment_group_outputs_path = stores.get_experiment_group_outputs_path( persistence=self.experiment_group.persistence_outputs, experiment_group_name=self.experiment_group.unique_name) assert os.path.exists(experiment_outputs_path) is True assert os.path.exists(experiment_group_outputs_path) is True stores_schedule_outputs_deletion(persistence=None, subpath=self.experiment_group.subpath) assert os.path.exists(experiment_outputs_path) is False assert os.path.exists(experiment_group_outputs_path) is False
def test_project_outputs_path_creation_deletion(self): with patch('scheduler.tasks.experiments.experiments_build.apply_async' ) as _: # noqa experiment = ExperimentFactory(user=self.project.user, project=self.project) stores.create_experiment_outputs_path( persistence=experiment.persistence_outputs, experiment_name=experiment.unique_name) experiment_outputs_path = stores.get_experiment_outputs_path( persistence=experiment.persistence_outputs, experiment_name=experiment.unique_name) project_outputs_path = stores.get_project_outputs_path( persistence=None, project_name=self.project.unique_name) assert os.path.exists(experiment_outputs_path) is True assert os.path.exists(project_outputs_path) is True stores_schedule_outputs_deletion(persistence='outputs', subpath=self.project.subpath) assert os.path.exists(experiment_outputs_path) is False assert os.path.exists(project_outputs_path) is False