Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
net-cscience-raphael committed Dec 12, 2023
2 parents 20cd60a + 87e39eb commit b8c3a07
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 38 deletions.
105 changes: 99 additions & 6 deletions vitrivr-engine-server/doc/oas.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"openapi" : "3.0.3",
"info" : {
"title" : "vitrivr engine API",
"description" : "API for the vitrivr engine.",
"version" : "1.0.0"
"version" : "1.0.0",
"description" : "API for the vitrivr engine."
},
"paths" : {
"/api/schema/list" : {
Expand Down Expand Up @@ -91,7 +91,7 @@
"content" : {
"application/json" : {
"schema" : {
"type" : "object"
"$ref" : "#/components/schemas/IngestStatus"
}
}
}
Expand All @@ -111,7 +111,7 @@
"security" : [ ]
}
},
"/api/{schema}/index/{id}" : {
"/api/{schema}/index/{jobId}" : {
"get" : {
"tags" : [ "Ingest" ],
"summary" : "Indexes an item, adding it to the defined schema.",
Expand All @@ -127,7 +127,7 @@
"type" : "string"
}
}, {
"name" : "id",
"name" : "jobId",
"in" : "path",
"description" : "The id querying the state.",
"required" : true,
Expand All @@ -143,7 +143,7 @@
"content" : {
"application/json" : {
"schema" : {
"type" : "object"
"$ref" : "#/components/schemas/IngestStatus"
}
}
}
Expand Down Expand Up @@ -179,6 +179,16 @@
"type" : "string"
}
} ],
"requestBody" : {
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/InformationNeedDescription"
}
}
},
"required" : false
},
"responses" : {
"200" : {
"description" : "OK",
Expand Down Expand Up @@ -208,6 +218,72 @@
},
"components" : {
"schemas" : {
"ExecutionStatus" : {
"type" : "string",
"enum" : [ "UNKNOWN", "RUNNING", "FAILED", "COMPLETED" ]
},
"QueryContext" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"property" : {
"type" : "string"
}
}
},
"InformationNeedDescription" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"inputs" : {
"type" : "object",
"additionalProperties" : {
"$ref" : "#/components/schemas/InputData"
}
},
"operations" : {
"type" : "object",
"additionalProperties" : {
"$ref" : "#/components/schemas/OperatorDescription"
}
},
"output" : {
"type" : "string"
},
"context" : {
"$ref" : "#/components/schemas/QueryContext"
}
},
"required" : [ "inputs", "operations", "output", "context" ]
},
"InputData" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"type" : {
"$ref" : "#/components/schemas/InputType"
}
},
"required" : [ "type" ]
},
"InputType" : {
"type" : "string",
"enum" : [ "TEXT", "IMAGE", "VECTOR", "ID" ]
},
"OperatorDescription" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"type" : {
"$ref" : "#/components/schemas/OperatorType"
}
},
"required" : [ "type" ]
},
"OperatorType" : {
"type" : "string",
"enum" : [ "RETRIEVER", "TRANSFORMER", "AGGREGATOR" ]
},
"QueryResult" : {
"type" : "object",
"additionalProperties" : false,
Expand Down Expand Up @@ -253,6 +329,23 @@
}
},
"required" : [ "message" ]
},
"IngestStatus" : {
"type" : "object",
"additionalProperties" : false,
"properties" : {
"jobId" : {
"type" : "string"
},
"executionStatus" : {
"$ref" : "#/components/schemas/ExecutionStatus"
},
"timestamp" : {
"type" : "integer",
"format" : "int64"
}
},
"required" : [ "jobId", "executionStatus", "timestamp" ]
}
},
"securitySchemes" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import io.javalin.openapi.plugin.OpenApiPluginConfiguration
import io.javalin.openapi.plugin.SecurityComponentConfiguration
import io.javalin.openapi.plugin.swagger.SwaggerConfiguration
import io.javalin.openapi.plugin.swagger.SwaggerPlugin
import io.javalin.plugin.bundled.CorsPlugin
import io.javalin.plugin.bundled.CorsPluginConfig
import org.vitrivr.engine.core.config.pipeline.execution.ExecutionServer
import org.vitrivr.engine.core.model.metamodel.SchemaManager
import org.vitrivr.engine.query.execution.RetrievalRuntime
Expand Down Expand Up @@ -48,6 +50,7 @@ fun main(args: Array<String>) {
val javalin = Javalin.create { c ->
c.jsonMapper(KotlinxJsonMapper)


/* Registers Open API plugin. */
c.plugins.register(
OpenApiPlugin(
Expand All @@ -67,6 +70,9 @@ fun main(args: Array<String>) {
)
c.http.maxRequestSize = 1024 * 1024 * 1024 /* 1GB */

c.plugins.enableCors { u -> u.add(CorsPluginConfig::anyHost) }


/* Registers Swagger Plugin. */
c.plugins.register(
SwaggerPlugin(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.vitrivr.engine.server.api.rest.model.ErrorStatusException
pathParams = [
OpenApiParam("schema", type = String::class, description = "The name of the schema to execute a query for.", required = true)
],
requestBody = OpenApiRequestBody([OpenApiContent(InformationNeedDescription::class)]),
responses = [
OpenApiResponse("200", [OpenApiContent(QueryResult::class)]),
OpenApiResponse("400", [OpenApiContent(ErrorStatus::class)])
Expand All @@ -37,35 +38,4 @@ fun executeQuery(ctx: Context, schema: Schema, runtime: RetrievalRuntime) {
}
val results = runtime.query(schema, informationNeed)
ctx.json(QueryResult(results))
}

/**
*
* @author Raphael Waltenspül
* @version 1.0
@OpenApi(
path = "/api/{schema}/query",
methods = [HttpMethod.POST],
summary = "Executes a query and returns the query's results.",
operationId = "postExecuteQuery",
tags = ["Retrieval"],
pathParams = [
OpenApiParam("schema", type = String::class, description = "The name of the schema to execute a query for.", required = true),
OpenApiParam("pipeline", type = String::class, description = "The name of the pipeline provided by the schema.", required = false)
],
responses = [
OpenApiResponse("200", [OpenApiContent(QueryResult::class)]),
OpenApiResponse("400", [OpenApiContent(ErrorStatus::class)])
]
)
fun executeQuery(ctx: Context, schema: Schema, pipeline: Pipeline, runtime: RetrievalRuntime) {
val informationNeed = try {
ctx.bodyAsClass<PipelineInformationNeedDescription>()
} catch (e: Exception) {
throw ErrorStatusException(400, "Invalid request: ${e.message}")
}
val results = runtime.query(schema, informationNeed)
ctx.json(QueryResult(results))
}
*/
}

0 comments on commit b8c3a07

Please sign in to comment.