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/";
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ import {
|
|||
import { pipelineRealTimeService } from "../../features/_realtime/realtime_presentation";
|
||||
import { App } from "../controllers/app";
|
||||
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 {
|
||||
call = async (): Promise<void> => {
|
||||
return (
|
||||
await new SearchDataBaseModelUseCase<IProjectInstanceModel>(ProjectInstanceDbModel).call({
|
||||
await new SearchOneDataBaseModelUseCase<IProjectInstanceModel>(ProjectInstanceDbModel).call({
|
||||
isActive: true,
|
||||
})
|
||||
).fold(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Result } from "../helpers/result";
|
||||
|
||||
export class SearchDataBaseModelUseCase<T> {
|
||||
export class SearchOneDataBaseModelUseCase<T> {
|
||||
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 { EXEC_EVENT, ExecError, SpawnError } from "../../../core/models/exec_error_model";
|
||||
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 { DatasetDBModel } from "../models/dataset_database_model";
|
||||
import { DatasetValidationModel, ProcessStatus } from "../models/dataset_validation_model";
|
||||
|
@ -53,7 +53,7 @@ export class CreateDataSetScenario extends CallbackStrategyWithValidationModel<D
|
|||
validationModel: DatasetValidationModel;
|
||||
call = async (model: DatasetValidationModel): ResponseBase => {
|
||||
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) => {
|
||||
model.processStatus = ProcessStatus.NEW;
|
||||
model.local_path = project.rootDir;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { CallbackStrategyWithEmpty, ResponseBase } from "../../../core/controllers/http_controller";
|
||||
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 { DatasetDBModel } from "../models/dataset_database_model";
|
||||
|
||||
export class GetDatasetActiveProjectScenario extends CallbackStrategyWithEmpty {
|
||||
call = async (): ResponseBase => {
|
||||
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) => {
|
||||
return Result.ok(await DatasetDBModel.find({ project: project._id }));
|
||||
});
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { CallbackStrategyWithEmpty, ResponseBase } from "../../../core/controllers/http_controller";
|
||||
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";
|
||||
|
||||
export class GetActiveProjectScenario extends CallbackStrategyWithEmpty {
|
||||
async call(): ResponseBase {
|
||||
async call(): Promise<Result<any, { id: string }>> {
|
||||
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 }));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ export class ExecWeightProcessScenario extends CallbackStrategyWithIdQuery {
|
|||
await WeightDBModel.findById(id).updateOne({ processStatus: "RUN" });
|
||||
return match(model.processStatus)
|
||||
.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}`));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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: {
|
||||
type: Number,
|
||||
default:0,
|
||||
},
|
||||
neuralNetworkName: {
|
||||
type: String,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
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 { WeightDBModel } from "./models/weights_validation_model";
|
||||
|
||||
|
@ -10,6 +11,7 @@ export class WeightsPresentation extends CrudController<WeightValidationModel, t
|
|||
validationModel: WeightValidationModel,
|
||||
databaseModel: WeightDBModel,
|
||||
});
|
||||
super.get(new GetAllWeightsActiveProjectScenarios().call);
|
||||
this.subRoutes.push({
|
||||
method: "GET",
|
||||
subUrl: "exec",
|
||||
|
|
|
@ -11,4 +11,3 @@ const socketSubscribers = [new SocketSubscriber(executorProgramService, "realtim
|
|||
|
||||
new App(httpRoutes, socketSubscribers).listen();
|
||||
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ export interface ISkillCardProps {
|
|||
epoch?: number;
|
||||
onDelete?: (id: string) => void;
|
||||
datasetName?: string;
|
||||
epochNextTraining?: number;
|
||||
}
|
||||
|
||||
export const SkillCard = (props: ISkillCardProps) => {
|
||||
|
@ -52,7 +53,7 @@ export const SkillCard = (props: ISkillCardProps) => {
|
|||
backgroundColor: "#f7f2fa",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
width: 150,
|
||||
width: 200,
|
||||
height: "max-content",
|
||||
alignContent: "center",
|
||||
display: "flex",
|
||||
|
@ -86,7 +87,9 @@ export const SkillCard = (props: ISkillCardProps) => {
|
|||
<div style={{ display: "flex", flexDirection: "column", margin: 10 }}>
|
||||
<CoreText text={props.name ?? ""} type={CoreTextType.medium} />
|
||||
<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} />
|
||||
</div>
|
||||
<div style={{ height: 10 }}>
|
||||
|
@ -120,9 +123,10 @@ export const SkillCard = (props: ISkillCardProps) => {
|
|||
<CoreButton
|
||||
text="дообучение"
|
||||
onClick={() => {
|
||||
if (props.startOnClick && props.id) props.startOnClick(props.id);
|
||||
if (props.continueOnClick && props.id) props.continueOnClick(props.id);
|
||||
}}
|
||||
/>
|
||||
<div style={{ height: 10 }} />
|
||||
<CoreButton
|
||||
text="заново"
|
||||
onClick={() => {
|
||||
|
|
|
@ -1,25 +1,39 @@
|
|||
import makeAutoObservable from "mobx-store-inheritance";
|
||||
import { Result } from "../../core/helper/result";
|
||||
import { ISkils } from "./skills_repository";
|
||||
import { ISkils } from "./skills_http_repository";
|
||||
|
||||
export class SkillModel {
|
||||
numberOfTrainedEpochs?: number;
|
||||
id?: string;
|
||||
|
||||
constructor(
|
||||
public name: string,
|
||||
public datasetId: string,
|
||||
public project: string,
|
||||
public epoch: number,
|
||||
numberOfTrainedEpochs?: number
|
||||
numberOfTrainedEpochs?: number,
|
||||
id?: string
|
||||
) {
|
||||
this.numberOfTrainedEpochs = numberOfTrainedEpochs;
|
||||
this.id = id;
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
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() {
|
||||
return new SkillModel("", "", "", 0);
|
||||
}
|
||||
|
||||
valid(): Result<string, SkillModel> {
|
||||
if (this.name.isEmpty()) {
|
||||
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
|
||||
style={{
|
||||
display: "grid",
|
||||
gridTemplateColumns: "repeat(auto-fill, minmax(150px,1px))",
|
||||
gridTemplateColumns: "repeat(auto-fill, minmax(220px,1px))",
|
||||
width: "100%",
|
||||
gap: 20,
|
||||
margin: 12,
|
||||
|
@ -56,9 +56,11 @@ export const SkillScreen = observer(() => {
|
|||
processStatus={el.processStatus}
|
||||
empty={false}
|
||||
epoch={el.numberOfTrainedEpochs}
|
||||
epochNextTraining={el.epoch}
|
||||
startOnClick={(id) => store.execSkill(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)} />
|
||||
|
@ -71,7 +73,14 @@ export const SkillScreen = observer(() => {
|
|||
onClose={() => store.edtDrawer(DrawersSkill.EDIT_SKILL, false)}
|
||||
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
|
||||
title={store.titleDrawer}
|
||||
|
|
|
@ -2,12 +2,14 @@ import makeAutoObservable from "mobx-store-inheritance";
|
|||
import { NavigateFunction } from "react-router-dom";
|
||||
import { HttpError } from "../../core/repository/http_repository";
|
||||
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 { IDatasetModel } from "../dataset/dataset_model";
|
||||
import { message } from "antd";
|
||||
import { UUID } from "../all_projects/data/project_repository";
|
||||
import { SkillModel } from "./skill_model";
|
||||
import { SocketRepository, socketRepository } from "../../core/repository/socket_repository";
|
||||
import { ProcessUpdate, SkillSocketRepository } from "./skill_socket_repository";
|
||||
|
||||
export enum DrawersSkill {
|
||||
NEW_SKILL = "Новый навык",
|
||||
|
@ -15,11 +17,6 @@ export enum DrawersSkill {
|
|||
}
|
||||
|
||||
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[];
|
||||
skillsHttpRepository: SkillsHttpRepository;
|
||||
skils?: ISkils[];
|
||||
|
@ -27,6 +24,7 @@ export class SkillStore extends UiErrorState<HttpError> {
|
|||
activeProjectId?: UUID;
|
||||
skill: SkillModel;
|
||||
titleDrawer: string = DrawersSkill.NEW_SKILL;
|
||||
skillSocketRepository: SkillSocketRepository = new SkillSocketRepository();
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -38,14 +36,25 @@ export class SkillStore extends UiErrorState<HttpError> {
|
|||
});
|
||||
this.skill = SkillModel.empty();
|
||||
this.skillsHttpRepository = new SkillsHttpRepository();
|
||||
this.skillSocketRepository.on(this.socketUpdate);
|
||||
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);
|
||||
continueSkill = async (id: string) => {
|
||||
const skill = this.getSkillById(id) as ISkils;
|
||||
skill.processStatus = "new";
|
||||
skill.processStatus = "before_training";
|
||||
skill.numberOfTrainedEpochs += skill.epoch;
|
||||
await this.skillsHttpRepository.editSkill(skill);
|
||||
this.messageHttp(this.skillsHttpRepository.execSkill(id), {
|
||||
|
||||
await this.messageHttp(this.skillsHttpRepository.execSkill(id), {
|
||||
errorMessage: "Ошибка",
|
||||
successMessage: "Обучение продолжено",
|
||||
});
|
||||
|
@ -54,6 +63,7 @@ export class SkillStore extends UiErrorState<HttpError> {
|
|||
execSkill = async (id: string) => {
|
||||
const skill = this.getSkillById(id) as ISkils;
|
||||
skill.processStatus = "exec";
|
||||
skill.numberOfTrainedEpochs = skill.epoch;
|
||||
await this.skillsHttpRepository.editSkill(skill);
|
||||
this.messageHttp(this.skillsHttpRepository.execSkill(id), {
|
||||
errorMessage: "Ошибка",
|
||||
|
@ -72,7 +82,6 @@ export class SkillStore extends UiErrorState<HttpError> {
|
|||
}
|
||||
changeEpoch(epoch: number) {
|
||||
this.skill.epoch = epoch;
|
||||
|
||||
}
|
||||
saveSkill() {
|
||||
this.skill.project = this.activeProjectId?.id ?? "";
|
||||
|
@ -94,6 +103,7 @@ export class SkillStore extends UiErrorState<HttpError> {
|
|||
this.skill.datasetId = id;
|
||||
}
|
||||
edtDrawer(drawerName: DrawersSkill, status: boolean): void {
|
||||
this.titleDrawer = drawerName;
|
||||
this.drawers = this.drawers.map((el) => {
|
||||
if (el.name === drawerName) {
|
||||
el.status = status;
|
||||
|
@ -101,4 +111,20 @@ export class SkillStore extends UiErrorState<HttpError> {
|
|||
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) => {
|
||||
React.useEffect(() => {
|
||||
socketListerStore.init();
|
||||
}, []);
|
||||
return (
|
||||
<div>
|
||||
{/* {socketListerStore.socketHasDisconnect ? (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue