progress
This commit is contained in:
parent
e155b4a2a1
commit
c4ddb3dc8c
23 changed files with 333 additions and 132 deletions
15
server/src/core/scenarios/create_many_folder_scenario.ts
Normal file
15
server/src/core/scenarios/create_many_folder_scenario.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { Result } from "../helpers/result";
|
||||
import { CreateFolderUseCase } from "../usecases/create_folder_usecase";
|
||||
|
||||
export class CreateManyFolderScenario {
|
||||
call = async (path: string, foldersNames: string[]): Promise<Result<Error, string>> => {
|
||||
try {
|
||||
foldersNames.forEach(async (folder) => {
|
||||
await new CreateFolderUseCase().call(`${path}${folder}`.normalize());
|
||||
});
|
||||
return Result.ok("many folder created");
|
||||
} catch (error) {
|
||||
return Result.error(new Error(error));
|
||||
}
|
||||
};
|
||||
}
|
|
@ -6,6 +6,7 @@ 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 { FolderStructure } from "../../projects/domain/upload_file_to_to_project_scenario";
|
||||
|
||||
export class ExecDatasetProcessScenario extends CallbackStrategyWithIdQuery {
|
||||
idValidationExpression = new MongoIdValidation();
|
||||
|
@ -14,6 +15,8 @@ export class ExecDatasetProcessScenario extends CallbackStrategyWithIdQuery {
|
|||
return (await new ReadByIdDataBaseModelUseCase<IDatasetModel>(DatasetDBModel).call(id)).map(async (model) => {
|
||||
return (await new IsHaveActiveProcessUseCase().call()).map(async () => {
|
||||
await DatasetDBModel.findById(id).updateOne({ processStatus: "RUN" });
|
||||
model.local_path = `${model.local_path}/${FolderStructure.datasets}/`;
|
||||
console.log(`blenderproc run $PYTHON_BLENDER_PROC --cfg '${JSON.stringify(model)}'`);
|
||||
return new ExecProcessUseCase().call(
|
||||
`${model.project.rootDir}/`,
|
||||
`blenderproc run $PYTHON_BLENDER_PROC --cfg '${JSON.stringify(model)}'`,
|
||||
|
@ -23,4 +26,4 @@ export class ExecDatasetProcessScenario extends CallbackStrategyWithIdQuery {
|
|||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ export class FormBuilderValidationModel {
|
|||
public context: string;
|
||||
@IsArray()
|
||||
public form: [];
|
||||
output: any;
|
||||
}
|
||||
export enum ProcessStatus {
|
||||
END = "END",
|
||||
|
@ -16,7 +17,7 @@ export enum ProcessStatus {
|
|||
NEW = "NEW",
|
||||
}
|
||||
export interface IDatasetModel {
|
||||
_id?:string;
|
||||
_id?: string;
|
||||
name: string;
|
||||
local_path: string;
|
||||
dataSetObjects: string[];
|
||||
|
|
|
@ -6,6 +6,14 @@ 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";
|
||||
import { Result } from "../../../core/helpers/result";
|
||||
import { CreateManyFolderScenario } from "../../../core/scenarios/create_many_folder_scenario";
|
||||
|
||||
export enum FolderStructure {
|
||||
assets = "assets",
|
||||
weights = "weights",
|
||||
datasets = "datasets",
|
||||
}
|
||||
|
||||
export class UploadCadFileToProjectScenario extends CallbackStrategyWithFileUpload {
|
||||
checkingFileExpression: RegExp = new RegExp(".FCStd");
|
||||
|
@ -14,13 +22,18 @@ export class UploadCadFileToProjectScenario extends CallbackStrategyWithFileUplo
|
|||
async call(file: IFile, id: string): ResponseBase {
|
||||
return (await new ReadByIdDataBaseModelUseCase<IProjectInstanceModel>(ProjectDBModel).call(id)).map(
|
||||
async (databaseModel) =>
|
||||
(await new CreateFileUseCase().call(`${databaseModel.rootDir}/${file.name}`, file.data)).map(
|
||||
async () =>
|
||||
(await new CreateFileUseCase().call(`${databaseModel.rootDir}/${file.name}`, file.data)).map(async () =>
|
||||
(
|
||||
await new ExecProcessUseCase().call(
|
||||
`${databaseModel.rootDir}/`,
|
||||
'',
|
||||
`python3 $PYTHON_BLENDER --path '${databaseModel.rootDir}/assets/'`
|
||||
`python3 $PYTHON_BLENDER --path '${databaseModel.rootDir}/assets/'`,
|
||||
""
|
||||
)
|
||||
).map(async () =>
|
||||
(await new CreateManyFolderScenario().call(databaseModel.rootDir, Object.keys(FolderStructure).map((el) => `/${el}`))).map(() =>
|
||||
Result.ok("file upload and save")
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -13,14 +13,16 @@ export class ExecWeightProcessScenario extends CallbackStrategyWithIdQuery {
|
|||
return (await new ReadByIdDataBaseModelUseCase<IWeightModel>(WeightDBModel).call(id)).map(async (model) => {
|
||||
return (await new IsHaveActiveProcessUseCase().call()).map(async () => {
|
||||
await WeightDBModel.findById(id).updateOne({ processStatus: "RUN" });
|
||||
|
||||
if (typeof model.project === "object" && typeof model.datasetId === "object") {
|
||||
console.log(
|
||||
`python3 $PYTHON_EDUCATION --path ${model.project.rootDir} --name ${model.name} --datasetName ${model.datasetId.name}`
|
||||
);
|
||||
if (model.processStatus === "exec") {
|
||||
console.log(20);
|
||||
}
|
||||
if (model.processStatus === "new") {
|
||||
console.log(20);
|
||||
}
|
||||
return new ExecProcessUseCase().call(
|
||||
`${model.project.rootDir}/`,
|
||||
`python3 $PYTHON_EDUCATION --path ${model.project.rootDir} --name ${model.name} --datasetName ${model.datasetId.name}`,
|
||||
`python3 $PYTHON_EDUCATION --path ${model.project.rootDir} --name ${model.name} --datasetName ${model.datasetId.name} --outpath ${model.project.rootDir} --type ${model.datasetId.formBuilder.output.typedataset} --epoch ${model.epoch} `,
|
||||
id,
|
||||
new ProcessWatcherAndDatabaseUpdateService(id as unknown as ObjectId, WeightDBModel)
|
||||
);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { IsMongoId, IsString } from "class-validator";
|
||||
import { IsNumber, IsString } from "class-validator";
|
||||
import { IWeightModel } from "./weights_validation_model";
|
||||
|
||||
export class WeightValidationModel implements IWeightModel {
|
||||
public processStatus: string;
|
||||
@IsNumber()
|
||||
public epoch: number;
|
||||
@IsString()
|
||||
public name: string;
|
||||
@IsMongoId()
|
||||
public datasetId: string;
|
||||
@IsMongoId()
|
||||
public project: string;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ export interface IWeightModel {
|
|||
name: string;
|
||||
datasetId: string | IDatasetModel;
|
||||
project: string | IProjectModel;
|
||||
processStatus: string;
|
||||
epoch: number;
|
||||
}
|
||||
export const WeightSchema = new Schema({
|
||||
name: {
|
||||
|
@ -22,11 +24,15 @@ export const WeightSchema = new Schema({
|
|||
type: String,
|
||||
default: "none",
|
||||
},
|
||||
|
||||
// the user selects
|
||||
isFinished: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
epoch:{
|
||||
type:Number,
|
||||
},
|
||||
datasetId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: datasetSchema,
|
||||
|
|
|
@ -5,6 +5,7 @@ import { extensions } from "./core/extensions/extensions";
|
|||
import { httpRoutes } from "./core/controllers/routes";
|
||||
import { executorProgramService } from "./core/usecases/exec_process_usecase";
|
||||
|
||||
|
||||
extensions();
|
||||
|
||||
const socketSubscribers = [new SocketSubscriber(executorProgramService, "realtime")];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue