This commit is contained in:
IDONTSUDO 2024-05-02 17:30:59 +03:00
parent 8bc943de2c
commit c49beb8218
3 changed files with 21 additions and 56 deletions

View file

@ -7,6 +7,7 @@ import { MongoIdValidation } from "../../../core/validations/mongo_id_validation
import { ProcessWatcherAndDatabaseUpdateService } from "../../datasets/domain/create_dataset_scenario";
import { WeightDBModel, IWeightModel } from "../models/weights_validation_model";
import { match } from "ts-pattern";
import { FolderStructure } from "../../projects/domain/upload_file_to_to_project_scenario";
export class ExecWeightProcessScenario extends CallbackStrategyWithIdQuery {
idValidationExpression = new MongoIdValidation();
@ -15,8 +16,8 @@ export class ExecWeightProcessScenario extends CallbackStrategyWithIdQuery {
return (await new IsHaveActiveProcessUseCase().call()).map(async () => {
await WeightDBModel.findById(id).updateOne({ processStatus: "RUN" });
return match(model.processStatus)
.with("exec", "RUN", "none", () => this.exec(id, model, true))
.with("new", () => this.exec(id, model, false))
.with("exec", "RUN", "none", () => this.exec(id, model, false))
.with("exec", "RUN", () => this.exec(id, model, true))
.otherwise(() => Result.error(`model status is ${model.processStatus}`));
});
});
@ -27,12 +28,11 @@ export class ExecWeightProcessScenario extends CallbackStrategyWithIdQuery {
.with(true, async () => {
if (typeof model.project === "object" && typeof model.datasetId === "object") {
console.log(
`${model.project.rootDir}/`,
`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} --pretrain ${preTrain}`
`python3 $PYTHON_EDUCATION --path ${model.project.rootDir}/${FolderStructure.datasets} --name ${model.name} --datasetName ${model.datasetId.name} --outpath ${model.project.rootDir}/${FolderStructure.weights} --type ${model.datasetId.formBuilder.output.typedataset} --epoch ${model.epoch} --pretrain ${preTrain}`
);
return await new ExecProcessUseCase().call(
`${model.project.rootDir}/`,
`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} --pretrain ${preTrain}`,
`python3 $PYTHON_EDUCATION --path ${model.project.rootDir}/${FolderStructure.datasets} --name ${model.name} --datasetName ${model.datasetId.name} --outpath ${model.project.rootDir}/${FolderStructure.weights} --type ${model.datasetId.formBuilder.output.typedataset} --epoch ${model.epoch} --pretrain ${preTrain}`,
id,
new ProcessWatcherAndDatabaseUpdateService(id as unknown as ObjectId, WeightDBModel)
);