From 05c0d4e4be6d85edacce8e0de4a1a0b1fe5aa4bd Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Wed, 17 Jul 2024 21:50:52 +0000 Subject: [PATCH] feat(api): update via SDK Studio --- .stats.yml | 2 +- .../InferencePipelineRowStreamParams.kt | 462 ++++++++++++++++++ .../InferencePipelineRowStreamResponse.kt | 160 ++++++ .../async/InferencePipelineServiceAsync.kt | 3 + .../InferencePipelineServiceAsyncImpl.kt | 6 + .../inferencePipelines/RowServiceAsync.kt | 20 + .../inferencePipelines/RowServiceAsyncImpl.kt | 56 +++ .../blocking/InferencePipelineService.kt | 3 + .../blocking/InferencePipelineServiceImpl.kt | 6 + .../blocking/inferencePipelines/RowService.kt | 19 + .../inferencePipelines/RowServiceImpl.kt | 54 ++ .../InferencePipelineRowStreamParamsTest.kt | 124 +++++ .../InferencePipelineRowStreamResponseTest.kt | 20 + .../inferencePipelines/RowServiceTest.kt | 43 ++ 14 files changed, 977 insertions(+), 1 deletion(-) create mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowStreamParams.kt create mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowStreamResponse.kt create mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsync.kt create mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsyncImpl.kt create mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowService.kt create mode 100644 openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceImpl.kt create mode 100644 openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowStreamParamsTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowStreamResponseTest.kt create mode 100644 openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 699660e..de47912 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 8 +configured_endpoints: 9 diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowStreamParams.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowStreamParams.kt new file mode 100644 index 0000000..64b926d --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowStreamParams.kt @@ -0,0 +1,462 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.toUnmodifiable +import com.openlayer.api.models.* +import java.util.Objects +import java.util.Optional + +class InferencePipelineRowStreamParams +constructor( + private val inferencePipelineId: String, + private val inferenceId: String, + private val row: JsonValue, + private val config: Config?, + private val additionalQueryParams: Map>, + private val additionalHeaders: Map>, + private val additionalBodyProperties: Map, +) { + + fun inferencePipelineId(): String = inferencePipelineId + + fun inferenceId(): String = inferenceId + + fun row(): JsonValue = row + + fun config(): Optional = Optional.ofNullable(config) + + @JvmSynthetic + internal fun getBody(): InferencePipelineRowStreamBody { + return InferencePipelineRowStreamBody( + row, + config, + additionalBodyProperties, + ) + } + + @JvmSynthetic + internal fun getQueryParams(): Map> { + val params = mutableMapOf>() + this.inferenceId.let { params.put("inferenceId", listOf(it.toString())) } + params.putAll(additionalQueryParams) + return params.toUnmodifiable() + } + + @JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> inferencePipelineId + else -> "" + } + } + + @JsonDeserialize(builder = InferencePipelineRowStreamBody.Builder::class) + @NoAutoDetect + class InferencePipelineRowStreamBody + internal constructor( + private val row: JsonValue?, + private val config: Config?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + @JsonProperty("row") fun row(): JsonValue? = row + + @JsonProperty("config") fun config(): Config? = config + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineRowStreamBody && + this.row == other.row && + this.config == other.config && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + row, + config, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "InferencePipelineRowStreamBody{row=$row, config=$config, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var row: JsonValue? = null + private var config: Config? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineRowStreamBody: InferencePipelineRowStreamBody) = + apply { + this.row = inferencePipelineRowStreamBody.row + this.config = inferencePipelineRowStreamBody.config + additionalProperties(inferencePipelineRowStreamBody.additionalProperties) + } + + @JsonProperty("row") fun row(row: JsonValue) = apply { this.row = row } + + @JsonProperty("config") fun config(config: Config) = apply { this.config = config } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): InferencePipelineRowStreamBody = + InferencePipelineRowStreamBody( + checkNotNull(row) { "`row` is required but was not set" }, + config, + additionalProperties.toUnmodifiable(), + ) + } + } + + fun _additionalQueryParams(): Map> = additionalQueryParams + + fun _additionalHeaders(): Map> = additionalHeaders + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineRowStreamParams && + this.inferencePipelineId == other.inferencePipelineId && + this.row == other.row && + this.config == other.config && + this.inferenceId == other.inferenceId && + this.additionalQueryParams == other.additionalQueryParams && + this.additionalHeaders == other.additionalHeaders && + this.additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int { + return Objects.hash( + inferencePipelineId, + row, + config, + inferenceId, + additionalQueryParams, + additionalHeaders, + additionalBodyProperties, + ) + } + + override fun toString() = + "InferencePipelineRowStreamParams{inferencePipelineId=$inferencePipelineId, row=$row, config=$config, inferenceId=$inferenceId, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}" + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var inferencePipelineId: String? = null + private var inferenceId: String? = null + private var row: JsonValue? = null + private var config: Config? = null + private var additionalQueryParams: MutableMap> = mutableMapOf() + private var additionalHeaders: MutableMap> = mutableMapOf() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineRowStreamParams: InferencePipelineRowStreamParams) = + apply { + this.inferencePipelineId = inferencePipelineRowStreamParams.inferencePipelineId + this.inferenceId = inferencePipelineRowStreamParams.inferenceId + this.row = inferencePipelineRowStreamParams.row + this.config = inferencePipelineRowStreamParams.config + additionalQueryParams(inferencePipelineRowStreamParams.additionalQueryParams) + additionalHeaders(inferencePipelineRowStreamParams.additionalHeaders) + additionalBodyProperties(inferencePipelineRowStreamParams.additionalBodyProperties) + } + + fun inferencePipelineId(inferencePipelineId: String) = apply { + this.inferencePipelineId = inferencePipelineId + } + + /** Specify the inference id as a query param. */ + fun inferenceId(inferenceId: String) = apply { this.inferenceId = inferenceId } + + fun row(row: JsonValue) = apply { this.row = row } + + fun config(config: Config) = apply { this.config = config } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllQueryParams(additionalQueryParams) + } + + fun putQueryParam(name: String, value: String) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putQueryParams(name: String, values: Iterable) = apply { + this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllQueryParams(additionalQueryParams: Map>) = apply { + additionalQueryParams.forEach(this::putQueryParams) + } + + fun removeQueryParam(name: String) = apply { + this.additionalQueryParams.put(name, mutableListOf()) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllHeaders(additionalHeaders) + } + + fun putHeader(name: String, value: String) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value) + } + + fun putHeaders(name: String, values: Iterable) = apply { + this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values) + } + + fun putAllHeaders(additionalHeaders: Map>) = apply { + additionalHeaders.forEach(this::putHeaders) + } + + fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + this.additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun build(): InferencePipelineRowStreamParams = + InferencePipelineRowStreamParams( + checkNotNull(inferencePipelineId) { + "`inferencePipelineId` is required but was not set" + }, + checkNotNull(inferenceId) { "`inferenceId` is required but was not set" }, + checkNotNull(row) { "`row` is required but was not set" }, + config, + additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(), + additionalBodyProperties.toUnmodifiable(), + ) + } + + @JsonDeserialize(builder = Config.Builder::class) + @NoAutoDetect + class Config + private constructor( + private val inferenceIdColumnName: String?, + private val latencyColumnName: String?, + private val timestampColumnName: String?, + private val groundTruthColumnName: String?, + private val humanFeedbackColumnName: String?, + private val additionalProperties: Map, + ) { + + private var hashCode: Int = 0 + + /** + * Name of the column with the inference ids. This is useful if you want to update rows at a + * later point in time. If not provided, a unique id is generated by Openlayer. + */ + @JsonProperty("inferenceIdColumnName") + fun inferenceIdColumnName(): String? = inferenceIdColumnName + + /** Name of the column with the latencies. */ + @JsonProperty("latencyColumnName") fun latencyColumnName(): String? = latencyColumnName + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not + * provided, the upload timestamp is used. + */ + @JsonProperty("timestampColumnName") + fun timestampColumnName(): String? = timestampColumnName + + /** Name of the column with the ground truths. */ + @JsonProperty("groundTruthColumnName") + fun groundTruthColumnName(): String? = groundTruthColumnName + + /** Name of the column with human feedback. */ + @JsonProperty("humanFeedbackColumnName") + fun humanFeedbackColumnName(): String? = humanFeedbackColumnName + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && + this.inferenceIdColumnName == other.inferenceIdColumnName && + this.latencyColumnName == other.latencyColumnName && + this.timestampColumnName == other.timestampColumnName && + this.groundTruthColumnName == other.groundTruthColumnName && + this.humanFeedbackColumnName == other.humanFeedbackColumnName && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = + Objects.hash( + inferenceIdColumnName, + latencyColumnName, + timestampColumnName, + groundTruthColumnName, + humanFeedbackColumnName, + additionalProperties, + ) + } + return hashCode + } + + override fun toString() = + "Config{inferenceIdColumnName=$inferenceIdColumnName, latencyColumnName=$latencyColumnName, timestampColumnName=$timestampColumnName, groundTruthColumnName=$groundTruthColumnName, humanFeedbackColumnName=$humanFeedbackColumnName, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var inferenceIdColumnName: String? = null + private var latencyColumnName: String? = null + private var timestampColumnName: String? = null + private var groundTruthColumnName: String? = null + private var humanFeedbackColumnName: String? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + this.inferenceIdColumnName = config.inferenceIdColumnName + this.latencyColumnName = config.latencyColumnName + this.timestampColumnName = config.timestampColumnName + this.groundTruthColumnName = config.groundTruthColumnName + this.humanFeedbackColumnName = config.humanFeedbackColumnName + additionalProperties(config.additionalProperties) + } + + /** + * Name of the column with the inference ids. This is useful if you want to update rows + * at a later point in time. If not provided, a unique id is generated by Openlayer. + */ + @JsonProperty("inferenceIdColumnName") + fun inferenceIdColumnName(inferenceIdColumnName: String) = apply { + this.inferenceIdColumnName = inferenceIdColumnName + } + + /** Name of the column with the latencies. */ + @JsonProperty("latencyColumnName") + fun latencyColumnName(latencyColumnName: String) = apply { + this.latencyColumnName = latencyColumnName + } + + /** + * Name of the column with the timestamps. Timestamps must be in UNIX sec format. If not + * provided, the upload timestamp is used. + */ + @JsonProperty("timestampColumnName") + fun timestampColumnName(timestampColumnName: String) = apply { + this.timestampColumnName = timestampColumnName + } + + /** Name of the column with the ground truths. */ + @JsonProperty("groundTruthColumnName") + fun groundTruthColumnName(groundTruthColumnName: String) = apply { + this.groundTruthColumnName = groundTruthColumnName + } + + /** Name of the column with human feedback. */ + @JsonProperty("humanFeedbackColumnName") + fun humanFeedbackColumnName(humanFeedbackColumnName: String) = apply { + this.humanFeedbackColumnName = humanFeedbackColumnName + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Config = + Config( + inferenceIdColumnName, + latencyColumnName, + timestampColumnName, + groundTruthColumnName, + humanFeedbackColumnName, + additionalProperties.toUnmodifiable(), + ) + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowStreamResponse.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowStreamResponse.kt new file mode 100644 index 0000000..c52d907 --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/models/InferencePipelineRowStreamResponse.kt @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.openlayer.api.core.Enum +import com.openlayer.api.core.ExcludeMissing +import com.openlayer.api.core.JsonField +import com.openlayer.api.core.JsonMissing +import com.openlayer.api.core.JsonValue +import com.openlayer.api.core.NoAutoDetect +import com.openlayer.api.core.toUnmodifiable +import com.openlayer.api.errors.OpenlayerInvalidDataException +import java.util.Objects + +@JsonDeserialize(builder = InferencePipelineRowStreamResponse.Builder::class) +@NoAutoDetect +class InferencePipelineRowStreamResponse +private constructor( + private val success: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + private var hashCode: Int = 0 + + fun success(): Success = success.getRequired("success") + + @JsonProperty("success") @ExcludeMissing fun _success() = success + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): InferencePipelineRowStreamResponse = apply { + if (!validated) { + success() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InferencePipelineRowStreamResponse && + this.success == other.success && + this.additionalProperties == other.additionalProperties + } + + override fun hashCode(): Int { + if (hashCode == 0) { + hashCode = Objects.hash(success, additionalProperties) + } + return hashCode + } + + override fun toString() = + "InferencePipelineRowStreamResponse{success=$success, additionalProperties=$additionalProperties}" + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var success: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inferencePipelineRowStreamResponse: InferencePipelineRowStreamResponse) = + apply { + this.success = inferencePipelineRowStreamResponse.success + additionalProperties(inferencePipelineRowStreamResponse.additionalProperties) + } + + fun success(success: Success) = success(JsonField.of(success)) + + @JsonProperty("success") + @ExcludeMissing + fun success(success: JsonField) = apply { this.success = success } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): InferencePipelineRowStreamResponse = + InferencePipelineRowStreamResponse(success, additionalProperties.toUnmodifiable()) + } + + class Success + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Success && this.value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + + companion object { + + @JvmField val TRUE = Success(JsonField.of(true)) + + @JvmStatic fun of(value: Boolean) = Success(JsonField.of(value)) + } + + enum class Known { + TRUE, + } + + enum class Value { + TRUE, + _UNKNOWN, + } + + fun value(): Value = + when (this) { + TRUE -> Value.TRUE + else -> Value._UNKNOWN + } + + fun known(): Known = + when (this) { + TRUE -> Known.TRUE + else -> throw OpenlayerInvalidDataException("Unknown Success: $value") + } + + fun asString(): String = _value().asStringOrThrow() + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt index dd1d4d5..b4419d4 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsync.kt @@ -5,11 +5,14 @@ package com.openlayer.api.services.async import com.openlayer.api.services.async.inferencePipelines.DataServiceAsync +import com.openlayer.api.services.async.inferencePipelines.RowServiceAsync import com.openlayer.api.services.async.inferencePipelines.TestResultServiceAsync interface InferencePipelineServiceAsync { fun data(): DataServiceAsync + fun rows(): RowServiceAsync + fun testResults(): TestResultServiceAsync } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt index f2e5c2f..5518aff 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/InferencePipelineServiceAsyncImpl.kt @@ -7,6 +7,8 @@ import com.openlayer.api.core.http.HttpResponse.Handler import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.services.async.inferencePipelines.DataServiceAsync import com.openlayer.api.services.async.inferencePipelines.DataServiceAsyncImpl +import com.openlayer.api.services.async.inferencePipelines.RowServiceAsync +import com.openlayer.api.services.async.inferencePipelines.RowServiceAsyncImpl import com.openlayer.api.services.async.inferencePipelines.TestResultServiceAsync import com.openlayer.api.services.async.inferencePipelines.TestResultServiceAsyncImpl import com.openlayer.api.services.errorHandler @@ -20,11 +22,15 @@ constructor( private val data: DataServiceAsync by lazy { DataServiceAsyncImpl(clientOptions) } + private val rows: RowServiceAsync by lazy { RowServiceAsyncImpl(clientOptions) } + private val testResults: TestResultServiceAsync by lazy { TestResultServiceAsyncImpl(clientOptions) } override fun data(): DataServiceAsync = data + override fun rows(): RowServiceAsync = rows + override fun testResults(): TestResultServiceAsync = testResults } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsync.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsync.kt new file mode 100644 index 0000000..ce9b54b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsync.kt @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.openlayer.api.services.async.inferencePipelines + +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.models.InferencePipelineRowStreamParams +import com.openlayer.api.models.InferencePipelineRowStreamResponse +import java.util.concurrent.CompletableFuture + +interface RowServiceAsync { + + /** Update an inference data point in an inference pipeline. */ + @JvmOverloads + fun stream( + params: InferencePipelineRowStreamParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsyncImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsyncImpl.kt new file mode 100644 index 0000000..b13033e --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/async/inferencePipelines/RowServiceAsyncImpl.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.async.inferencePipelines + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.errors.OpenlayerError +import com.openlayer.api.models.InferencePipelineRowStreamParams +import com.openlayer.api.models.InferencePipelineRowStreamResponse +import com.openlayer.api.services.errorHandler +import com.openlayer.api.services.json +import com.openlayer.api.services.jsonHandler +import com.openlayer.api.services.withErrorHandler +import java.util.concurrent.CompletableFuture + +class RowServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : RowServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val streamHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Update an inference data point in an inference pipeline. */ + override fun stream( + params: InferencePipelineRowStreamParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("inference-pipelines", params.getPathParam(0), "rows") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { streamHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt index 161248f..157d71f 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineService.kt @@ -5,11 +5,14 @@ package com.openlayer.api.services.blocking import com.openlayer.api.services.blocking.inferencePipelines.DataService +import com.openlayer.api.services.blocking.inferencePipelines.RowService import com.openlayer.api.services.blocking.inferencePipelines.TestResultService interface InferencePipelineService { fun data(): DataService + fun rows(): RowService + fun testResults(): TestResultService } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt index e83ed60..2267d4a 100644 --- a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/InferencePipelineServiceImpl.kt @@ -7,6 +7,8 @@ import com.openlayer.api.core.http.HttpResponse.Handler import com.openlayer.api.errors.OpenlayerError import com.openlayer.api.services.blocking.inferencePipelines.DataService import com.openlayer.api.services.blocking.inferencePipelines.DataServiceImpl +import com.openlayer.api.services.blocking.inferencePipelines.RowService +import com.openlayer.api.services.blocking.inferencePipelines.RowServiceImpl import com.openlayer.api.services.blocking.inferencePipelines.TestResultService import com.openlayer.api.services.blocking.inferencePipelines.TestResultServiceImpl import com.openlayer.api.services.errorHandler @@ -20,9 +22,13 @@ constructor( private val data: DataService by lazy { DataServiceImpl(clientOptions) } + private val rows: RowService by lazy { RowServiceImpl(clientOptions) } + private val testResults: TestResultService by lazy { TestResultServiceImpl(clientOptions) } override fun data(): DataService = data + override fun rows(): RowService = rows + override fun testResults(): TestResultService = testResults } diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowService.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowService.kt new file mode 100644 index 0000000..68e608b --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowService.kt @@ -0,0 +1,19 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.openlayer.api.services.blocking.inferencePipelines + +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.models.InferencePipelineRowStreamParams +import com.openlayer.api.models.InferencePipelineRowStreamResponse + +interface RowService { + + /** Update an inference data point in an inference pipeline. */ + @JvmOverloads + fun stream( + params: InferencePipelineRowStreamParams, + requestOptions: RequestOptions = RequestOptions.none() + ): InferencePipelineRowStreamResponse +} diff --git a/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceImpl.kt b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceImpl.kt new file mode 100644 index 0000000..09c5c4f --- /dev/null +++ b/openlayer-java-core/src/main/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceImpl.kt @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.inferencePipelines + +import com.openlayer.api.core.ClientOptions +import com.openlayer.api.core.RequestOptions +import com.openlayer.api.core.http.HttpMethod +import com.openlayer.api.core.http.HttpRequest +import com.openlayer.api.core.http.HttpResponse.Handler +import com.openlayer.api.errors.OpenlayerError +import com.openlayer.api.models.InferencePipelineRowStreamParams +import com.openlayer.api.models.InferencePipelineRowStreamResponse +import com.openlayer.api.services.errorHandler +import com.openlayer.api.services.json +import com.openlayer.api.services.jsonHandler +import com.openlayer.api.services.withErrorHandler + +class RowServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : RowService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val streamHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + .withErrorHandler(errorHandler) + + /** Update an inference data point in an inference pipeline. */ + override fun stream( + params: InferencePipelineRowStreamParams, + requestOptions: RequestOptions + ): InferencePipelineRowStreamResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .addPathSegments("inference-pipelines", params.getPathParam(0), "rows") + .putAllQueryParams(clientOptions.queryParams) + .putAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .putAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { streamHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowStreamParamsTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowStreamParamsTest.kt new file mode 100644 index 0000000..15f8668 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowStreamParamsTest.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import com.openlayer.api.core.JsonValue +import com.openlayer.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InferencePipelineRowStreamParamsTest { + + @Test + fun createInferencePipelineRowStreamParams() { + InferencePipelineRowStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .row(JsonValue.from(mapOf())) + .config( + InferencePipelineRowStreamParams.Config.builder() + .groundTruthColumnName("ground_truth") + .humanFeedbackColumnName("human_feedback") + .inferenceIdColumnName("id") + .latencyColumnName("latency") + .timestampColumnName("timestamp") + .build() + ) + .inferenceId("inferenceId") + .build() + } + + @Test + fun getQueryParams() { + val params = + InferencePipelineRowStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .row(JsonValue.from(mapOf())) + .config( + InferencePipelineRowStreamParams.Config.builder() + .groundTruthColumnName("ground_truth") + .humanFeedbackColumnName("human_feedback") + .inferenceIdColumnName("id") + .latencyColumnName("latency") + .timestampColumnName("timestamp") + .build() + ) + .inferenceId("inferenceId") + .build() + val expected = mutableMapOf>() + expected.put("inferenceId", listOf("inferenceId")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getQueryParamsWithoutOptionalFields() { + val params = + InferencePipelineRowStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .row(JsonValue.from(mapOf())) + .inferenceId("inferenceId") + .build() + val expected = mutableMapOf>() + expected.put("inferenceId", listOf("inferenceId")) + assertThat(params.getQueryParams()).isEqualTo(expected) + } + + @Test + fun getBody() { + val params = + InferencePipelineRowStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .row(JsonValue.from(mapOf())) + .config( + InferencePipelineRowStreamParams.Config.builder() + .groundTruthColumnName("ground_truth") + .humanFeedbackColumnName("human_feedback") + .inferenceIdColumnName("id") + .latencyColumnName("latency") + .timestampColumnName("timestamp") + .build() + ) + .inferenceId("inferenceId") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.row()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body.config()) + .isEqualTo( + InferencePipelineRowStreamParams.Config.builder() + .groundTruthColumnName("ground_truth") + .humanFeedbackColumnName("human_feedback") + .inferenceIdColumnName("id") + .latencyColumnName("latency") + .timestampColumnName("timestamp") + .build() + ) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + InferencePipelineRowStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .row(JsonValue.from(mapOf())) + .inferenceId("inferenceId") + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.row()).isEqualTo(JsonValue.from(mapOf())) + } + + @Test + fun getPathParam() { + val params = + InferencePipelineRowStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .row(JsonValue.from(mapOf())) + .inferenceId("inferenceId") + .build() + assertThat(params).isNotNull + // path param "inferencePipelineId" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowStreamResponseTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowStreamResponseTest.kt new file mode 100644 index 0000000..2b615a5 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/models/InferencePipelineRowStreamResponseTest.kt @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class InferencePipelineRowStreamResponseTest { + + @Test + fun createInferencePipelineRowStreamResponse() { + val inferencePipelineRowStreamResponse = + InferencePipelineRowStreamResponse.builder() + .success(InferencePipelineRowStreamResponse.Success.TRUE) + .build() + assertThat(inferencePipelineRowStreamResponse).isNotNull + assertThat(inferencePipelineRowStreamResponse.success()) + .isEqualTo(InferencePipelineRowStreamResponse.Success.TRUE) + } +} diff --git a/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceTest.kt b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceTest.kt new file mode 100644 index 0000000..bff5a32 --- /dev/null +++ b/openlayer-java-core/src/test/kotlin/com/openlayer/api/services/blocking/inferencePipelines/RowServiceTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.openlayer.api.services.blocking.inferencePipelines + +import com.openlayer.api.TestServerExtension +import com.openlayer.api.client.okhttp.OpenlayerOkHttpClient +import com.openlayer.api.core.JsonValue +import com.openlayer.api.models.* +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class RowServiceTest { + + @Test + fun callStream() { + val client = + OpenlayerOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val rowService = client.inferencePipelines().rows() + val inferencePipelineRowStreamResponse = + rowService.stream( + InferencePipelineRowStreamParams.builder() + .inferencePipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .row(JsonValue.from(mapOf())) + .config( + InferencePipelineRowStreamParams.Config.builder() + .groundTruthColumnName("ground_truth") + .humanFeedbackColumnName("human_feedback") + .inferenceIdColumnName("id") + .latencyColumnName("latency") + .timestampColumnName("timestamp") + .build() + ) + .inferenceId("inferenceId") + .build() + ) + println(inferencePipelineRowStreamResponse) + inferencePipelineRowStreamResponse.validate() + } +}