示例#1
0
    def ApplyFeatureSet(self, request: ApplyFeatureSetRequest, context):
        feature_set = request.feature_set

        if feature_set.spec.source.type == SourceTypeProto.INVALID:
            feature_set.spec.source.kafka_source_config.CopyFrom(
                KafkaSourceConfigProto(bootstrap_servers="server.com",
                                       topic="topic1"))
            feature_set.spec.source.type = SourceTypeProto.KAFKA

        feature_set_meta = FeatureSetMeta(
            status=FeatureSetStatus.STATUS_READY,
            created_timestamp=Timestamp(seconds=10),
        )
        applied_feature_set = FeatureSetProto(spec=feature_set.spec,
                                              meta=feature_set_meta)
        self._feature_sets[feature_set.spec.name] = applied_feature_set

        _logger.info("registered feature set " + feature_set.spec.name +
                     " with " + str(len(feature_set.spec.entities)) +
                     " entities and " + str(len(feature_set.spec.features)) +
                     " features")

        return ApplyFeatureSetResponse(
            feature_set=applied_feature_set,
            status=ApplyFeatureSetResponse.Status.CREATED,
        )
示例#2
0
    def ApplyFeatureSet(self, request: ApplyFeatureSetRequest, context):
        feature_set = request.feature_set

        if feature_set.version is None:
            feature_set.version = 1
        else:
            feature_set.version = feature_set.version + 1

        if feature_set.source.type == SourceTypeProto.INVALID:
            feature_set.source.kafka_source_config.CopyFrom(
                KafkaSourceConfigProto(bootstrap_servers="server.com", topic="topic1")
            )
            feature_set.source.type = SourceTypeProto.KAFKA

        self._feature_sets[feature_set.name] = feature_set

        _logger.info(
            "registered feature set "
            + feature_set.name
            + " with "
            + str(len(feature_set.entities))
            + " entities and "
            + str(len(feature_set.features))
            + " features"
        )

        return ApplyFeatureSetResponse(
            feature_set=feature_set, status=ApplyFeatureSetResponse.Status.CREATED
        )