This commit is contained in:
IDONTSUDO 2024-05-02 17:57:58 +03:00
parent a0cee0b394
commit 89d4226ea6
3 changed files with 10 additions and 9 deletions

View file

@ -16,23 +16,26 @@ 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, false))
.with("exec", "RUN", "none", () => this.exec(id, model))
.with("exec", "RUN", () => this.exec(id, model, true))
.otherwise(() => Result.error(`model status is ${model.processStatus}`));
});
});
exec = (id: string, model: IWeightModel, preTrain: boolean) =>
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") {
console.log(
`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}`
);
let execCommand = `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}`;
if (preTrain) {
execCommand += ` --pretrain`;
}
console.log(execCommand);
return await new ExecProcessUseCase().call(
`${model.project.rootDir}/`,
`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}`,
execCommand,
id,
new ProcessWatcherAndDatabaseUpdateService(id as unknown as ObjectId, WeightDBModel)
);

View file

@ -8,8 +8,6 @@ args = parser.parse_args()
def copy_and_move_folder(src, dst):
try:
if os.path.exists(src) is False:
shutil.rmtree(src)
shutil.copytree(src, dst)
print(f"Folder {src} successfully copied")
except shutil.Error as e:

View file

@ -1,6 +1,6 @@
{
"assets": [
{ "name": "bear_holder", "mesh": "./mesh/fork.stl", "image": "./images/bear_holder_220425.png" },
{ "name": "fork", "mesh": "./mesh/fork.stl", "image": "./images/bear_holder_220425.png" },
{ "name": "bear_holder1", "mesh": "./mesh/fork.stl", "image": "./images/bear_holder_220425.png" }
]
}