-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add task processing manager method to get the list of available task type IDs #54848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -632,6 +632,7 @@ private function getFile(string $name, string $content): File { | |
| public function testShouldNotHaveAnyProviders(): void { | ||
| $this->registrationContext->expects($this->any())->method('getTaskProcessingProviders')->willReturn([]); | ||
| self::assertCount(0, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(0, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertFalse($this->manager->hasProviders()); | ||
| self::expectException(PreConditionNotMetException::class); | ||
| $this->manager->scheduleTask(new Task(TextToText::ID, ['input' => 'Hello'], 'test', null)); | ||
|
|
@@ -647,6 +648,8 @@ public function testProviderShouldBeRegisteredAndTaskTypeDisabled(): void { | |
| $this->appConfig->setValueString('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings), lazy: true); | ||
| self::assertCount(0, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypes(true)); | ||
| self::assertCount(0, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds(true)); | ||
| self::assertTrue($this->manager->hasProviders()); | ||
| self::expectException(PreConditionNotMetException::class); | ||
| $this->manager->scheduleTask(new Task(TextToText::ID, ['input' => 'Hello'], 'test', null)); | ||
|
|
@@ -659,6 +662,7 @@ public function testProviderShouldBeRegisteredAndTaskFailValidation(): void { | |
| new ServiceRegistration('test', BrokenSyncProvider::class) | ||
| ]); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertTrue($this->manager->hasProviders()); | ||
| $task = new Task(TextToText::ID, ['wrongInputKey' => 'Hello'], 'test', null); | ||
| self::assertNull($task->getId()); | ||
|
|
@@ -680,6 +684,7 @@ public function testProviderShouldBeRegisteredAndTaskWithFilesFailValidation(): | |
| $this->userMountCache->expects($this->any())->method('getMountsForFileId')->willReturn([$mount]); | ||
|
|
||
| self::assertCount(1, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertTrue($this->manager->hasProviders()); | ||
|
|
||
| $audioId = $this->getFile('audioInput', 'Hello')->getId(); | ||
|
|
@@ -695,6 +700,7 @@ public function testProviderShouldBeRegisteredAndFail(): void { | |
| new ServiceRegistration('test', FailingSyncProvider::class) | ||
| ]); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertTrue($this->manager->hasProviders()); | ||
| $task = new Task(TextToText::ID, ['input' => 'Hello'], 'test', null); | ||
| self::assertNull($task->getId()); | ||
|
|
@@ -723,6 +729,7 @@ public function testProviderShouldBeRegisteredAndFailOutputValidation(): void { | |
| new ServiceRegistration('test', BrokenSyncProvider::class) | ||
| ]); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Woop woop, even tests! 😍 |
||
| self::assertTrue($this->manager->hasProviders()); | ||
| $task = new Task(TextToText::ID, ['input' => 'Hello'], 'test', null); | ||
| self::assertNull($task->getId()); | ||
|
|
@@ -751,6 +758,7 @@ public function testProviderShouldBeRegisteredAndRun(): void { | |
| new ServiceRegistration('test', SuccessfulSyncProvider::class) | ||
| ]); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
| $taskTypeStruct = $this->manager->getAvailableTaskTypes()[array_keys($this->manager->getAvailableTaskTypes())[0]]; | ||
| self::assertTrue(isset($taskTypeStruct['inputShape']['input'])); | ||
| self::assertEquals(EShapeType::Text, $taskTypeStruct['inputShape']['input']->getShapeType()); | ||
|
|
@@ -803,6 +811,7 @@ public function testTaskTypeExplicitlyEnabled(): void { | |
| $this->appConfig->setValueString('core', 'ai.taskprocessing_type_preferences', json_encode($taskProcessingTypeSettings), lazy: true); | ||
|
|
||
| self::assertCount(1, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
|
|
||
| self::assertTrue($this->manager->hasProviders()); | ||
| $task = new Task(TextToText::ID, ['input' => 'Hello'], 'test', null); | ||
|
|
@@ -843,6 +852,7 @@ public function testAsyncProviderWithFilesShouldBeRegisteredAndRunReturningRawFi | |
| $this->userMountCache->expects($this->any())->method('getMountsForFileId')->willReturn([$mount]); | ||
|
|
||
| self::assertCount(1, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
|
|
||
| self::assertTrue($this->manager->hasProviders()); | ||
| $audioId = $this->getFile('audioInput', 'Hello')->getId(); | ||
|
|
@@ -893,6 +903,7 @@ public function testAsyncProviderWithFilesShouldBeRegisteredAndRunReturningFileI | |
| $mount->expects($this->any())->method('getUser')->willReturn($user); | ||
| $this->userMountCache->expects($this->any())->method('getMountsForFileId')->willReturn([$mount]); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
|
|
||
| self::assertTrue($this->manager->hasProviders()); | ||
| $audioId = $this->getFile('audioInput', 'Hello')->getId(); | ||
|
|
@@ -952,6 +963,7 @@ public function testOldTasksShouldBeCleanedUp(): void { | |
| new ServiceRegistration('test', SuccessfulSyncProvider::class) | ||
| ]); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypes()); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertTrue($this->manager->hasProviders()); | ||
| $task = new Task(TextToText::ID, ['input' => 'Hello'], 'test', null); | ||
| $this->manager->scheduleTask($task); | ||
|
|
@@ -992,6 +1004,7 @@ public function testShouldTransparentlyHandleTextProcessingProviders(): void { | |
| ]); | ||
| $taskTypes = $this->manager->getAvailableTaskTypes(); | ||
| self::assertCount(1, $taskTypes); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertTrue(isset($taskTypes[TextToTextSummary::ID])); | ||
| self::assertTrue($this->manager->hasProviders()); | ||
| $task = new Task(TextToTextSummary::ID, ['input' => 'Hello'], 'test', null); | ||
|
|
@@ -1023,6 +1036,7 @@ public function testShouldTransparentlyHandleFailingTextProcessingProviders(): v | |
| ]); | ||
| $taskTypes = $this->manager->getAvailableTaskTypes(); | ||
| self::assertCount(1, $taskTypes); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertTrue(isset($taskTypes[TextToTextSummary::ID])); | ||
| self::assertTrue($this->manager->hasProviders()); | ||
| $task = new Task(TextToTextSummary::ID, ['input' => 'Hello'], 'test', null); | ||
|
|
@@ -1053,6 +1067,7 @@ public function testShouldTransparentlyHandleText2ImageProviders(): void { | |
| ]); | ||
| $taskTypes = $this->manager->getAvailableTaskTypes(); | ||
| self::assertCount(1, $taskTypes); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertTrue(isset($taskTypes[TextToImage::ID])); | ||
| self::assertTrue($this->manager->hasProviders()); | ||
| $task = new Task(TextToImage::ID, ['input' => 'Hello', 'numberOfImages' => 3], 'test', null); | ||
|
|
@@ -1089,6 +1104,7 @@ public function testShouldTransparentlyHandleFailingText2ImageProviders(): void | |
| ]); | ||
| $taskTypes = $this->manager->getAvailableTaskTypes(); | ||
| self::assertCount(1, $taskTypes); | ||
| self::assertCount(1, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertTrue(isset($taskTypes[TextToImage::ID])); | ||
| self::assertTrue($this->manager->hasProviders()); | ||
| $task = new Task(TextToImage::ID, ['input' => 'Hello', 'numberOfImages' => 3], 'test', null); | ||
|
|
@@ -1178,6 +1194,7 @@ public function testGetAvailableTaskTypesIncludesExternalViaEvent() { | |
|
|
||
| // Assert | ||
| self::assertArrayHasKey(ExternalTaskType::ID, $availableTypes); | ||
| self::assertContains(ExternalTaskType::ID, $this->manager->getAvailableTaskTypeIds()); | ||
| self::assertEquals(ExternalTaskType::ID, $externalProvider->getTaskTypeId(), 'Test Sanity: Provider must handle the Task Type'); | ||
| self::assertEquals('External Task Type via Event', $availableTypes[ExternalTaskType::ID]['name']); | ||
| // Check if shapes match the external type/provider | ||
|
|
@@ -1230,11 +1247,14 @@ public function testMergeTaskTypesLocalAndEvent() { | |
|
|
||
| // Act | ||
| $availableTypes = $this->manager->getAvailableTaskTypes(); | ||
| $availableTypeIds = $this->manager->getAvailableTaskTypeIds(); | ||
|
|
||
| // Assert: Both task types should be available | ||
| self::assertContains(AudioToImage::ID, $availableTypeIds); | ||
| self::assertArrayHasKey(AudioToImage::ID, $availableTypes); | ||
| self::assertEquals(AudioToImage::class, $availableTypes[AudioToImage::ID]['name']); | ||
|
|
||
| self::assertContains(ExternalTaskType::ID, $availableTypeIds); | ||
| self::assertArrayHasKey(ExternalTaskType::ID, $availableTypes); | ||
| self::assertEquals('External Task Type via Event', $availableTypes[ExternalTaskType::ID]['name']); | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏