Skip to content

Commit

Permalink
chore: deprecate cortex start stop api
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed May 30, 2024
1 parent 9b89d43 commit 0a52a79
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -105,6 +106,7 @@ export class InitCliUsecases {
console.error('Error decompressing file', e);
exit(1);
}
await rm(destination, { force: true });
};

parseEngineFileName = (options: InitOptions) => {
Expand Down Expand Up @@ -228,5 +230,6 @@ export class InitCliUsecases {
console.log(e);
exit(1);
}
await rm(destination, { force: true });
};
}
18 changes: 0 additions & 18 deletions cortex-js/src/infrastructure/controllers/cortex.controller.spec.ts

This file was deleted.

45 changes: 0 additions & 45 deletions cortex-js/src/infrastructure/controllers/cortex.controller.ts

This file was deleted.

10 changes: 8 additions & 2 deletions cortex-js/src/infrastructure/controllers/models.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions cortex-js/src/usecases/cortex/cortex.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
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],
controllers: [],
exports: [CortexUsecases],
})
export class CortexModule {}

0 comments on commit 0a52a79

Please sign in to comment.