deleted unnecessary files

added new features
This commit is contained in:
IDONTSUDO 2024-04-09 16:31:25 +03:00
parent dffc73c30f
commit 6840402b1f
119 changed files with 1835 additions and 1522 deletions

View file

@ -0,0 +1,92 @@
import { ObjectId } from "mongoose";
import { CallbackStrategyWithValidationModel, ResponseBase } from "../../../core/controllers/http_controller";
import { Result } from "../../../core/helpers/result";
import { TypedEvent } from "../../../core/helpers/typed_event";
import { EXEC_EVENT, ExecError, SpawnError } from "../../../core/models/exec_error_model";
import { ExecutorResult } from "../../../core/models/executor_result";
import { ExecProcessUseCase } from "../../../core/usecases/exec_process_usecase";
import { SearchDataBaseModelUseCase } from "../../../core/usecases/search_database_model_usecase";
import { IProjectModel, ProjectDBModel } from "../../_projects/models/project_database_model";
import { DatasetDBModel } from "../models/dataset_database_model";
import { DatasetValidationModel } from "../models/dataset_validation_model";
export class ProcessWatcherAndDatabaseUpdateService extends TypedEvent<Result<ExecError | SpawnError, ExecutorResult>> {
databaseId: ObjectId;
constructor(databaseId: ObjectId) {
super();
this.databaseId = databaseId;
this.on((event) => this.lister(event));
}
lister(event: Result<ExecError | SpawnError, ExecutorResult>) {
event.fold(
async (success) => {
if (success.event == EXEC_EVENT.END) {
const dbModel = await DatasetDBModel.findById(this.databaseId);
if (dbModel !== null) {
dbModel.local_path;
dbModel.processStatus = "end";
dbModel.processLogs = success.data;
await dbModel.save();
}
}
},
async (error) => {
const dbModel = await DatasetDBModel.findById(this.databaseId);
if (dbModel !== null) {
dbModel.processStatus = "error";
dbModel.processLogs = error.message;
await dbModel.save();
}
}
);
}
}
export class CreateDataSetScenario extends CallbackStrategyWithValidationModel<DatasetValidationModel> {
validationModel: DatasetValidationModel;
call = async (model: DatasetValidationModel): ResponseBase => {
return (
await new SearchDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
).map(async (project) => {
model.processStatus = "exec";
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}]
// }
// }