progress
This commit is contained in:
parent
89d4226ea6
commit
4585d079f6
19 changed files with 149 additions and 30 deletions
|
@ -124,3 +124,4 @@ export class App extends TypedEvent<ServerStatus> {
|
||||||
return rootDir + "public/";
|
return rootDir + "public/";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,12 @@ import {
|
||||||
import { pipelineRealTimeService } from "../../features/_realtime/realtime_presentation";
|
import { pipelineRealTimeService } from "../../features/_realtime/realtime_presentation";
|
||||||
import { App } from "../controllers/app";
|
import { App } from "../controllers/app";
|
||||||
import { CreateFolderUseCase } from "../usecases/create_folder_usecase";
|
import { CreateFolderUseCase } from "../usecases/create_folder_usecase";
|
||||||
import { SearchDataBaseModelUseCase } from "../usecases/search_database_model_usecase";
|
import { SearchOneDataBaseModelUseCase } from "../usecases/search_database_model_usecase";
|
||||||
|
|
||||||
export class SetLastActivePipelineToRealTimeServiceScenario {
|
export class SetLastActivePipelineToRealTimeServiceScenario {
|
||||||
call = async (): Promise<void> => {
|
call = async (): Promise<void> => {
|
||||||
return (
|
return (
|
||||||
await new SearchDataBaseModelUseCase<IProjectInstanceModel>(ProjectInstanceDbModel).call({
|
await new SearchOneDataBaseModelUseCase<IProjectInstanceModel>(ProjectInstanceDbModel).call({
|
||||||
isActive: true,
|
isActive: true,
|
||||||
})
|
})
|
||||||
).fold(
|
).fold(
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Result } from "../helpers/result";
|
import { Result } from "../helpers/result";
|
||||||
|
|
||||||
export class SearchDataBaseModelUseCase<T> {
|
export class SearchOneDataBaseModelUseCase<T> {
|
||||||
model: any;
|
model: any;
|
||||||
|
|
||||||
constructor(model: any) {
|
constructor(model: any) {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { Result } from "../helpers/result";
|
||||||
|
|
||||||
|
export class SearchManyDataBaseModelUseCase<T> {
|
||||||
|
model: any;
|
||||||
|
|
||||||
|
constructor(model: any) {
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
call = async (findFilter: Partial<T>, error: string = "not found database"): Promise<Result<string, T>> => {
|
||||||
|
const result = await this.model.find(findFilter);
|
||||||
|
if (result === null) {
|
||||||
|
return Result.error(error);
|
||||||
|
} else {
|
||||||
|
return Result.ok(result);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ import { Result } from "../../../core/helpers/result";
|
||||||
import { TypedEvent } from "../../../core/helpers/typed_event";
|
import { TypedEvent } from "../../../core/helpers/typed_event";
|
||||||
import { EXEC_EVENT, ExecError, SpawnError } from "../../../core/models/exec_error_model";
|
import { EXEC_EVENT, ExecError, SpawnError } from "../../../core/models/exec_error_model";
|
||||||
import { ExecutorResult } from "../../../core/models/executor_result";
|
import { ExecutorResult } from "../../../core/models/executor_result";
|
||||||
import { SearchDataBaseModelUseCase } from "../../../core/usecases/search_database_model_usecase";
|
import { SearchOneDataBaseModelUseCase } from "../../../core/usecases/search_database_model_usecase";
|
||||||
import { IProjectModel, ProjectDBModel } from "../../_projects/models/project_database_model";
|
import { IProjectModel, ProjectDBModel } from "../../_projects/models/project_database_model";
|
||||||
import { DatasetDBModel } from "../models/dataset_database_model";
|
import { DatasetDBModel } from "../models/dataset_database_model";
|
||||||
import { DatasetValidationModel, ProcessStatus } from "../models/dataset_validation_model";
|
import { DatasetValidationModel, ProcessStatus } from "../models/dataset_validation_model";
|
||||||
|
@ -53,7 +53,7 @@ export class CreateDataSetScenario extends CallbackStrategyWithValidationModel<D
|
||||||
validationModel: DatasetValidationModel;
|
validationModel: DatasetValidationModel;
|
||||||
call = async (model: DatasetValidationModel): ResponseBase => {
|
call = async (model: DatasetValidationModel): ResponseBase => {
|
||||||
return (
|
return (
|
||||||
await new SearchDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
await new SearchOneDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
||||||
).map(async (project) => {
|
).map(async (project) => {
|
||||||
model.processStatus = ProcessStatus.NEW;
|
model.processStatus = ProcessStatus.NEW;
|
||||||
model.local_path = project.rootDir;
|
model.local_path = project.rootDir;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { CallbackStrategyWithEmpty, ResponseBase } from "../../../core/controllers/http_controller";
|
import { CallbackStrategyWithEmpty, ResponseBase } from "../../../core/controllers/http_controller";
|
||||||
import { Result } from "../../../core/helpers/result";
|
import { Result } from "../../../core/helpers/result";
|
||||||
import { SearchDataBaseModelUseCase } from "../../../core/usecases/search_database_model_usecase";
|
import { SearchOneDataBaseModelUseCase } from "../../../core/usecases/search_database_model_usecase";
|
||||||
import { IProjectModel, ProjectDBModel } from "../../_projects/models/project_database_model";
|
import { IProjectModel, ProjectDBModel } from "../../_projects/models/project_database_model";
|
||||||
import { DatasetDBModel } from "../models/dataset_database_model";
|
import { DatasetDBModel } from "../models/dataset_database_model";
|
||||||
|
|
||||||
export class GetDatasetActiveProjectScenario extends CallbackStrategyWithEmpty {
|
export class GetDatasetActiveProjectScenario extends CallbackStrategyWithEmpty {
|
||||||
call = async (): ResponseBase => {
|
call = async (): ResponseBase => {
|
||||||
return (
|
return (
|
||||||
await new SearchDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
await new SearchOneDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
||||||
).map(async (project) => {
|
).map(async (project) => {
|
||||||
return Result.ok(await DatasetDBModel.find({ project: project._id }));
|
return Result.ok(await DatasetDBModel.find({ project: project._id }));
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { CallbackStrategyWithEmpty, ResponseBase } from "../../../core/controllers/http_controller";
|
import { CallbackStrategyWithEmpty, ResponseBase } from "../../../core/controllers/http_controller";
|
||||||
import { Result } from "../../../core/helpers/result";
|
import { Result } from "../../../core/helpers/result";
|
||||||
import { SearchDataBaseModelUseCase } from "../../../core/usecases/search_database_model_usecase";
|
import { SearchOneDataBaseModelUseCase } from "../../../core/usecases/search_database_model_usecase";
|
||||||
import { IProjectModel, ProjectDBModel } from "../../_projects/models/project_database_model";
|
import { IProjectModel, ProjectDBModel } from "../../_projects/models/project_database_model";
|
||||||
|
|
||||||
export class GetActiveProjectScenario extends CallbackStrategyWithEmpty {
|
export class GetActiveProjectScenario extends CallbackStrategyWithEmpty {
|
||||||
async call(): ResponseBase {
|
async call(): Promise<Result<any, { id: string }>> {
|
||||||
return (
|
return (
|
||||||
await new SearchDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
await new SearchOneDataBaseModelUseCase<IProjectModel>(ProjectDBModel).call({ isActive: true }, "no active projects")
|
||||||
).map((model) => Result.ok({ id: model._id }));
|
).map((model) => Result.ok({ id: model._id }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ export class ExecWeightProcessScenario extends CallbackStrategyWithIdQuery {
|
||||||
await WeightDBModel.findById(id).updateOne({ processStatus: "RUN" });
|
await WeightDBModel.findById(id).updateOne({ processStatus: "RUN" });
|
||||||
return match(model.processStatus)
|
return match(model.processStatus)
|
||||||
.with("exec", "RUN", "none", () => this.exec(id, model))
|
.with("exec", "RUN", "none", () => this.exec(id, model))
|
||||||
.with("exec", "RUN", () => this.exec(id, model, true))
|
.with('before_training' , () => this.exec(id, model, true))
|
||||||
.otherwise(() => Result.error(`model status is ${model.processStatus}`));
|
.otherwise(() => Result.error(`model status is ${model.processStatus}`));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { ResponseBase } from "../../../core/controllers/http_controller";
|
||||||
|
import { SearchManyDataBaseModelUseCase } from "../../../core/usecases/search_many_database_model_usecase";
|
||||||
|
import { GetActiveProjectScenario } from "../../projects/domain/get_active_project_scenario";
|
||||||
|
import { IWeightModel, WeightDBModel } from "../models/weights_validation_model";
|
||||||
|
|
||||||
|
export class GetAllWeightsActiveProjectScenarios {
|
||||||
|
call = async (): ResponseBase =>
|
||||||
|
(await new GetActiveProjectScenario().call()).map(
|
||||||
|
async (model) => await new SearchManyDataBaseModelUseCase<IWeightModel>(WeightDBModel).call({ project: model.id })
|
||||||
|
);
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ export const WeightSchema = new Schema({
|
||||||
},
|
},
|
||||||
numberOfTrainedEpochs: {
|
numberOfTrainedEpochs: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
default:0,
|
||||||
},
|
},
|
||||||
neuralNetworkName: {
|
neuralNetworkName: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { CrudController } from "../../core/controllers/crud_controller";
|
import { CrudController } from "../../core/controllers/crud_controller";
|
||||||
import { ExecWeightProcessScenario } from "./domain/exec_weights_process_scenario";
|
import { ExecWeightProcessScenario } from "./domain/exec_weights_process_scenario";
|
||||||
|
import { GetAllWeightsActiveProjectScenarios } from "./domain/get_all_weights_active_project_scenarios";
|
||||||
import { WeightValidationModel } from "./models/weights_database_model";
|
import { WeightValidationModel } from "./models/weights_database_model";
|
||||||
import { WeightDBModel } from "./models/weights_validation_model";
|
import { WeightDBModel } from "./models/weights_validation_model";
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ export class WeightsPresentation extends CrudController<WeightValidationModel, t
|
||||||
validationModel: WeightValidationModel,
|
validationModel: WeightValidationModel,
|
||||||
databaseModel: WeightDBModel,
|
databaseModel: WeightDBModel,
|
||||||
});
|
});
|
||||||
|
super.get(new GetAllWeightsActiveProjectScenarios().call);
|
||||||
this.subRoutes.push({
|
this.subRoutes.push({
|
||||||
method: "GET",
|
method: "GET",
|
||||||
subUrl: "exec",
|
subUrl: "exec",
|
||||||
|
|
|
@ -11,4 +11,3 @@ const socketSubscribers = [new SocketSubscriber(executorProgramService, "realtim
|
||||||
|
|
||||||
new App(httpRoutes, socketSubscribers).listen();
|
new App(httpRoutes, socketSubscribers).listen();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ export interface ISkillCardProps {
|
||||||
epoch?: number;
|
epoch?: number;
|
||||||
onDelete?: (id: string) => void;
|
onDelete?: (id: string) => void;
|
||||||
datasetName?: string;
|
datasetName?: string;
|
||||||
|
epochNextTraining?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SkillCard = (props: ISkillCardProps) => {
|
export const SkillCard = (props: ISkillCardProps) => {
|
||||||
|
@ -52,7 +53,7 @@ export const SkillCard = (props: ISkillCardProps) => {
|
||||||
backgroundColor: "#f7f2fa",
|
backgroundColor: "#f7f2fa",
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
padding: 10,
|
padding: 10,
|
||||||
width: 150,
|
width: 200,
|
||||||
height: "max-content",
|
height: "max-content",
|
||||||
alignContent: "center",
|
alignContent: "center",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
@ -86,7 +87,9 @@ export const SkillCard = (props: ISkillCardProps) => {
|
||||||
<div style={{ display: "flex", flexDirection: "column", margin: 10 }}>
|
<div style={{ display: "flex", flexDirection: "column", margin: 10 }}>
|
||||||
<CoreText text={props.name ?? ""} type={CoreTextType.medium} />
|
<CoreText text={props.name ?? ""} type={CoreTextType.medium} />
|
||||||
<div style={{ height: 10 }} />
|
<div style={{ height: 10 }} />
|
||||||
<CoreText text={"Количество эпох: " + props.epoch?.toString() ?? ""} type={CoreTextType.small} />
|
<CoreText text={"обученных эпох: " + props.epoch?.toString() ?? ""} type={CoreTextType.small} />
|
||||||
|
<CoreText text={"обучится эпох: " + props.epoch?.toString() ?? ""} type={CoreTextType.small} />
|
||||||
|
|
||||||
<CoreText text={"Датасет: " + props.datasetName ?? ""} type={CoreTextType.small} />
|
<CoreText text={"Датасет: " + props.datasetName ?? ""} type={CoreTextType.small} />
|
||||||
</div>
|
</div>
|
||||||
<div style={{ height: 10 }}>
|
<div style={{ height: 10 }}>
|
||||||
|
@ -120,9 +123,10 @@ export const SkillCard = (props: ISkillCardProps) => {
|
||||||
<CoreButton
|
<CoreButton
|
||||||
text="дообучение"
|
text="дообучение"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (props.startOnClick && props.id) props.startOnClick(props.id);
|
if (props.continueOnClick && props.id) props.continueOnClick(props.id);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<div style={{ height: 10 }} />
|
||||||
<CoreButton
|
<CoreButton
|
||||||
text="заново"
|
text="заново"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
|
@ -1,25 +1,39 @@
|
||||||
import makeAutoObservable from "mobx-store-inheritance";
|
import makeAutoObservable from "mobx-store-inheritance";
|
||||||
import { Result } from "../../core/helper/result";
|
import { Result } from "../../core/helper/result";
|
||||||
import { ISkils } from "./skills_repository";
|
import { ISkils } from "./skills_http_repository";
|
||||||
|
|
||||||
export class SkillModel {
|
export class SkillModel {
|
||||||
numberOfTrainedEpochs?: number;
|
numberOfTrainedEpochs?: number;
|
||||||
|
id?: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public name: string,
|
public name: string,
|
||||||
public datasetId: string,
|
public datasetId: string,
|
||||||
public project: string,
|
public project: string,
|
||||||
public epoch: number,
|
public epoch: number,
|
||||||
numberOfTrainedEpochs?: number
|
numberOfTrainedEpochs?: number,
|
||||||
|
id?: string
|
||||||
) {
|
) {
|
||||||
this.numberOfTrainedEpochs = numberOfTrainedEpochs;
|
this.numberOfTrainedEpochs = numberOfTrainedEpochs;
|
||||||
|
this.id = id;
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromISkill(model: ISkils) {
|
static fromISkill(model: ISkils) {
|
||||||
return new SkillModel(model.name, model.datasetId._id, model.project._id, model.epoch, model.numberOfTrainedEpochs);
|
return new SkillModel(
|
||||||
|
model.name,
|
||||||
|
model.datasetId._id,
|
||||||
|
model.project._id,
|
||||||
|
model.epoch,
|
||||||
|
model.numberOfTrainedEpochs,
|
||||||
|
model._id
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static empty() {
|
static empty() {
|
||||||
return new SkillModel("", "", "", 0);
|
return new SkillModel("", "", "", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
valid(): Result<string, SkillModel> {
|
valid(): Result<string, SkillModel> {
|
||||||
if (this.name.isEmpty()) {
|
if (this.name.isEmpty()) {
|
||||||
return Result.error("введите имя скила");
|
return Result.error("введите имя скила");
|
||||||
|
|
31
ui/src/features/skils/skill_socket_repository.ts
Normal file
31
ui/src/features/skils/skill_socket_repository.ts
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
import { TypedEvent } from "../../core/helper/typed_event";
|
||||||
|
import { SocketRepository, socketRepository } from "../../core/repository/socket_repository";
|
||||||
|
import { ProcessStatus } from "../dataset/dataset_model";
|
||||||
|
|
||||||
|
export interface ProcessUpdate {
|
||||||
|
id: string;
|
||||||
|
status: ProcessStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SkillSocketRepository extends TypedEvent<ProcessUpdate> {
|
||||||
|
socketRepository: SocketRepository = socketRepository;
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.socketRepository.on((e) => {
|
||||||
|
if (e.event === "realtime") {
|
||||||
|
if (e.payload !== undefined && e.payload.value !== undefined && e.payload.value.id !== undefined) {
|
||||||
|
this.emit({
|
||||||
|
id: String(e.payload.value.id),
|
||||||
|
status: ProcessStatus.END,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (e.payload !== undefined && e.payload.error !== undefined && e.payload.error.id !== undefined) {
|
||||||
|
this.emit({
|
||||||
|
id: String(e.payload.error.id),
|
||||||
|
status: ProcessStatus.ERROR,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,7 +39,7 @@ export const SkillScreen = observer(() => {
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: "grid",
|
display: "grid",
|
||||||
gridTemplateColumns: "repeat(auto-fill, minmax(150px,1px))",
|
gridTemplateColumns: "repeat(auto-fill, minmax(220px,1px))",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
gap: 20,
|
gap: 20,
|
||||||
margin: 12,
|
margin: 12,
|
||||||
|
@ -56,9 +56,11 @@ export const SkillScreen = observer(() => {
|
||||||
processStatus={el.processStatus}
|
processStatus={el.processStatus}
|
||||||
empty={false}
|
empty={false}
|
||||||
epoch={el.numberOfTrainedEpochs}
|
epoch={el.numberOfTrainedEpochs}
|
||||||
|
epochNextTraining={el.epoch}
|
||||||
startOnClick={(id) => store.execSkill(id)}
|
startOnClick={(id) => store.execSkill(id)}
|
||||||
continueOnClick={(id) => store.continueSkill(id)}
|
continueOnClick={(id) => store.continueSkill(id)}
|
||||||
onEdit={(id) => store.editSkill(id)}
|
onEdit={(id) => store.fromEditSkill(id)}
|
||||||
|
onDelete={(id) => store.deleteSkill(id)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<SkillCard empty={true} emptyOnClick={() => store.edtDrawer(DrawersSkill.NEW_SKILL, true)} />
|
<SkillCard empty={true} emptyOnClick={() => store.edtDrawer(DrawersSkill.NEW_SKILL, true)} />
|
||||||
|
@ -71,7 +73,14 @@ export const SkillScreen = observer(() => {
|
||||||
onClose={() => store.edtDrawer(DrawersSkill.EDIT_SKILL, false)}
|
onClose={() => store.edtDrawer(DrawersSkill.EDIT_SKILL, false)}
|
||||||
open={store.drawers.find((el) => el.name === DrawersSkill.EDIT_SKILL)?.status}
|
open={store.drawers.find((el) => el.name === DrawersSkill.EDIT_SKILL)?.status}
|
||||||
>
|
>
|
||||||
<CoreInput value={(store.skill.epoch ?? "").toString()} label={"добавить эпох"} />
|
<div style={{ display: "flex", flexDirection: "column", justifyContent: "space-between", height: "100%" }}>
|
||||||
|
<CoreInput value={(store.skill.epoch ?? "").toString()} label={"добавить эпох"} />
|
||||||
|
<div style={{ display: "flex" }}>
|
||||||
|
<CoreButton text="Сохранить" filled={true} onClick={() => store.saveEdiSkill()} />
|
||||||
|
<div style={{ width: 10 }} />
|
||||||
|
<CoreButton text="Отмена" onClick={() => store.edtDrawer(DrawersSkill.NEW_SKILL, false)} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
<Drawer
|
<Drawer
|
||||||
title={store.titleDrawer}
|
title={store.titleDrawer}
|
||||||
|
|
|
@ -2,12 +2,14 @@ import makeAutoObservable from "mobx-store-inheritance";
|
||||||
import { NavigateFunction } from "react-router-dom";
|
import { NavigateFunction } from "react-router-dom";
|
||||||
import { HttpError } from "../../core/repository/http_repository";
|
import { HttpError } from "../../core/repository/http_repository";
|
||||||
import { UiErrorState } from "../../core/store/base_store";
|
import { UiErrorState } from "../../core/store/base_store";
|
||||||
import { ISkils, SkillsHttpRepository } from "./skills_repository";
|
import { ISkils, SkillsHttpRepository } from "./skills_http_repository";
|
||||||
import { Drawer } from "../dataset/dataset_store";
|
import { Drawer } from "../dataset/dataset_store";
|
||||||
import { IDatasetModel } from "../dataset/dataset_model";
|
import { IDatasetModel } from "../dataset/dataset_model";
|
||||||
import { message } from "antd";
|
import { message } from "antd";
|
||||||
import { UUID } from "../all_projects/data/project_repository";
|
import { UUID } from "../all_projects/data/project_repository";
|
||||||
import { SkillModel } from "./skill_model";
|
import { SkillModel } from "./skill_model";
|
||||||
|
import { SocketRepository, socketRepository } from "../../core/repository/socket_repository";
|
||||||
|
import { ProcessUpdate, SkillSocketRepository } from "./skill_socket_repository";
|
||||||
|
|
||||||
export enum DrawersSkill {
|
export enum DrawersSkill {
|
||||||
NEW_SKILL = "Новый навык",
|
NEW_SKILL = "Новый навык",
|
||||||
|
@ -15,11 +17,6 @@ export enum DrawersSkill {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class SkillStore extends UiErrorState<HttpError> {
|
export class SkillStore extends UiErrorState<HttpError> {
|
||||||
editSkill(id: string): void {
|
|
||||||
this.skill = SkillModel.fromISkill(this.getSkillById(id) as ISkils);
|
|
||||||
|
|
||||||
this.edtDrawer(DrawersSkill.EDIT_SKILL, true);
|
|
||||||
}
|
|
||||||
drawers: Drawer[];
|
drawers: Drawer[];
|
||||||
skillsHttpRepository: SkillsHttpRepository;
|
skillsHttpRepository: SkillsHttpRepository;
|
||||||
skils?: ISkils[];
|
skils?: ISkils[];
|
||||||
|
@ -27,6 +24,7 @@ export class SkillStore extends UiErrorState<HttpError> {
|
||||||
activeProjectId?: UUID;
|
activeProjectId?: UUID;
|
||||||
skill: SkillModel;
|
skill: SkillModel;
|
||||||
titleDrawer: string = DrawersSkill.NEW_SKILL;
|
titleDrawer: string = DrawersSkill.NEW_SKILL;
|
||||||
|
skillSocketRepository: SkillSocketRepository = new SkillSocketRepository();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -38,14 +36,25 @@ export class SkillStore extends UiErrorState<HttpError> {
|
||||||
});
|
});
|
||||||
this.skill = SkillModel.empty();
|
this.skill = SkillModel.empty();
|
||||||
this.skillsHttpRepository = new SkillsHttpRepository();
|
this.skillsHttpRepository = new SkillsHttpRepository();
|
||||||
|
this.skillSocketRepository.on(this.socketUpdate);
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
}
|
}
|
||||||
|
socketUpdate = (data: ProcessUpdate) => {
|
||||||
|
this.skils?.map((el) => {
|
||||||
|
if (el._id.isEqual(data.id)) {
|
||||||
|
el.processStatus = data.status;
|
||||||
|
}
|
||||||
|
return el;
|
||||||
|
});
|
||||||
|
};
|
||||||
getSkillById = (id: string) => this.skils?.find((el) => el._id === id);
|
getSkillById = (id: string) => this.skils?.find((el) => el._id === id);
|
||||||
continueSkill = async (id: string) => {
|
continueSkill = async (id: string) => {
|
||||||
const skill = this.getSkillById(id) as ISkils;
|
const skill = this.getSkillById(id) as ISkils;
|
||||||
skill.processStatus = "new";
|
skill.processStatus = "before_training";
|
||||||
|
skill.numberOfTrainedEpochs += skill.epoch;
|
||||||
await this.skillsHttpRepository.editSkill(skill);
|
await this.skillsHttpRepository.editSkill(skill);
|
||||||
this.messageHttp(this.skillsHttpRepository.execSkill(id), {
|
|
||||||
|
await this.messageHttp(this.skillsHttpRepository.execSkill(id), {
|
||||||
errorMessage: "Ошибка",
|
errorMessage: "Ошибка",
|
||||||
successMessage: "Обучение продолжено",
|
successMessage: "Обучение продолжено",
|
||||||
});
|
});
|
||||||
|
@ -54,6 +63,7 @@ export class SkillStore extends UiErrorState<HttpError> {
|
||||||
execSkill = async (id: string) => {
|
execSkill = async (id: string) => {
|
||||||
const skill = this.getSkillById(id) as ISkils;
|
const skill = this.getSkillById(id) as ISkils;
|
||||||
skill.processStatus = "exec";
|
skill.processStatus = "exec";
|
||||||
|
skill.numberOfTrainedEpochs = skill.epoch;
|
||||||
await this.skillsHttpRepository.editSkill(skill);
|
await this.skillsHttpRepository.editSkill(skill);
|
||||||
this.messageHttp(this.skillsHttpRepository.execSkill(id), {
|
this.messageHttp(this.skillsHttpRepository.execSkill(id), {
|
||||||
errorMessage: "Ошибка",
|
errorMessage: "Ошибка",
|
||||||
|
@ -72,7 +82,6 @@ export class SkillStore extends UiErrorState<HttpError> {
|
||||||
}
|
}
|
||||||
changeEpoch(epoch: number) {
|
changeEpoch(epoch: number) {
|
||||||
this.skill.epoch = epoch;
|
this.skill.epoch = epoch;
|
||||||
|
|
||||||
}
|
}
|
||||||
saveSkill() {
|
saveSkill() {
|
||||||
this.skill.project = this.activeProjectId?.id ?? "";
|
this.skill.project = this.activeProjectId?.id ?? "";
|
||||||
|
@ -94,6 +103,7 @@ export class SkillStore extends UiErrorState<HttpError> {
|
||||||
this.skill.datasetId = id;
|
this.skill.datasetId = id;
|
||||||
}
|
}
|
||||||
edtDrawer(drawerName: DrawersSkill, status: boolean): void {
|
edtDrawer(drawerName: DrawersSkill, status: boolean): void {
|
||||||
|
this.titleDrawer = drawerName;
|
||||||
this.drawers = this.drawers.map((el) => {
|
this.drawers = this.drawers.map((el) => {
|
||||||
if (el.name === drawerName) {
|
if (el.name === drawerName) {
|
||||||
el.status = status;
|
el.status = status;
|
||||||
|
@ -101,4 +111,20 @@ export class SkillStore extends UiErrorState<HttpError> {
|
||||||
return el;
|
return el;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
deleteSkill = async (id: string): Promise<void> => {
|
||||||
|
await this.skillsHttpRepository.deleteSkill(id);
|
||||||
|
await this.init();
|
||||||
|
};
|
||||||
|
fromEditSkill(id: string): void {
|
||||||
|
this.skill = SkillModel.fromISkill(this.getSkillById(id) as ISkils);
|
||||||
|
|
||||||
|
this.edtDrawer(DrawersSkill.EDIT_SKILL, true);
|
||||||
|
}
|
||||||
|
saveEdiSkill = async () => {
|
||||||
|
const skillOrigin = this.getSkillById(this.skill.id as string) as ISkils;
|
||||||
|
skillOrigin.numberOfTrainedEpochs = this.skill.epoch;
|
||||||
|
|
||||||
|
await this.skillsHttpRepository.editSkill(skillOrigin);
|
||||||
|
this.edtDrawer(DrawersSkill.EDIT_SKILL, false);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,9 @@ export interface ISocketListerProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SocketLister = observer((props: ISocketListerProps) => {
|
export const SocketLister = observer((props: ISocketListerProps) => {
|
||||||
|
React.useEffect(() => {
|
||||||
|
socketListerStore.init();
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{/* {socketListerStore.socketHasDisconnect ? (
|
{/* {socketListerStore.socketHasDisconnect ? (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue