From 267e8b46aec7d6a3f2d83f2961e9966df4cc67fc Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 15 Oct 2024 15:15:53 +0200 Subject: [PATCH] refactors --- example-configs/ingestion/dense/dense.json | 2 +- example-configs/ingestion/example/video.json | 97 ++++++++++++------- example-configs/schema/dense.json | 3 + example-configs/schema/example.json | 39 ++------ settings.gradle | 2 +- .../IngestionPipelineBuilderPrintExtension.kt | 18 ++++ .../kotlin/org/vitrivr/engine/server/Main.kt | 15 +-- 7 files changed, 101 insertions(+), 75 deletions(-) create mode 100644 vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/util/extension/IngestionPipelineBuilderPrintExtension.kt diff --git a/example-configs/ingestion/dense/dense.json b/example-configs/ingestion/dense/dense.json index 0b1c701ef..72caaa440 100644 --- a/example-configs/ingestion/dense/dense.json +++ b/example-configs/ingestion/dense/dense.json @@ -8,7 +8,7 @@ "path": "../cache" }, "enumerator": { - "path": "../objects_dense",, + "path": "../objects_dense", "depth": "5" }, "selector":{ diff --git a/example-configs/ingestion/example/video.json b/example-configs/ingestion/example/video.json index aa897417f..fa8ce60c9 100644 --- a/example-configs/ingestion/example/video.json +++ b/example-configs/ingestion/example/video.json @@ -1,15 +1,39 @@ { "schema": "example", "context": { - "contentFactory": "InMemoryContentFactory", + "contentFactory": "CachedContentFactory", "resolverName":"disk", + "local": { + "clip": { + "contentSources": "selector" + }, + "averagecolor": { + "contentSources": "selector" + }, + "content": { + "path": "../cache" + }, + "thumbnail": { + "contentSources": "selector", + "maxSideResolution": "400", + "mimeType": "JPG" + }, + "selector":{ + "contentSources": "decoder" + }, "enumerator": { - "path": "./example/media/", + "path": "D:\\v3c", "depth": "3" }, + "decoder": { + "timeWindowMs": "6000" + }, "filter": { - "type": "SOURCE:IMAGE" + "type": "SOURCE:VIDEO" + }, + "path": { + "field": "file" } } }, @@ -17,39 +41,39 @@ "enumerator": { "type": "ENUMERATOR", "factory": "FileSystemEnumerator", - "mediaTypes": ["IMAGE"] + "mediaTypes": ["VIDEO"] }, "decoder": { "type": "DECODER", - "factory": "ImageDecoder" + "factory": "VideoDecoder" }, - "averagecolor": { + "metadata":{ "type": "EXTRACTOR", - "fieldName": "averagecolor" + "fieldName": "video" }, - "clip": { + "source":{ "type": "EXTRACTOR", - "fieldName": "clip" + "fieldName": "file" }, - "dino": { - "type": "EXTRACTOR", - "fieldName": "dino" + "path": { + "type": "TRANSFORMER", + "factory":"DescriptorAsContentTransformer" }, - "ocr": { - "type": "EXTRACTOR", - "fieldName": "ocr" + "selector": { + "type": "TRANSFORMER", + "factory": "LastContentAggregator" }, - "meta-file": { + "time": { "type": "EXTRACTOR", - "fieldName": "file" + "fieldName": "time" }, - "meta-video": { + "averagecolor": { "type": "EXTRACTOR", - "fieldName": "video" + "fieldName": "averagecolor" }, - "meta-time": { + "clip": { "type": "EXTRACTOR", - "fieldName": "time" + "fieldName": "clip" }, "thumbnail": { "type": "EXPORTER", @@ -61,22 +85,23 @@ } }, "operations": { - "stage-0-0": {"operator": "enumerator"}, - "stage-1-0": {"operator": "decoder","inputs": ["stage-0-0"]}, - "stage-2-0": {"operator": "clip","inputs": ["stage-1-0"]}, - "stage-2-1": {"operator": "dino","inputs": ["stage-1-0"]}, - "stage-2-2": {"operator": "ocr","inputs": ["stage-1-0"]}, - "stage-2-3": {"operator": "averagecolor","inputs": ["stage-1-0"]}, - "stage-2-4": {"operator": "thumbnail","inputs": ["stage-1-0"]}, - "stage-3-0": {"operator": "filter","inputs": ["stage-2-3","stage-2-4"], "merge": "COMBINE"}, - "stage-4-0": {"operator": "meta-file", "inputs": ["stage-3-0"]} + "enumerator": {"operator": "enumerator"}, + "decoder": {"operator": "decoder", "inputs": ["enumerator"]}, + "path": {"operator": "path", "inputs": ["decoder"]}, + "metadata": {"operator": "metadata", "inputs": ["path"], "merge": "COMBINE"}, + + "source": {"operator": "source", "inputs": ["metadata"]}, + + "time": {"operator": "time", "inputs": ["source"]}, + "selector": {"operator": "selector", "inputs": ["time"]}, + + "thumbnail": {"operator": "thumbnail", "inputs": ["selector"]}, + + "clip": {"operator": "clip", "inputs": ["thumbnail"]}, + "filter": {"operator": "filter","inputs": ["clip"],"merge": "MERGE"} }, "output": [ - "stage-2-0", - "stage-2-1", - "stage-2-2", - "stage-2-3", - "stage-4-0" + "filter" ], - "mergeType": "COMBINE" + "mergeType": "MERGE" } \ No newline at end of file diff --git a/example-configs/schema/dense.json b/example-configs/schema/dense.json index 1acc27c67..99705ee51 100644 --- a/example-configs/schema/dense.json +++ b/example-configs/schema/dense.json @@ -11,6 +11,9 @@ } }, "fields": { + "imageFilePathContent": { + "field": "file" + }, "averagecolor": { "factory": "AverageColor" }, diff --git a/example-configs/schema/example.json b/example-configs/schema/example.json index c23fff8cc..1c2243388 100644 --- a/example-configs/schema/example.json +++ b/example-configs/schema/example.json @@ -2,10 +2,12 @@ "schemas": { "example": { "connection": { - "database": "CottontailConnectionProvider", + "database": "PgVectorConnectionProvider", "parameters": { "Host": "127.0.0.1", - "port": "1865" + "port": "5432", + "username": "postgres", + "password": "vitrivr" } }, "fields": { @@ -18,31 +20,11 @@ "clip": { "factory": "DenseEmbedding", "parameters": { - "host": "http://127.0.0.1:8888", + "host": "http://10.34.64.84:8888/", "model": "open-clip-vit-b32", - "length": "512" - } - }, - "dino": { - "factory": "DenseEmbedding", - "parameters": { - "host": "http://127.0.0.1:8888/", - "model": "dino-v2-vits14", - "length": "384" - } - }, - "whisper": { - "factory": "ASR", - "parameters": { - "host": "http://127.0.0.1:8888/", - "model": "whisper" - } - }, - "ocr": { - "factory": "OCR", - "parameters": { - "host": "http://127.0.0.1:8888/", - "model": "tesseract" + "length": "512", + "timeoutSeconds": "100", + "retries": "1000" } }, "time": { @@ -72,10 +54,7 @@ }, "extractionPipelines": { "video": { - "path": "./example/video.json" - }, - "image": { - "path": "./example/image.json" + "path": "./example-configs/ingestion/example/video.json" } } } diff --git a/settings.gradle b/settings.gradle index e2de8b7ea..4b1959bd9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,5 @@ plugins { - id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0' + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0' } rootProject.name = 'vitrivr-engine' diff --git a/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/util/extension/IngestionPipelineBuilderPrintExtension.kt b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/util/extension/IngestionPipelineBuilderPrintExtension.kt new file mode 100644 index 000000000..be911ecd8 --- /dev/null +++ b/vitrivr-engine-core/src/main/kotlin/org/vitrivr/engine/core/util/extension/IngestionPipelineBuilderPrintExtension.kt @@ -0,0 +1,18 @@ +package org.vitrivr.engine.core.util.extension + +import org.vitrivr.engine.core.config.ingest.IngestionPipelineBuilder +import org.vitrivr.engine.core.model.retrievable.Retrievable +import org.vitrivr.engine.core.operators.Operator + +public enum class Flavor { + MERMAID +} + +fun IngestionPipelineBuilder.build(flavor: Flavor) : List> { + val nodes = this.build() + nodes.forEach { + it.input + + } + return nodes +} \ No newline at end of file diff --git a/vitrivr-engine-server/src/main/kotlin/org/vitrivr/engine/server/Main.kt b/vitrivr-engine-server/src/main/kotlin/org/vitrivr/engine/server/Main.kt index 6af233582..e2e29e114 100644 --- a/vitrivr-engine-server/src/main/kotlin/org/vitrivr/engine/server/Main.kt +++ b/vitrivr-engine-server/src/main/kotlin/org/vitrivr/engine/server/Main.kt @@ -44,13 +44,14 @@ fun main(args: Array) { c.jsonMapper(KotlinxJsonMapper) /* Registers Open API plugin. */ - c.registerPlugin(OpenApiPlugin{ + c.registerPlugin(OpenApiPlugin { it.withDocumentationPath("/openapi.json") - .withDefinitionConfiguration{ _, def -> - def.withInfo{i -> + .withDefinitionConfiguration { _, def -> + def.withInfo { i -> i.title = "vitrivr engine API" i.version = "0.1.0" - i.description = "Rest API for the vitrivr engine project. Provides query (runtime) and extraction (ingestion) endpoints" + i.description = + "Rest API for the vitrivr engine project. Provides query (runtime) and extraction (ingestion) endpoints" } .withSecurity( SecurityComponentConfiguration().withSecurityScheme("CookieAuth", CookieAuth("SESSIONID")) @@ -59,9 +60,9 @@ fun main(args: Array) { }) c.http.maxRequestSize = 1024 * 1024 * 1024 /* 1GB */ - c.bundledPlugins.enableCors{cors -> + c.bundledPlugins.enableCors { cors -> /* https://javalin.io/plugins/cors#getting-started */ - cors.addRule{ + cors.addRule { it.reflectClientOrigin = true // might be a little too loose it.allowCredentials = true } @@ -74,7 +75,7 @@ fun main(args: Array) { swaggerConfig.uiPath = "/swagger-ui" }) - c.router.apiBuilder{ + c.router.apiBuilder { configureApiRoutes(config.api, manager, executor) } }.exception(ErrorStatusException::class.java) { e, ctx ->