progress
This commit is contained in:
parent
c10cdb8158
commit
78ebb748ea
19 changed files with 2032 additions and 124 deletions
1873
server/package-lock.json
generated
1873
server/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -24,13 +24,13 @@
|
|||
"chai": "latest",
|
||||
"eslint": "^8.47.0",
|
||||
"mocha": "latest",
|
||||
"node-watch": "^0.7.4",
|
||||
"nodemon": "^3.0.1",
|
||||
"nyc": "latest",
|
||||
"source-map-support": "latest",
|
||||
"ts-node": "^10.9.1",
|
||||
"tslint": "latest",
|
||||
"typescript": "^5.1.6",
|
||||
"node-watch": "^0.7.4",
|
||||
"nodemon": "^3.0.1"
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@grpc/grpc-js": "^1.9.0",
|
||||
|
@ -45,13 +45,14 @@
|
|||
"md5": "^2.3.0",
|
||||
"mongoose": "^7.6.2",
|
||||
"mongoose-autopopulate": "^1.1.0",
|
||||
"pm2": "^5.3.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^5.0.5",
|
||||
"socket.io": "^4.7.2",
|
||||
"socket.io-client": "^4.7.2",
|
||||
"spark-md5": "^3.0.2",
|
||||
"ts-md5": "^1.3.1",
|
||||
"tsc-watch": "^6.0.4",
|
||||
"uuid": "^9.0.1",
|
||||
"pm2": "^5.3.1"
|
||||
"uuid": "^9.0.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import * as fs from "fs";
|
||||
import { promisify } from "node:util";
|
||||
import { rimraf } from 'rimraf'
|
||||
|
||||
export class FileSystemRepository {
|
||||
public createDir = promisify(fs.mkdir);
|
||||
|
@ -9,7 +10,7 @@ export class FileSystemRepository {
|
|||
public stat = promisify(fs.stat);
|
||||
public readFileAsync = promisify(fs.readFile);
|
||||
public readdir = promisify(fs.readdir);
|
||||
|
||||
public deleteDirRecursive = rimraf;
|
||||
async readFileAtBuffer(path: string): Promise<Buffer> {
|
||||
if ((await this.lsStat(path)).isDirectory()) {
|
||||
return (
|
||||
|
@ -40,4 +41,5 @@ export class FileSystemRepository {
|
|||
});
|
||||
return filesToDir;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
12
server/src/core/usecases/delete_recursive_folder_usecase.ts
Normal file
12
server/src/core/usecases/delete_recursive_folder_usecase.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { Result } from "../helpers/result";
|
||||
import { FileSystemRepository } from "../repository/file_system_repository";
|
||||
|
||||
export class DeleteRecursiveFolderUseCase{
|
||||
repository:FileSystemRepository = new FileSystemRepository()
|
||||
call = async (path:string):Promise<Result<void,void>> =>{
|
||||
console.log(path)
|
||||
await this.repository.deleteDirRecursive(path)
|
||||
return Result.ok()
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { IsHaveActiveProcessUseCase, KillLastProcessUseCase } from "../../core/usecases/exec_process_usecase";
|
||||
import { CreateDataSetScenario } from "./domain/create_dataset_scenario";
|
||||
import { DeleteDatasetUseCase } from "./domain/delete_dataset_use_case";
|
||||
import { ExecDatasetProcessScenario } from "./domain/exec_process_scenario";
|
||||
import { GetDatasetActiveProjectScenario } from "./domain/get_dataset_active_project_scenario";
|
||||
import { DatasetDBModel } from "./models/dataset_database_model";
|
||||
|
@ -15,6 +16,7 @@ export class DatasetsPresentation extends CrudController<DatasetValidationModel,
|
|||
});
|
||||
super.post(new CreateDataSetScenario().call);
|
||||
super.get(new GetDatasetActiveProjectScenario().call);
|
||||
super.delete(null)
|
||||
this.subRoutes.push({
|
||||
method: "POST",
|
||||
subUrl: "exec",
|
||||
|
@ -30,5 +32,11 @@ export class DatasetsPresentation extends CrudController<DatasetValidationModel,
|
|||
subUrl: "delete/process",
|
||||
fn: new KillLastProcessUseCase(),
|
||||
});
|
||||
this.subRoutes.push({
|
||||
method: "DELETE",
|
||||
subUrl: "dataset",
|
||||
fn: new DeleteDatasetUseCase()
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
import { CallbackStrategyWithIdQuery, ResponseBase } from "../../../core/controllers/http_controller";
|
||||
import { Result } from "../../../core/helpers/result";
|
||||
import { DeleteDataBaseModelUseCase } from "../../../core/usecases/delete_database_model_usecase";
|
||||
import { DeleteRecursiveFolderUseCase } from "../../../core/usecases/delete_recursive_folder_usecase";
|
||||
import { ReadByIdDataBaseModelUseCase } from "../../../core/usecases/read_by_id_database_model_usecase";
|
||||
import { MongoIdValidation } from "../../../core/validations/mongo_id_validation";
|
||||
import { DatasetDBModel } from "../models/dataset_database_model";
|
||||
import { IDatasetModel } from "../models/dataset_validation_model";
|
||||
|
||||
export class DeleteDatasetUseCase extends CallbackStrategyWithIdQuery {
|
||||
idValidationExpression = new MongoIdValidation();
|
||||
call = async (id: string): ResponseBase =>
|
||||
(await new ReadByIdDataBaseModelUseCase<IDatasetModel>(DatasetDBModel).call(id)).map(async (model) =>
|
||||
(await new DeleteRecursiveFolderUseCase().call(`${model.local_path}/${model.name}/`)).map(async () =>
|
||||
(await new DeleteDataBaseModelUseCase(model).call(model._id)).map(() => Result.ok({ status: "delete dataset" }))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -6,16 +6,18 @@ import { MongoIdValidation } from "../../../core/validations/mongo_id_validation
|
|||
import { DatasetDBModel } from "../models/dataset_database_model";
|
||||
import { IDatasetModel } from "../models/dataset_validation_model";
|
||||
import { ProcessWatcherAndDatabaseUpdateService } from "./create_dataset_scenario";
|
||||
import { UpdateDataBaseModelUseCase } from "../../../core/usecases/update_database_model_usecase";
|
||||
|
||||
export class ExecDatasetProcessScenario extends CallbackStrategyWithIdQuery {
|
||||
idValidationExpression = new MongoIdValidation();
|
||||
|
||||
call = async (id: string): ResponseBase => {
|
||||
return (await new ReadByIdDataBaseModelUseCase<IDatasetModel>(DatasetDBModel).call(id)).map(async (model) => {
|
||||
return (await new IsHaveActiveProcessUseCase().call()).map(() => {
|
||||
return new ExecProcessUseCase().call(
|
||||
return (await new IsHaveActiveProcessUseCase().call()).map(async () => {
|
||||
await DatasetDBModel.findById(id).updateOne({processStatus:"RUN"})
|
||||
return new ExecProcessUseCase().call(
|
||||
`${model.project.rootDir}/`,
|
||||
`python3 $PYTHON_BLENDER_PROC --cfg '${JSON.stringify(model)}' `,
|
||||
`python3 $PYTHON_BLENDER_PROC --path '${model.project.rootDir}/${model.name}/'`,
|
||||
new ProcessWatcherAndDatabaseUpdateService(id as unknown as ObjectId)
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Type } from "class-transformer";
|
||||
import { IsArray, IsString, ValidateNested } from "class-validator";
|
||||
import { IsArray, IsOptional, IsString, ValidateNested } from "class-validator";
|
||||
import { IProjectModel } from "../../_projects/models/project_database_model";
|
||||
|
||||
export class FormBuilderValidationModel {
|
||||
|
@ -16,6 +16,7 @@ export enum ProcessStatus {
|
|||
NEW = "NEW",
|
||||
}
|
||||
export interface IDatasetModel {
|
||||
_id?:string;
|
||||
name: string;
|
||||
local_path: string;
|
||||
dataSetObjects: string[];
|
||||
|
@ -34,6 +35,8 @@ export class DatasetValidationModel implements IDatasetModel {
|
|||
@Type(() => FormBuilderValidationModel)
|
||||
public formBuilder: FormBuilderValidationModel;
|
||||
public local_path: string;
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
public processStatus: ProcessStatus;
|
||||
public projectId: string;
|
||||
public processLogs: string;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue