def test_experiment_group_deletion_triggers_stopping_for_running_experiment( self, create_build_job): build = BuildJobFactory() BuildJobStatus.objects.create(status=JobLifeCycle.SUCCEEDED, job=build) create_build_job.return_value = build, True, True with patch('hpsearch.tasks.grid.hp_grid_search_start.apply_async' ) as mock_fct: experiment_group = ExperimentGroupFactory() assert mock_fct.call_count == 2 experiment = ExperimentFactory(project=experiment_group.project, experiment_group=experiment_group) # Set this experiment to scheduled experiment.set_status(ExperimentLifeCycle.SCHEDULED) # Add job ExperimentJobFactory(experiment=experiment) assert Experiment.objects.filter( experiment_group=experiment_group).count() == 3 with patch('scheduler.tasks.experiments.experiments_stop.apply_async' ) as mock_fct: experiment_group.delete() assert mock_fct.call_count == 1 # Only one experiment was stopped assert Experiment.objects.filter( experiment_group=experiment_group).count() == 0
def test_experiment_group_deletion_triggers_stopping_for_running_experiment( self): with patch('hpsearch.tasks.grid.hp_grid_search_start.apply_async' ) as mock_fct: experiment_group = ExperimentGroupFactory() assert mock_fct.call_count == 1 experiment = ExperimentFactory(project=experiment_group.project, experiment_group=experiment_group) # Set this experiment to scheduled experiment.set_status(ExperimentLifeCycle.SCHEDULED) # Add job ExperimentJobFactory(experiment=experiment) assert Experiment.objects.filter( experiment_group=experiment_group).count() == 3 with patch('scheduler.tasks.experiments.experiments_stop.apply_async' ) as mock_fct: experiment_group.delete() assert mock_fct.call_count == 1 # Only one experiment was stopped assert Experiment.objects.filter( experiment_group=experiment_group).count() == 0
def test_experiment_group_deletion_deletes_old_data( self, delete_outputs_path, delete_logs_path, _): experiment_group = ExperimentGroupFactory() assert delete_outputs_path.call_count == 0 assert delete_logs_path.call_count == 0 experiment_group.delete() assert delete_outputs_path.call_count == 1 assert delete_logs_path.call_count == 1
def test_experiment_group_deletion_triggers_experiments_deletion(self): with patch('runner.hp_search.grid.hp_grid_search_start.apply_async') as mock_fct: experiment_group = ExperimentGroupFactory() assert mock_fct.call_count == 1 assert Experiment.objects.filter(experiment_group=experiment_group).count() == 2 with patch('runner.schedulers.experiment_scheduler.stop_experiment') as mock_fct: experiment_group.delete() assert mock_fct.call_count == 2 assert Experiment.objects.filter(experiment_group=experiment_group).count() == 0
def test_experiment_group_deletion_triggers_experiments_deletion(self): with patch('hpsearch.tasks.grid.hp_grid_search_start.apply_async') as mock_fct: experiment_group = ExperimentGroupFactory() assert mock_fct.call_count == 1 assert Experiment.objects.filter(experiment_group=experiment_group).count() == 2 with patch('scheduler.experiment_scheduler.stop_experiment') as mock_fct: experiment_group.delete() assert mock_fct.call_count == 2 assert Experiment.objects.filter(experiment_group=experiment_group).count() == 0
def test_experiment_group_deletion_deletes_old_data(self, delete_path, _): experiment_group = ExperimentGroupFactory() assert delete_path.call_count == 2 # outputs + logs experiment_group.delete() assert delete_path.call_count == 2 + 2 # outputs + logs