How to use the smac.tae.execute_ta_run.StatusType.CRASHED function in smac

To help you get started, we’ve selected a few smac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github automl / SMAC3 / test / test_tae / test_tae_old.py View on Github external
ta=shlex.split(""),
            stats=stats)
        
        def test_success(**kwargs):
            return "Result of this algorithm run: SUCCESS,1,1,1,12354", ""
        
        eta._call_ta = test_success
        status, cost, runtime, ar_info = eta.run(config={},)
        self.assertEqual(status, StatusType.SUCCESS)
        
        def test_success(**kwargs):
            return "Result of this algorithm run: SUCESS,1,1,1,12354", ""
        
        eta._call_ta = test_success
        status, cost, runtime, ar_info = eta.run(config={},)
        self.assertEqual(status, StatusType.CRASHED)
        
        def test_success(**kwargs):
            return "Result of this algorithm run: success,1,1,1,12354", ""
        
        eta._call_ta = test_success
        status, cost, runtime, ar_info = eta.run(config={},)
        self.assertEqual(status, StatusType.SUCCESS)
github automl / auto-sklearn / test / test_automl / test_automl.py View on Github external
auto._do_dummy_prediction(D, 1)
        ta_run_mock.assert_called_once_with(1, cutoff=time_for_this_task)

        # Case 1. Check that function raises no error when statustype == success.
        # ta.run() returns status, cost, runtime, and additional info.
        ta_run_mock.return_value = StatusType.SUCCESS, None, None, "test"
        raised = False
        try:
            auto._do_dummy_prediction(D, 1)
        except ValueError:
            raised = True
        self.assertFalse(raised, 'Exception raised')

        # Case 2. Check that if statustype returned by ta.run() != success,
        # the function raises error.
        ta_run_mock.return_value = StatusType.CRASHED, None, None, "test"
        self.assertRaisesRegex(ValueError,
                               'Dummy prediction failed: test',
                               auto._do_dummy_prediction,
                               D, 1,
                               )
        ta_run_mock.return_value = StatusType.ABORT, None, None, "test"
        self.assertRaisesRegex(ValueError,
                               'Dummy prediction failed: test',
                               auto._do_dummy_prediction,
                               D, 1,
                               )
        ta_run_mock.return_value = StatusType.TIMEOUT, None, None, "test"
        self.assertRaisesRegex(ValueError,
                               'Dummy prediction failed: test',
                               auto._do_dummy_prediction,
                               D, 1,
github automl / SMAC3 / smac / tae / execute_ta_run_old.py View on Github external
status, runtime, runlength, quality, seed = fields
                    additional_info = {}
                else:
                    status, runtime, runlength, quality, seed, additional_info = fields
                    additional_info = {"additional_info": additional_info}

                runtime = min(float(runtime), cutoff)
                quality = float(quality)
                seed = int(seed)

        if status.upper() in ["SAT", "UNSAT", "SUCCESS"]:
            status = StatusType.SUCCESS
        elif status.upper() in ["TIMEOUT"]:
            status = StatusType.TIMEOUT
        elif status.upper() in ["CRASHED"]:
            status = StatusType.CRASHED
        elif status.upper() in ["ABORT"]:
            status = StatusType.ABORT
        elif status.upper() in ["MEMOUT"]:
            status = StatusType.MEMOUT
        else:
            self.logger.warn("Could not parse output of target algorithm. Expected format: "
                             "\"Result of this algorithm run: ,,,\"; "
                             "Treating as CRASHED run.")
            status = StatusType.CRASHED

        if status in [StatusType.CRASHED, StatusType.ABORT]:
            self.logger.warn(
                "Target algorithm crashed. Last 5 lines of stdout and stderr")
            self.logger.warn("\n".join(stdout_.split("\n")[-5:]))
            self.logger.warn("\n".join(stderr_.split("\n")[-5:]))
github automl / auto-sklearn / autosklearn / smbo.py View on Github external
)
    scenario = Scenario(scenario_dict)
    if len(metalearning_configurations) > 0:
        default_config = scenario.cs.get_default_configuration()
        initial_configurations = [default_config] + metalearning_configurations
    else:
        initial_configurations = None
    rh2EPM = RunHistory2EPM4Cost(
        num_params=len(scenario.cs.get_hyperparameters()),
        scenario=scenario,
        success_states=[
            StatusType.SUCCESS,
            StatusType.MEMOUT,
            StatusType.TIMEOUT,
            # As long as we don't have a model for crashes yet!
            StatusType.CRASHED,
        ],
        impute_censored_data=False,
        impute_state=None,
    )
    return SMAC(
        scenario=scenario,
        rng=seed,
        runhistory2epm=rh2EPM,
        tae_runner=ta,
        initial_configurations=initial_configurations,
        runhistory=runhistory,
        run_id=seed,
    )
github automl / CAVE / cave / reader / conversion / csv2rh.py View on Github external
"CRASHED" : StatusType.CRASHED,
                     "STATUSTYPE.CRASHED" : StatusType.CRASHED,
                     "MEMOUT" : StatusType.MEMOUT,
                     "STATUSTYPE.MEMOUT" : StatusType.MEMOUT,
                     "ABORT" : StatusType.ABORT,
                     "STATUSTYPE.ABORT" : StatusType.ABORT,
                     }

        status = status.strip().upper()
        if status in types:
            status = types[status]
        else:
            self.logger.warning("Could not parse %s as a status. Valid values "
                                "are: %s. Treating as CRASHED run.", status,
                                types.keys())
            status = StatusType.CRASHED
        return status
github automl / SMAC3 / smac / facade / smac_ac_facade.py View on Github external
model=model,
                               change_threshold=0.01,
                               max_iter=2)

        r2e_def_kwargs = {
            'scenario': scenario,
            'num_params': num_params,
            'success_states': [StatusType.SUCCESS, ],
            'impute_censored_data': True,
            'impute_state': [StatusType.CAPPED, ],
            'imputor': imputor,
            'scale_perc': 5
            }
        if scenario.run_obj == 'quality':
            r2e_def_kwargs.update({
                'success_states': [StatusType.SUCCESS, StatusType.CRASHED],
                'impute_censored_data': False,
                'impute_state': None,
            })
        if runhistory2epm_kwargs is not None:
            r2e_def_kwargs.update(runhistory2epm_kwargs)
        if runhistory2epm is None:
            if scenario.run_obj == 'runtime':
                runhistory2epm = RunHistory2EPM4LogCost(**r2e_def_kwargs)
            elif scenario.run_obj == 'quality':
                if scenario.transform_y == "NONE":
                    runhistory2epm = RunHistory2EPM4Cost(**r2e_def_kwargs)
                elif scenario.transform_y == "LOG":
                    runhistory2epm = RunHistory2EPM4LogCost(**r2e_def_kwargs)
                elif scenario.transform_y == "LOGS":
                    runhistory2epm = RunHistory2EPM4LogScaledCost(**r2e_def_kwargs)
                elif scenario.transform_y == "INVS":
github automl / auto-sklearn / examples / example_eips.py View on Github external
seed,
        ta,
        backend,
        metalearning_configurations,
        runhistory,
):
    scenario_dict['input_psmac_dirs'] = backend.get_smac_output_glob()
    scenario = Scenario(scenario_dict)
    rh2EPM = RunHistory2EPM4EIPS(
        num_params=len(scenario.cs.get_hyperparameters()),
        scenario=scenario,
        success_states=[
            StatusType.SUCCESS,
            StatusType.MEMOUT,
            StatusType.TIMEOUT,
            StatusType.CRASHED
        ],
        impute_censored_data=False,
        impute_state=None
    )
    types, bounds = get_types(scenario.cs,
                              scenario.feature_array)
    model = UncorrelatedMultiObjectiveRandomForestWithInstances(
        ['cost', 'runtime'],
        types=types,
        bounds=bounds,
        instance_features=scenario.feature_array,
        rf_kwargs={'seed': 1,},
    )
    acquisition_function = EIPS(model)
    return SMAC(
        runhistory=runhistory,
github automl / CAVE / cave / reader / conversion / csv2rh.py View on Github external
optional, mapping to use

        Returns
        -------
        status: StatusType
            interpreted status-type
        """
        if not types:
            types = {"SAT" : StatusType.SUCCESS,
                     "UNSAT" : StatusType.SUCCESS,
                     "SUCCESS" : StatusType.SUCCESS,
                     "STATUSTYPE.SUCCESS" : StatusType.SUCCESS,
                     "TIMEOUT" : StatusType.TIMEOUT,
                     "STATUSTYPE.TIMEOUT" : StatusType.TIMEOUT,
                     "CRASHED" : StatusType.CRASHED,
                     "STATUSTYPE.CRASHED" : StatusType.CRASHED,
                     "MEMOUT" : StatusType.MEMOUT,
                     "STATUSTYPE.MEMOUT" : StatusType.MEMOUT,
                     "ABORT" : StatusType.ABORT,
                     "STATUSTYPE.ABORT" : StatusType.ABORT,
                     }

        status = status.strip().upper()
        if status in types:
            status = types[status]
        else:
            self.logger.warning("Could not parse %s as a status. Valid values "
                                "are: %s. Treating as CRASHED run.", status,
                                types.keys())
            status = StatusType.CRASHED
        return status
github automl / SMAC3 / smac / tae / execute_func.py View on Github external
status = StatusType.SUCCESS
                cost = result
            else:
                status = StatusType.CRASHED
                cost = self.crash_cost
        
            runtime = float(obj.wall_clock_time)
        else:
            start_time = time.time()
            result = self.ta(config, **obj_kwargs)
            
            if result is not None:
                status = StatusType.SUCCESS
                cost = result
            else:
                status = StatusType.CRASHED
                cost = self.crash_cost
            
            runtime = time.time() - start_time
            additional_run_info = {}

        return status, cost, runtime, additional_run_info