Skip to content
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

feat: display error if not matching containers is found #115

Merged
merged 8 commits into from
Jan 25, 2024
36 changes: 36 additions & 0 deletions packages/backend/src/managers/applicationManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,40 @@ describe('pullApplication', () => {
expect(cloneRepositoryMock).not.toHaveBeenCalled();
expect(downloadModelMainSpy).not.toHaveBeenCalled();
});

test('pullApplication should mark the loading config as error if not container are found', async () => {
mockForPullApplication({
recipeFolderExists: true,
});

const recipe: Recipe = {
id: 'recipe1',
name: 'Recipe 1',
categories: [],
description: '',
readme: '',
repository: 'repo',
};
const model: ModelInfo = {
id: 'model1',
description: '',
hw: '',
license: '',
name: 'Model 1',
popularity: 1,
registry: '',
url: '',
};

mocks.parseYamlMock.mockReturnValue({
application: {
containers: [],
},
});

await expect(manager.pullApplication(recipe, model)).rejects.toThrowError('No containers available.');

expect(cloneRepositoryMock).not.toHaveBeenCalled();
expect(downloadModelMainSpy).not.toHaveBeenCalled();
});
});
15 changes: 11 additions & 4 deletions packages/backend/src/managers/applicationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,22 @@ export class ApplicationManager {
throw new Error('Cannot load configuration file.');
}

// Mark as success.
loadingConfiguration.state = 'success';
taskUtil.setTask(loadingConfiguration);

// Filter the containers based on architecture
const filteredContainers = aiConfig.application.containers.filter(
container => container.arch === undefined || container.arch === arch(),
);

if (filteredContainers.length > 0) {
// Mark as success.
loadingConfiguration.state = 'success';
axel7083 marked this conversation as resolved.
Show resolved Hide resolved
taskUtil.setTask(loadingConfiguration);
} else {
// Mark as failure.
loadingConfiguration.state = 'error';
taskUtil.setTask(loadingConfiguration);
throw new Error('No containers available.');
}

axel7083 marked this conversation as resolved.
Show resolved Hide resolved
if (!this.modelsManager.isModelOnDisk(model.id)) {
// Download model
taskUtil.setTask({
Expand Down
Loading