示例#1
0
    def pre_validate(self, data, **kwargs):
        connections = data.get(POLYAXON_KEYS_AGENT_CONNECTIONS)
        try:
            connections = parser.get_dict(
                key=POLYAXON_KEYS_AGENT_CONNECTIONS,
                value=connections,
                is_list=True,
                is_optional=True,
            )
        except PolyaxonSchemaError as e:
            raise ValidationError("Received an invalid connections") from e
        if connections:
            data[POLYAXON_KEYS_AGENT_CONNECTIONS] = connections

        artifacts_store = data.get(POLYAXON_KEYS_AGENT_ARTIFACTS_STORE)
        try:
            artifacts_store = parser.get_dict(
                key=POLYAXON_KEYS_AGENT_ARTIFACTS_STORE,
                value=artifacts_store,
                is_optional=True,
            )
        except PolyaxonSchemaError as e:
            raise ValidationError(
                "Received an invalid artifacts store `{}`".format(
                    artifacts_store)) from e
        if artifacts_store:
            data[POLYAXON_KEYS_AGENT_ARTIFACTS_STORE] = artifacts_store

        sidecar = data.get(POLYAXON_KEYS_AGENT_SIDECAR)
        try:
            sidecar = parser.get_dict(key=POLYAXON_KEYS_AGENT_SIDECAR,
                                      value=sidecar,
                                      is_optional=True)
        except PolyaxonSchemaError as e:
            raise ValidationError(
                "Received an invalid sidecar `{}`".format(sidecar)) from e
        if sidecar:
            data[POLYAXON_KEYS_AGENT_SIDECAR] = sidecar

        init = data.get(POLYAXON_KEYS_AGENT_INIT)
        try:
            init = parser.get_dict(key=POLYAXON_KEYS_AGENT_INIT,
                                   value=init,
                                   is_optional=True)
        except PolyaxonSchemaError as e:
            raise ValidationError(
                "Received an invalid init `{}`".format(init)) from e
        if init:
            data[POLYAXON_KEYS_AGENT_INIT] = init

        return data
示例#2
0
    def pre_validate(self, data, **kwargs):
        if data.get("image") is not None:
            data["image"] = parser.get_dict(
                key="image",
                value=data["image"],
            )
        if data.get("histogram") is not None:
            data["histogram"] = parser.get_dict(
                key="histogram",
                value=data["histogram"],
            )
        if data.get("audio") is not None:
            data["audio"] = parser.get_dict(
                key="audio",
                value=data["audio"],
            )
        if data.get("video") is not None:
            data["video"] = parser.get_dict(
                key="video",
                value=data["video"],
            )
        if data.get("chart") is not None:
            data["chart"] = parser.get_dict(
                key="chart",
                value=data["chart"],
            )
        if data.get("curve") is not None:
            data["curve"] = parser.get_dict(
                key="curve",
                value=data["curve"],
            )
        if data.get("artifact") is not None:
            data["artifact"] = parser.get_dict(
                key="artifact",
                value=data["artifact"],
            )
        if data.get("model") is not None:
            data["model"] = parser.get_dict(
                key="model",
                value=data["model"],
            )
        if data.get("dataframe") is not None:
            data["dataframe"] = parser.get_dict(
                key="dataframe",
                value=data["dataframe"],
            )

        return data
示例#3
0
    def _get_config(cls) -> ConfigType:
        """Getting config to execute an action.

        Currently we get config from env vars.

        should be a list of urls and potentially a method.

        If no method is given, then by default we use POST.
        """
        value = os.environ.get(cls.config_key)
        if not value:
            raise PolyaxonNotificationException(
                "Could not validate config for notifier {}".format(cls.name))

        return parser.get_dict(key=cls.config_key, value=value, is_list=True)