diff --git a/cortex-js/src/infrastructure/commanders/models/model-pull.command.ts b/cortex-js/src/infrastructure/commanders/models/model-pull.command.ts index 58b4a5d4a..1dade38de 100644 --- a/cortex-js/src/infrastructure/commanders/models/model-pull.command.ts +++ b/cortex-js/src/infrastructure/commanders/models/model-pull.command.ts @@ -50,6 +50,7 @@ export class ModelPullCommand extends CommandRunner { name: sanitizedInput, }; + // eslint-disable-next-line @typescript-eslint/no-unused-vars for await (const _fileInfo of listFiles({ repo })) { break; } diff --git a/cortex-js/src/infrastructure/commanders/models/model-remove.command.ts b/cortex-js/src/infrastructure/commanders/models/model-remove.command.ts index 531f0f893..db31204a1 100644 --- a/cortex-js/src/infrastructure/commanders/models/model-remove.command.ts +++ b/cortex-js/src/infrastructure/commanders/models/model-remove.command.ts @@ -14,7 +14,6 @@ export class ModelRemoveCommand extends CommandRunner { exit(1); } - const result = await this.modelsCliUsecases.removeModel(input[0]); - console.log(result); + await this.modelsCliUsecases.removeModel(input[0]).then(console.log); } } diff --git a/cortex-js/src/infrastructure/commanders/models/model-stop.command.ts b/cortex-js/src/infrastructure/commanders/models/model-stop.command.ts index 3168e9b7a..a72ec0074 100644 --- a/cortex-js/src/infrastructure/commanders/models/model-stop.command.ts +++ b/cortex-js/src/infrastructure/commanders/models/model-stop.command.ts @@ -1,14 +1,10 @@ import { CommandRunner, SubCommand } from 'nest-commander'; import { exit } from 'node:process'; import { ModelsCliUsecases } from '../usecases/models.cli.usecases'; -import { CortexUsecases } from '@/usecases/cortex/cortex.usecases'; @SubCommand({ name: 'stop', description: 'Stop a model by ID.' }) export class ModelStopCommand extends CommandRunner { - constructor( - private readonly cortexUsecases: CortexUsecases, - private readonly modelsCliUsecases: ModelsCliUsecases, - ) { + constructor(private readonly modelsCliUsecases: ModelsCliUsecases) { super(); } diff --git a/cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts b/cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts index 443f5cbf3..34527d857 100644 --- a/cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts +++ b/cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts @@ -8,6 +8,7 @@ import { InitOptions } from '../types/init-options.interface'; import { Injectable } from '@nestjs/common'; import { firstValueFrom } from 'rxjs'; import { FileManagerService } from '@/file-manager/file-manager.service'; +import { rm } from 'fs/promises'; @Injectable() export class InitCliUsecases { @@ -105,6 +106,7 @@ export class InitCliUsecases { console.error('Error decompressing file', e); exit(1); } + await rm(destination, { force: true }); }; parseEngineFileName = (options: InitOptions) => { @@ -228,5 +230,6 @@ export class InitCliUsecases { console.log(e); exit(1); } + await rm(destination, { force: true }); }; } diff --git a/cortex-js/src/infrastructure/controllers/cortex.controller.spec.ts b/cortex-js/src/infrastructure/controllers/cortex.controller.spec.ts deleted file mode 100644 index 6d7790c71..000000000 --- a/cortex-js/src/infrastructure/controllers/cortex.controller.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { CortexController } from './cortex.controller'; - -describe('CortexController', () => { - let controller: CortexController; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - controllers: [CortexController], - }).compile(); - - controller = module.get(CortexController); - }); - - it('should be defined', () => { - expect(controller).toBeDefined(); - }); -}); diff --git a/cortex-js/src/infrastructure/controllers/cortex.controller.ts b/cortex-js/src/infrastructure/controllers/cortex.controller.ts deleted file mode 100644 index 907fdba10..000000000 --- a/cortex-js/src/infrastructure/controllers/cortex.controller.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Body, Controller, HttpCode, Post } from '@nestjs/common'; -import { ApiResponse, ApiTags, ApiOperation } from '@nestjs/swagger'; -import { StartCortexDto } from '@/infrastructure/dtos/cortex/start-cortex.dto'; -import { CortexOperationSuccessfullyDto } from '../dtos/cortex/cortex-operation-successfully.dto'; -import { CortexUsecases } from '@/usecases/cortex/cortex.usecases'; - -@ApiTags('Cortex') -@Controller('cortex') -export class CortexController { - constructor(private readonly cortexUsecases: CortexUsecases) {} - - @HttpCode(200) - @ApiResponse({ - status: 200, - description: 'Start Cortex successfully', - type: CortexOperationSuccessfullyDto, - }) - @ApiOperation({ - summary: 'Start cortex', - description: 'Starts the cortex operation.', - }) - @Post('start') - startCortex(@Body() startCortexDto: StartCortexDto) { - return this.cortexUsecases.startCortex( - false, - startCortexDto.host, - startCortexDto.port, - ); - } - - @HttpCode(200) - @ApiResponse({ - status: 200, - description: 'Stop Cortex successfully', - type: CortexOperationSuccessfullyDto, - }) - @ApiOperation({ - summary: 'Stop cortex', - description: 'Stops the cortex operation.', - }) - @Post('stop') - stopCortex() { - return this.cortexUsecases.stopCortex(); - } -} diff --git a/cortex-js/src/infrastructure/controllers/models.controller.ts b/cortex-js/src/infrastructure/controllers/models.controller.ts index 1f8b17e30..bb1d415b1 100644 --- a/cortex-js/src/infrastructure/controllers/models.controller.ts +++ b/cortex-js/src/infrastructure/controllers/models.controller.ts @@ -20,12 +20,16 @@ import { ApiOperation, ApiParam, ApiTags, ApiResponse } from '@nestjs/swagger'; import { StartModelSuccessDto } from '@/infrastructure/dtos/models/start-model-success.dto'; import { ModelSettingParamsDto } from '../dtos/models/model-setting-params.dto'; import { TransformInterceptor } from '../interceptors/transform.interceptor'; +import { CortexUsecases } from '@/usecases/cortex/cortex.usecases'; @ApiTags('Models') @Controller('models') @UseInterceptors(TransformInterceptor) export class ModelsController { - constructor(private readonly modelsUsecases: ModelsUsecases) {} + constructor( + private readonly modelsUsecases: ModelsUsecases, + private readonly cortexUsecases: CortexUsecases, + ) {} @HttpCode(201) @ApiResponse({ @@ -62,7 +66,9 @@ export class ModelsController { @Param('modelId') modelId: string, @Body() settings: ModelSettingParamsDto, ) { - return this.modelsUsecases.startModel(modelId, settings); + return this.cortexUsecases + .startCortex() + .then(() => this.modelsUsecases.startModel(modelId, settings)); } @HttpCode(200) diff --git a/cortex-js/src/usecases/cortex/cortex.module.ts b/cortex-js/src/usecases/cortex/cortex.module.ts index 76c757b8c..dcb28a595 100644 --- a/cortex-js/src/usecases/cortex/cortex.module.ts +++ b/cortex-js/src/usecases/cortex/cortex.module.ts @@ -1,13 +1,11 @@ import { Module } from '@nestjs/common'; import { CortexUsecases } from './cortex.usecases'; -import { CortexController } from '@/infrastructure/controllers/cortex.controller'; import { HttpModule } from '@nestjs/axios'; import { FileManagerModule } from '@/file-manager/file-manager.module'; @Module({ imports: [HttpModule, FileManagerModule], providers: [CortexUsecases], - controllers: [CortexController], exports: [CortexUsecases], }) export class CortexModule {}