Example #1
0
 def test_experiment_outputs_path_creation_deletion(self):
     experiment_outputs_path = get_experiment_outputs_path(
         self.experiment.unique_name)
     assert os.path.exists(experiment_outputs_path) is False
     create_experiment_outputs_path(self.experiment.unique_name)
     assert os.path.exists(experiment_outputs_path) is True
     delete_experiment_outputs(self.experiment.unique_name)
     assert os.path.exists(experiment_outputs_path) is False
Example #2
0
 def test_project_outputs_path_creation_deletion(self):
     with patch('experiments.tasks.build_experiment.apply_async') as _:
         experiment = ExperimentFactory(user=self.project.user, project=self.project)
     create_experiment_outputs_path(experiment.unique_name)
     experiment_outputs_path = get_experiment_outputs_path(experiment.unique_name)
     project_outputs_path = get_project_outputs_path(self.project.unique_name)
     assert os.path.exists(experiment_outputs_path) is True
     assert os.path.exists(project_outputs_path) is True
     delete_project_outputs(self.project.unique_name)
     assert os.path.exists(experiment_outputs_path) is False
     assert os.path.exists(project_outputs_path) is False
Example #3
0
def start_experiment(experiment_id):
    experiment = get_valid_experiment(experiment_id=experiment_id)
    if not experiment:
        return

    # Check if we need to restart an experiment
    if experiment.is_clone:
        handle_restarted_experiment(experiment)
    else:
        create_experiment_outputs_path(experiment.unique_name)

    scheduler.start_experiment(experiment)
Example #4
0
    def test_restarting_an_experiment(self):
        with patch('experiments.tasks.build_experiment.apply_async') as _:
            experiment1 = ExperimentFactory()

        # We create some outputs files for the experiment
        path = create_experiment_outputs_path(experiment1.unique_name)
        open(os.path.join(path, 'file'), 'w+')

        # Create a new experiment that is a clone of the previous
        with patch('experiments.tasks.build_experiment.apply_async') as _:
            experiment2 = ExperimentFactory(original_experiment=experiment1)

        # Check that outputs path for experiment2 does not exist yet
        experiment2_outputs_path = get_experiment_outputs_path(
            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
        handle_restarted_experiment(experiment2)

        assert os.path.exists(experiment2_outputs_path) is True
        assert os.path.exists(os.path.join(experiment2_outputs_path,
                                           'file')) is True