deleted unnecessary files
added new features
This commit is contained in:
parent
6840402b1f
commit
c17515d571
47 changed files with 1039 additions and 479 deletions
|
@ -49,18 +49,21 @@ export class ExecutorProgramService
|
|||
|
||||
if (spawnError instanceof SpawnError) {
|
||||
this.emit(Result.error(spawnError));
|
||||
this.worker = undefined;
|
||||
return;
|
||||
}
|
||||
const execError = ExecError.isExecError(e);
|
||||
|
||||
if (execError instanceof ExecError) {
|
||||
this.emit(Result.error(execError));
|
||||
this.worker = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
const executorResult = ExecutorResult.isExecutorResult(e);
|
||||
if (executorResult instanceof ExecutorResult) {
|
||||
this.emit(Result.ok(executorResult));
|
||||
this.worker = undefined;
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
@ -78,7 +81,10 @@ export class ExecutorProgramService
|
|||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
public deleteWorker() {
|
||||
if (this.worker) this.worker.kill();
|
||||
this.worker = undefined;
|
||||
}
|
||||
public async call(type: EXEC_TYPE, command: string, args: Array<string> | undefined = undefined): Promise<void> {
|
||||
if (type == EXEC_TYPE.EXEC) {
|
||||
this.workerExecuted(command, WorkerType.EXEC);
|
||||
|
|
|
@ -1,9 +1,27 @@
|
|||
import { CallbackStrategyWithEmpty } from "../controllers/http_controller";
|
||||
import { Result } from "../helpers/result";
|
||||
import { TypedEvent } from "../helpers/typed_event";
|
||||
import { EXEC_TYPE, ExecError, SpawnError } from "../models/exec_error_model";
|
||||
import { ExecutorResult } from "../models/executor_result";
|
||||
import { ExecutorProgramService } from "../services/executor_program_service";
|
||||
|
||||
const executorProgramService = new ExecutorProgramService("");
|
||||
export class KillLastProcessUseCase extends CallbackStrategyWithEmpty {
|
||||
call = async (): Promise<Result<undefined, string>> => {
|
||||
executorProgramService.deleteWorker();
|
||||
return Result.ok("ok");
|
||||
};
|
||||
}
|
||||
|
||||
export class IsHaveActiveProcessUseCase extends CallbackStrategyWithEmpty {
|
||||
call = async (): Promise<Result<string, string>> => {
|
||||
if (executorProgramService.worker === undefined) {
|
||||
return Result.ok("process not work");
|
||||
}
|
||||
return Result.error("process is exists");
|
||||
};
|
||||
}
|
||||
|
||||
export class ExecProcessUseCase {
|
||||
call = async (
|
||||
path: string,
|
||||
|
@ -11,11 +29,11 @@ export class ExecProcessUseCase {
|
|||
watcher?: TypedEvent<Result<ExecError | SpawnError, ExecutorResult>>
|
||||
): Promise<Result<Error, string>> => {
|
||||
try {
|
||||
const executorProgramService = new ExecutorProgramService(path);
|
||||
if (watcher)
|
||||
executorProgramService.on((event) => {
|
||||
watcher.emit(event);
|
||||
});
|
||||
executorProgramService.execPath = path;
|
||||
executorProgramService.on((event) => {
|
||||
console.log(event);
|
||||
if (watcher) watcher.emit(event);
|
||||
});
|
||||
executorProgramService.call(EXEC_TYPE.EXEC, command);
|
||||
|
||||
return Result.ok("ok");
|
||||
|
|
|
@ -11,4 +11,3 @@ export class TriggerPresentation extends CrudController<TriggerModelValidationMo
|
|||
});
|
||||
}
|
||||
}
|
||||
"".isEmpty();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { IsHaveActiveProcessUseCase, KillLastProcessUseCase } from "../../core/usecases/exec_process_usecase";
|
||||
import { CreateDataSetScenario } from "./domain/create_dataset_scanario";
|
||||
import { ExecDatasetProcessScenario } from "./domain/exec_process_scenario";
|
||||
import { GetDatasetActiveProjectScenario } from "./domain/get_dataset_active_project_scenario";
|
||||
import { DatasetDBModel } from "./models/dataset_database_model";
|
||||
import { DatasetValidationModel } from "./models/dataset_validation_model";
|
||||
|
@ -13,5 +15,20 @@ export class DatasetsPresentation extends CrudController<DatasetValidationModel,
|
|||
});
|
||||
super.post(new CreateDataSetScenario().call);
|
||||
super.get(new GetDatasetActiveProjectScenario().call);
|
||||
this.subRoutes.push({
|
||||
method: "POST",
|
||||
subUrl: "exec",
|
||||
fn: new ExecDatasetProcessScenario(),
|
||||
});
|
||||
this.subRoutes.push({
|
||||
method: "GET",
|
||||
subUrl: "is/running",
|
||||
fn: new IsHaveActiveProcessUseCase(),
|
||||
});
|
||||
this.subRoutes.push({
|
||||
method: "GET",
|
||||
subUrl: "delete/process",
|
||||
fn: new KillLastProcessUseCase(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,45 +48,14 @@ export class CreateDataSetScenario extends CallbackStrategyWithValidationModel<D
|
|||
return (
|
||||
await new SearchDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
||||
).map(async (project) => {
|
||||
model.processStatus = "exec";
|
||||
model.processStatus = "new";
|
||||
model.local_path = project.rootDir;
|
||||
model.projectId = project._id;
|
||||
const d = new DatasetDBModel();
|
||||
Object.assign(d, model);
|
||||
await d.save();
|
||||
|
||||
await new ExecProcessUseCase().call(
|
||||
`${project.rootDir}/`,
|
||||
`python3 $PYTHON_BLENDER_PROC --path '${project.rootDir}/${model.name}' --cfg '${JSON.stringify(model)}'`,
|
||||
new ProcessWatcherAndDatabaseUpdateService(d._id as unknown as ObjectId)
|
||||
);
|
||||
return Result.ok("create dataset ok");
|
||||
});
|
||||
};
|
||||
}
|
||||
// сохрнать formbuilder result и передать его в python
|
||||
// {
|
||||
// "typedataset": ${typedataset:Enum<T>:"ObjectDetection"},
|
||||
// "dataset_path": ${DATASET_PATH:string:""},
|
||||
// "models":${models:Array<MODELS>:[]},
|
||||
// "models_randomization":{
|
||||
// "loc_range_low": [${LOC_RANGE_LOW_1:number:-1}, ${LOC_RANGE_LOW_2:number:-1},/${LOC_RANGE_LOW_3:number:0}],
|
||||
// "loc_range_high": [${LOC_RANGE_HIGH_1:number:1}, ${LOC_RANGE_HIGH_2:number:1},/${LOC_RANGE_HIGH_3:number:2}]
|
||||
// },
|
||||
// "scene":{
|
||||
// "objects": ${OBJECTS_SCENE:Array<OBJECTS_SCENE>:[]},
|
||||
// "lights": ${LIGHTS:Array<LIGHTS>:[]},
|
||||
// },
|
||||
// "camera_position":{
|
||||
// "center_shell": [${CENTER_SHELL_1:number:0}, ${CENTER_SHELL_2:number:0}, ${CENTER_SHELL_3:number:0}],
|
||||
// "radius_range": [${RADIUS_RANGE_1:number:0.4}, ${RADIUS_RANGE_2:number:1.4}],
|
||||
// "elevation_range": [${ELEVATION_RANGE_1:number:10}, ${ELEVATION_RANGE_2:number:90}]
|
||||
// },
|
||||
// "generation":{
|
||||
// "n_cam_pose": ${N_CAM_POSE:number:5},
|
||||
// "n_sample_on_pose": ${N_SAMPLE_ON_POSE:number:3},
|
||||
// "n_series": ${N_SERIES:number:100},
|
||||
// "image_format": ${image_format:Enum<F>:"jpg"},
|
||||
// "image_size_wh": [${IMAGE_SIZE_WH_1:number:640}, ${IMAGE_SIZE_WH_2:number:480}]
|
||||
// }
|
||||
// }
|
||||
|
|
24
server/src/features/datasets/domain/exec_process_scenario.ts
Normal file
24
server/src/features/datasets/domain/exec_process_scenario.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { ObjectId } from "mongoose";
|
||||
import { CallbackStrategyWithIdQuery, ResponseBase } from "../../../core/controllers/http_controller";
|
||||
import { ExecProcessUseCase, IsHaveActiveProcessUseCase } from "../../../core/usecases/exec_process_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";
|
||||
import { ProcessWatcherAndDatabaseUpdateService } from "./create_dataset_scanario";
|
||||
|
||||
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(
|
||||
`${model.project.rootDir}/`,
|
||||
`python3 $PYTHON_BLENDER_PROC --cfg '${JSON.stringify(model)}' `,
|
||||
new ProcessWatcherAndDatabaseUpdateService(id as unknown as ObjectId)
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
|
@ -9,7 +9,7 @@ export class GetDatasetActiveProjectScenario extends CallbackStrategyWithEmpty {
|
|||
return (
|
||||
await new SearchDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
||||
).map(async (project) => {
|
||||
return Result.ok(await DatasetDBModel.find({ projectId: project._id }));
|
||||
return Result.ok(await DatasetDBModel.find({ project: project._id }));
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,19 +17,32 @@ export const DatasetSchema = new Schema({
|
|||
type: Schema.Types.Mixed,
|
||||
of: String,
|
||||
},
|
||||
unixTime: {
|
||||
type: Number,
|
||||
default: Date.now(),
|
||||
},
|
||||
neuralNetworkAction: {
|
||||
type: String,
|
||||
},
|
||||
neuralNetworkName: {
|
||||
type: String,
|
||||
},
|
||||
processStatus: {
|
||||
type: String,
|
||||
default: "none",
|
||||
},
|
||||
projectId: {
|
||||
project: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: projectSchema,
|
||||
autopopulate: false,
|
||||
default: null,
|
||||
autopopulate: true,
|
||||
require: true,
|
||||
},
|
||||
processLogs: {
|
||||
type: String,
|
||||
},
|
||||
datasetType: {
|
||||
type: String,
|
||||
},
|
||||
}).plugin(require("mongoose-autopopulate"));
|
||||
|
||||
export const datasetSchema = "Dataset";
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { Type } from "class-transformer";
|
||||
import { IsArray, IsString, ValidateNested } from "class-validator";
|
||||
import { IProjectModel } from "../../_projects/models/project_database_model";
|
||||
|
||||
export class FormBuilderValidationModel {
|
||||
@IsString()
|
||||
|
@ -17,6 +18,7 @@ export interface IDatasetModel {
|
|||
formBuilder: FormBuilderValidationModel;
|
||||
processLogs: string;
|
||||
processStatus: string;
|
||||
project?: IProjectModel;
|
||||
}
|
||||
|
||||
export class DatasetValidationModel implements IDatasetModel {
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
import { App } from "../../../core/controllers/app";
|
||||
import { CallbackStrategyWithFileUpload, ResponseBase } from "../../../core/controllers/http_controller";
|
||||
import { Result } from "../../../core/helpers/result";
|
||||
import { IFile } from "../../../core/interfaces/file";
|
||||
import { CreateDataBaseModelUseCase } from "../../../core/usecases/create_database_model_usecase";
|
||||
import { CreateFileUseCase } from "../../../core/usecases/create_file_usecase";
|
||||
import { CreateFolderUseCase } from "../../../core/usecases/create_folder_usecase";
|
||||
import { MongoIdValidation } from "../../../core/validations/mongo_id_validation";
|
||||
import { IProjectInstanceModel, ProjectInstanceDbModel } from "../models/project_instance_database_model";
|
||||
import { ProjectInstanceValidationModel } from "../models/project_instance_validation_model";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { SetActiveProjectScenario } from "./set_active_project_use_scenario";
|
||||
import { IProjectInstanceModel } from "../models/project_instance_database_model";
|
||||
import { ReadByIdDataBaseModelUseCase } from "../../../core/usecases/read_by_id_database_model_usecase";
|
||||
import { ProjectDBModel } from "../../_projects/models/project_database_model";
|
||||
import { ExecProcessUseCase } from "../../../core/usecases/exec_process_usecase";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue