progress
This commit is contained in:
parent
f0ed478b36
commit
8bc943de2c
16 changed files with 252 additions and 134 deletions
12
server/package-lock.json
generated
12
server/package-lock.json
generated
|
@ -20,6 +20,7 @@
|
|||
"md5": "^2.3.0",
|
||||
"mongoose": "^7.6.2",
|
||||
"mongoose-autopopulate": "^1.1.0",
|
||||
"pattern-matching-ts": "^2.0.0",
|
||||
"pm2": "^5.3.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^5.0.5",
|
||||
|
@ -27,6 +28,7 @@
|
|||
"socket.io-client": "^4.7.2",
|
||||
"spark-md5": "^3.0.2",
|
||||
"ts-md5": "^1.3.1",
|
||||
"ts-pattern": "^5.1.1",
|
||||
"tsc-watch": "^6.0.4",
|
||||
"uuid": "^9.0.1"
|
||||
},
|
||||
|
@ -6224,6 +6226,11 @@
|
|||
"node": ">= 14.16"
|
||||
}
|
||||
},
|
||||
"node_modules/pattern-matching-ts": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pattern-matching-ts/-/pattern-matching-ts-2.0.0.tgz",
|
||||
"integrity": "sha512-XfNA/wZ1A92Ps+jzlmFKXviAI6YQt98GwZoHVAsDEMOKYo+g5aSjvMQ3lnvYQskIYdBj30r7S4rAx/VzuxsRhA=="
|
||||
},
|
||||
"node_modules/pause-stream": {
|
||||
"version": "0.0.11",
|
||||
"resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz",
|
||||
|
@ -7781,6 +7788,11 @@
|
|||
"node": ">=0.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/ts-pattern": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-5.1.1.tgz",
|
||||
"integrity": "sha512-i+owkHr5RYdQxj8olUgRrqpiWH9x27PuWVfXwDmJ/n/CoF/SAa7WW1i2oUpPDMQpJ4U+bGRUcZkVq7i1m3zFCg=="
|
||||
},
|
||||
"node_modules/tsc-watch": {
|
||||
"version": "6.0.4",
|
||||
"resolved": "https://registry.npmjs.org/tsc-watch/-/tsc-watch-6.0.4.tgz",
|
||||
|
|
|
@ -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,6 +45,7 @@
|
|||
"md5": "^2.3.0",
|
||||
"mongoose": "^7.6.2",
|
||||
"mongoose-autopopulate": "^1.1.0",
|
||||
"pattern-matching-ts": "^2.0.0",
|
||||
"pm2": "^5.3.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^5.0.5",
|
||||
|
@ -52,6 +53,7 @@
|
|||
"socket.io-client": "^4.7.2",
|
||||
"spark-md5": "^3.0.2",
|
||||
"ts-md5": "^1.3.1",
|
||||
"ts-pattern": "^5.1.1",
|
||||
"tsc-watch": "^6.0.4",
|
||||
"uuid": "^9.0.1"
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ declare global {
|
|||
hasPattern(pattern: string): boolean;
|
||||
hasNoPattern(pattern: string): boolean;
|
||||
pathNormalize(): string;
|
||||
isEqual(str: string): boolean;
|
||||
isEqualMany(str: string[]): boolean;
|
||||
}
|
||||
}
|
||||
export const extensions = () => {
|
||||
|
|
|
@ -31,4 +31,19 @@ export const StringExtensions = () => {
|
|||
return !this.hasPattern(pattern);
|
||||
};
|
||||
}
|
||||
if ("".isEqual === undefined) {
|
||||
String.prototype.isEqual = function (str: string) {
|
||||
return this === str;
|
||||
};
|
||||
}
|
||||
if ("".isEqualMany === undefined) {
|
||||
String.prototype.isEqualMany = function (str: string[]) {
|
||||
for (const el of str) {
|
||||
if (el === this) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,29 +6,37 @@ import { ReadByIdDataBaseModelUseCase } from "../../../core/usecases/read_by_id_
|
|||
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";
|
||||
|
||||
export class ExecWeightProcessScenario extends CallbackStrategyWithIdQuery {
|
||||
idValidationExpression = new MongoIdValidation();
|
||||
call = async (id: string): ResponseBase => {
|
||||
return (await new ReadByIdDataBaseModelUseCase<IWeightModel>(WeightDBModel).call(id)).map(async (model) => {
|
||||
call = async (id: string): ResponseBase =>
|
||||
(await new ReadByIdDataBaseModelUseCase<IWeightModel>(WeightDBModel).call(id)).map(async (model) => {
|
||||
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))
|
||||
.otherwise(() => Result.error(`model status is ${model.processStatus}`));
|
||||
});
|
||||
});
|
||||
|
||||
exec = (id: string, model: IWeightModel, preTrain: boolean) =>
|
||||
match(typeof model.project === "object" && typeof model.datasetId === "object")
|
||||
.returnType<ResponseBase>()
|
||||
.with(true, async () => {
|
||||
if (typeof model.project === "object" && typeof model.datasetId === "object") {
|
||||
if (model.processStatus === "exec") {
|
||||
console.log(20);
|
||||
}
|
||||
if (model.processStatus === "new") {
|
||||
console.log(20);
|
||||
}
|
||||
return new ExecProcessUseCase().call(
|
||||
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} `,
|
||||
`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}`
|
||||
);
|
||||
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}`,
|
||||
id,
|
||||
new ProcessWatcherAndDatabaseUpdateService(id as unknown as ObjectId, WeightDBModel)
|
||||
);
|
||||
}
|
||||
return Result.error("model project is not object");
|
||||
});
|
||||
});
|
||||
};
|
||||
})
|
||||
.with(false, async () => Result.error("model is unknown"));
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ import { IsNumber, IsString } from "class-validator";
|
|||
import { IWeightModel } from "./weights_validation_model";
|
||||
|
||||
export class WeightValidationModel implements IWeightModel {
|
||||
@IsNumber()
|
||||
public numberOfTrainedEpochs: number;
|
||||
public processStatus: string;
|
||||
@IsNumber()
|
||||
|
|
|
@ -5,9 +5,10 @@ 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")];
|
||||
|
||||
new App(httpRoutes, socketSubscribers).listen();
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue