Ejemplo n.º 1
0
def get_ensemble_responses(*,
                           res: LibresFacade = Depends(get_res),
                           ensemble_id: UUID) -> Mapping[str, js.RecordOut]:

    response_map: Mapping[str, js.RecordOut] = {}
    case = get_name("ensemble", ensemble_id)

    for response_name in get_response_names():
        obs_keys = res.observation_keys(response_name)
        observations_list = [
            js.ObservationOut(
                id=uuid4(),
                userData=[],
                errors=obs["errors"],
                values=obs["values"],
                x_axis=obs["x_axis"],
                name=obs["name"],
            ) for obs in observations_for_obs_keys(case, obs_keys)
        ]
        response_map[str(response_name)] = js.RecordOut(
            id=get_id(f"response", f"{ensemble_id}/{response_name}"),
            name=response_name,
            userdata={},
            observations=observations_list,
        )

    return response_map
Ejemplo n.º 2
0
def get_experiment_by_id(
    *, res: LibresFacade = Depends(get_res), experiment_id: UUID
) -> js.ExperimentOut:
    return js.ExperimentOut(
        name="default",
        id=get_id("experiment", "default"),
        ensemble_ids=[get_id("ensemble", case) for case in res.cases()],
        priors={},
        userdata={},
    )
Ejemplo n.º 3
0
def get_experiments(*, res: LibresFacade = Depends(get_res)) -> List[js.ExperimentOut]:
    return [
        js.ExperimentOut(
            name="default",
            id=get_id("experiment", "default"),
            ensemble_ids=[get_id("ensemble", case) for case in res.cases()],
            priors={},
            userdata={},
        )
    ]
Ejemplo n.º 4
0
def get_ensemble_responses(*,
                           res: LibresFacade = Depends(get_res),
                           ensemble_id: UUID) -> Mapping[str, js.RecordOut]:

    response_map: Mapping[str, js.RecordOut] = {}
    for response_name in get_response_names(res):
        obs_keys = res.observation_keys(response_name)
        response_map[str(response_name)] = js.RecordOut(
            id=get_id("response", f"{ensemble_id}/{response_name}"),
            name=response_name,
            userdata={},
            has_observations=len(obs_keys) != 0,
        )
    return response_map
Ejemplo n.º 5
0
def get_ensemble(*, res: LibresFacade = Depends(get_res),
                 ensemble_id: UUID) -> js.EnsembleOut:
    return js.EnsembleOut(
        id=ensemble_id,
        children=[],
        parent=None,
        experiment_id=get_id("experiment", "default"),
        userdata={"name": get_name("ensemble", ensemble_id)},
        size=get_size(get_name("ensemble", ensemble_id)),
        parameter_names=ensemble_parameter_names(
            get_name("ensemble", ensemble_id)),
        response_names=get_response_names(),
        child_ensemble_ids=[],
    )
Ejemplo n.º 6
0
def get_experiment_ensembles(*,
                             res: LibresFacade = Depends(get_res),
                             experiment_id: UUID) -> List[js.EnsembleOut]:
    return [
        js.EnsembleOut(
            id=get_id("ensemble", case),
            children=[],
            parent=None,
            experiment_id=get_id("experiment", "default"),
            userdata={"name": case},
            size=get_size(res),
            parameter_names=[],
            response_names=[],
            child_ensemble_ids=[],
        ) for case in res.cases()
    ]
Ejemplo n.º 7
0
 def resolve_id(root: Any, info: "ResolveInfo") -> UUID:
     return get_id("ensemble", root)
Ejemplo n.º 8
0
 def resolve_id(root: Any, info: "ResolveInfo") -> UUID:
     return get_id("response", root["name"])
Ejemplo n.º 9
0
 def resolve_id(root: Any, info: "ResolveInfo") -> UUID:
     return get_id("experiment", "default")