From 9f1807a1282fd7c7e10974c852d43db871e1f2b6 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Tue, 20 Jan 2026 19:41:52 +0530 Subject: [PATCH] linting and fixing resources timeout and validator --- app/http.php | 18 ++++++- app/init/resources.php | 4 +- .../Databases/Collections/Indexes/Create.php | 1 - .../VectorDB/DatabasesCustomServerTest.php | 48 ++++++++++--------- 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/app/http.php b/app/http.php index 3b2c24c58e..dfc0629fab 100644 --- a/app/http.php +++ b/app/http.php @@ -386,13 +386,29 @@ $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg }); $projectCollections = $collections['projects']; + $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', '')); $sharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES_V1', '')); $sharedTablesV2 = \array_diff($sharedTables, $sharedTablesV1); + $documentsSharedTables = \explode(',', System::getEnv('_APP_DATABASE_DOCUMENTSDB_SHARED_TABLES', '')); + $documentsSharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_DOCUMENTSDB_SHARED_TABLES_V1', '')); + $documentsSharedTablesV2 = \array_diff($documentsSharedTables, $documentsSharedTablesV1); + + $vectorSharedTables = \explode(',', System::getEnv('_APP_DATABASE_VECTORDB_SHARED_TABLES', '')); + $vectorSharedTablesV1 = \explode(',', System::getEnv('_APP_DATABASE_VECTORDB_SHARED_TABLES_V1', '')); + $vectorSharedTablesV2 = \array_diff($vectorSharedTables, $vectorSharedTablesV1); + $cache = $app->getResource('cache'); - foreach ($sharedTablesV2 as $hostname) { + // All shared tables V2 pools that need project metadata collections + $sharedTablesV2All = \array_values(\array_unique(\array_filter([ + ...$sharedTablesV2, + ...$documentsSharedTablesV2, + ...$vectorSharedTablesV2, + ]))); + + foreach ($sharedTablesV2All as $hostname) { $adapter = new DatabasePool($pools->get($hostname)); $dbForProject = (new Database($adapter, $cache)) ->setDatabase('appwrite') diff --git a/app/init/resources.php b/app/init/resources.php index 52b8eb050c..769cf09bef 100644 --- a/app/init/resources.php +++ b/app/init/resources.php @@ -1541,7 +1541,7 @@ App::setResource('executionsRetentionCount', function (Document $project, array }, ['project', 'plan']); App::setResource('embeddingAgent', function ($register) { - $adapter = new Ollama(); + $adapter = new Ollama(150); $adapter->setEndpoint(System::getEnv('_APP_EMBEDDING_ENDPOINT', 'http://ollama:11434/api/embed')); return new Agent($adapter); -}, ['register']); \ No newline at end of file +}, ['register']); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php index 233d7029a3..cc02731e10 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php @@ -206,7 +206,6 @@ class Create extends Action $dbForDatabases->getAdapter()->getSupportForAttributes(), $dbForDatabases->getAdapter()->getSupportForMultipleFulltextIndexes(), $dbForDatabases->getAdapter()->getSupportForIdenticalIndexes(), - $dbForDatabases->getAdapter()->getSupportForObject(), $dbForProject->getAdapter()->getSupportForObjectIndexes(), $dbForProject->getAdapter()->getSupportForTrigramIndex(), $dbForProject->getAdapter()->getSupportForSpatialAttributes(), diff --git a/tests/e2e/Services/Databases/VectorDB/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/VectorDB/DatabasesCustomServerTest.php index 58cb48440e..2414708a27 100644 --- a/tests/e2e/Services/Databases/VectorDB/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/VectorDB/DatabasesCustomServerTest.php @@ -589,29 +589,31 @@ class DatabasesCustomServerTest extends Scope $collectionId = $col['body']['$id']; // Success: two embeddings - $ok = $this->client->call(Client::METHOD_POST, "/vectordb/embeddings/text", [ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-key' => $this->getProject()['apiKey'] - ], [ - 'model' => 'embeddinggemma', - 'texts' => [ - 'hello world', - 'second sentence', - ], - ]); - $this->assertEquals(200, $ok['headers']['status-code']); - $this->assertIsInt($ok['body']['total'] ?? 0); - $this->assertEquals(2, $ok['body']['total']); - $this->assertIsArray($ok['body']['embeddings']); - $this->assertCount(2, $ok['body']['embeddings']); - foreach ($ok['body']['embeddings'] as $embed) { - $this->assertIsString($embed['model']); - $this->assertIsInt($embed['dimension']); - $this->assertIsArray($embed['embedding']); - $this->assertGreaterThan(0, count($embed['embedding'])); - $this->assertArrayHasKey('error', $embed); - } + $this->assertEventually(function () { + $ok = $this->client->call(Client::METHOD_POST, "/vectordb/embeddings/text", [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ], [ + 'model' => 'embeddinggemma', + 'texts' => [ + 'hello world', + 'second sentence', + ], + ]); + $this->assertEquals(200, $ok['headers']['status-code']); + $this->assertIsInt($ok['body']['total'] ?? 0); + $this->assertEquals(2, $ok['body']['total']); + $this->assertIsArray($ok['body']['embeddings']); + $this->assertCount(2, $ok['body']['embeddings']); + foreach ($ok['body']['embeddings'] as $embed) { + $this->assertIsString($embed['model']); + $this->assertIsInt($embed['dimension']); + $this->assertIsArray($embed['embedding']); + $this->assertGreaterThan(0, count($embed['embedding'])); + $this->assertArrayHasKey('error', $embed); + } + }, 3000, 100); // Error: missing texts payload $missingTexts = $this->client->call(Client::METHOD_POST, "/vectordb/embeddings/text", [