def test_simcore_service_labels(example: Dict, items: int,
                                uses_dynamic_sidecar: bool) -> None:
    simcore_service_labels = SimcoreServiceLabels.parse_obj(example)

    assert simcore_service_labels
    assert len(simcore_service_labels.dict(exclude_unset=True)) == items
    assert simcore_service_labels.needs_dynamic_sidecar == uses_dynamic_sidecar
def test_raises_error_if_http_entrypoint_is_missing() -> None:
    simcore_service_labels: Dict[str, Any] = deepcopy(
        SimcoreServiceLabels.Config.schema_extra["examples"][2])
    del simcore_service_labels["simcore.service.container-http-entrypoint"]

    with pytest.raises(ValueError):
        SimcoreServiceLabels(**simcore_service_labels)
def test_simcore_services_labels_compose_spec_null_container_http_entry_provided(
) -> None:
    sample_data = deepcopy(
        SimcoreServiceLabels.Config.schema_extra["examples"][2])
    assert sample_data["simcore.service.container-http-entrypoint"]

    sample_data["simcore.service.compose-spec"] = None
    with pytest.raises(ValidationError):
        SimcoreServiceLabels(**sample_data)
 async def get_service_labels(
         self, service: ServiceKeyVersion) -> SimcoreServiceLabels:
     resp = await self.request(
         "GET",
         f"services/{urllib.parse.quote_plus(service.key)}/{service.version}/labels",
     )
     resp.raise_for_status()
     if resp.status_code == status.HTTP_200_OK:
         return SimcoreServiceLabels.parse_obj(
             unenvelope_or_raise_error(resp))
     raise HTTPException(status_code=resp.status_code, detail=resp.content)
Exemple #5
0
def _get_boot_options(
    service_labels: SimcoreServiceLabels,
) -> Optional[Dict[EnvVarKey, BootOption]]:
    as_dict = service_labels.dict()
    boot_options_encoded = as_dict.get("io.simcore.boot-options", None)
    if boot_options_encoded is None:
        return None

    boot_options = json.loads(boot_options_encoded)["boot-options"]
    log.debug("got boot_options=%s", boot_options)
    return {k: BootOption.parse_obj(v) for k, v in boot_options.items()}
Exemple #6
0
def simcore_service_labels() -> SimcoreServiceLabels:
    return SimcoreServiceLabels(
        **SimcoreServiceLabels.Config.schema_extra["examples"][1]
    )
def simcore_service_labels() -> SimcoreServiceLabels:
    # overwrites global fixture
    return SimcoreServiceLabels(
        **SimcoreServiceLabels.Config.schema_extra["examples"][2])