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)
);

View file

@ -100,6 +100,21 @@ export const SkillCard = (props: ISkillCardProps) => {
<div style={{ height: 10 }} />
<div>
{match(props.processStatus)
.with(ProcessStatus.ERROR, () => (
<>
<CoreButton
style={{
backgroundColor: "red",
}}
onClick={() => {
if (props.startOnClick && props.id) props.startOnClick(props.id);
}}
filled={true}
text="Ошибка"
/>
</>
))
.with(ProcessStatus.END, () => (
<>
<CoreButton
@ -140,53 +155,3 @@ export const SkillCard = (props: ISkillCardProps) => {
</div>
);
};
// {props.processStatus === ProcessStatus.NONE ? (
// <>
// <div style={{ height: 10 }} />
// <CoreButton
// text="продолжить"
// onClick={() => {
// if (props.continueOnClick && props.id) props.continueOnClick(props.id);
// }}
// />
// </>
// ) : null}
// {props.processStatus === ProcessStatus.END ? (
// <>
// <CoreButton
// text="старт"
// onClick={() => {
// if (props.startOnClick && props.id) props.startOnClick(props.id);
// }}
// />
// <div style={{ height: 10 }} />
// <CoreButton
// text="продолжить"
// onClick={() => {
// if (props.continueOnClick && props.id) props.continueOnClick(props.id);
// }}
// />
// </>
// ) : null}
// {props.processStatus === ProcessStatus.RUN ? (
// <>
// <CoreButton
// onClick={() => {
// // if (props.type.isEqual(CardDataSetType.COMPLETED) && props.onClickButton && props.id) {
// // props.onClickButton(props.id);
// }}
// block={true}
// text="Стоп"
// />
// </>
// ) : null}
// {props.processStatus === ProcessStatus.ERROR ? (
// <CoreButton
// style={{
// backgroundColor: "red",
// }}
// onClick={() => {}}
// filled={true}
// text="Ошибка"
// />
// ) : null}

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" }
]
}