Ejemplo n.º 1
0
def test_with_evc_tree(monkeypatch, kind):
    """Tests that the plotly backend returns a plotly object"""

    WITH_EVC_TREE = True

    original_to_pandas = Experiment.to_pandas

    def mock_to_pandas(self, with_evc_tree):
        assert with_evc_tree is WITH_EVC_TREE
        return original_to_pandas(self, with_evc_tree)

    monkeypatch.setattr("orion.core.worker.experiment.Experiment.to_pandas",
                        mock_to_pandas)

    with create_experiment(config, trial_config,
                           ["completed"]) as (_, _, experiment):
        pa = PlotAccessor(experiment)

        WITH_EVC_TREE = True
        plot = getattr(pa, kind)(with_evc_tree=WITH_EVC_TREE)
        check_plot(plot, kind)

        WITH_EVC_TREE = False
        plot = getattr(pa, kind)(with_evc_tree=WITH_EVC_TREE)
        check_plot(plot, kind)
Ejemplo n.º 2
0
def test_call_to(kind):
    """Tests instance calls to `PlotAccessor.{kind}()`"""
    with create_experiment(config, trial_config,
                           ["completed"]) as (_, _, experiment):
        pa = PlotAccessor(experiment)
        plot = getattr(pa, kind)()

        check_plot(plot, kind)
Ejemplo n.º 3
0
def test_kind(kind):
    """Tests that a plot can be created from specifying `kind` as a parameter."""
    with create_experiment(config, trial_config,
                           ["completed"]) as (_, _, experiment):
        pa = PlotAccessor(experiment)
        plot = pa(kind=kind)

        check_plot(plot, kind)
Ejemplo n.º 4
0
def test_regret_is_default_plot():
    """Tests that the regret plot is the default plot"""
    with create_experiment(config, trial_config,
                           ["completed"]) as (_, _, experiment):
        pa = PlotAccessor(experiment)
        plot = pa()

        check_plot(plot, "regret")
Ejemplo n.º 5
0
def test_call_nonexistent_kind():
    """Tests that specifying a non existent kind will fail"""
    with create_experiment(config, trial_config,
                           ["completed"]) as (_, _, experiment):
        pa = PlotAccessor(experiment)
        with pytest.raises(ValueError) as exception:
            pa(kind="nonexistent")

        assert "Plot of kind 'nonexistent' is not one of" in str(
            exception.value)
Ejemplo n.º 6
0
 def __init__(self, experiment, producer, heartbeat=None):
     self._experiment = experiment
     self._producer = producer
     self._pacemakers = {}
     self.set_broken_trials = functools.partial(set_broken_trials,
                                                client=self)
     if heartbeat is None:
         heartbeat = orion.core.config.worker.heartbeat
     self.heartbeat = heartbeat
     self.plot = PlotAccessor(self)
     atexit.register(self.set_broken_trials)
Ejemplo n.º 7
0
def test_init_require_experiment():
    """Tests that a `PlotAccessor` requires an instance of `ExperimentClient`"""
    with pytest.raises(ValueError) as exception:
        PlotAccessor(None)

    assert "Parameter 'experiment' is None" in str(exception.value)
Ejemplo n.º 8
0
def test_emtpy(kind):
    """Tests instance calls to `PlotAccessor.{kind}()`"""
    with create_experiment(config, trial_config, []) as (_, _, experiment):
        pa = PlotAccessor(experiment)
        getattr(pa, kind)()