Exemplo n.º 1
0
 def entrypoint(self, name, kwargs: Dict[str, Any]) -> Any:
     if name == "can_accept":
         return self._judge.can_accept(Trial.from_jsondict(kwargs["trial"]))
     if name == "judge":
         return self._judge.judge(
             TrialReport.from_jsondict(kwargs)).jsondict
     if name == "get_budget":
         return self._judge.get_budget(Trial.from_jsondict(kwargs["trial"]),
                                       kwargs["rung"])
     raise NotImplementedError  # pragma: no cover
Exemplo n.º 2
0
def get_trials_from_row(row: Dict[str, Any]) -> Iterable[Trial]:
    dfs: Dict[str, Any] = {}
    for k, v in row.items():
        if k.startswith(TUNE_DATASET_DF_PREFIX):
            key = k[len(TUNE_DATASET_DF_PREFIX):]
            if v is not None:
                dfs[key] = pd.read_parquet(v)
    for params in json.loads(row[TUNE_DATASET_TRIALS]):
        yield Trial.from_jsondict(params).with_dfs(dfs)
Exemplo n.º 3
0
def test_encode_decode():
    p = {"a": 1, "b": Rand(1, 2)}
    trial = Trial("abc", p, {}, keys=["x", "y"], dfs={"v": ""})
    d = trial.jsondict
    assert isinstance(d["params"]["b"], dict)
    t = Trial.from_jsondict(d)
    assert isinstance(t.params["b"], Rand)
    assert ["x", "y"] == t.keys
    assert {} == t.dfs  # dfs will not be serialized