progress
This commit is contained in:
parent
2024834d06
commit
ea1ebe0e95
38 changed files with 1435 additions and 43 deletions
|
@ -73,6 +73,7 @@ export class SpawnProcessUseCase {
|
|||
subprocess.on("close", (code) => {
|
||||
console.log(`Процесс завершился с кодом: ${code}`);
|
||||
});
|
||||
return Result.ok('ok');
|
||||
} catch (error) {
|
||||
return Result.error(error);
|
||||
}
|
||||
|
|
|
@ -15,16 +15,14 @@ export class ExecCalculationInstanceProcessScenario extends CallbackStrategyWith
|
|||
async (model) => {
|
||||
const fileOutPath = model.instancePath.pathNormalize() + "/form.json";
|
||||
return (await new IsHaveActiveProcessUseCase().call()).map(async () => {
|
||||
const execCommand = `${
|
||||
model.script
|
||||
} --path ${model.instancePath.pathNormalize()} --form ${fileOutPath}`.replace("\n", "");
|
||||
|
||||
const execCommand = `${model.script
|
||||
} --path ${model.instancePath.pathNormalize()} --form ${fileOutPath}`.replace("\n", "");
|
||||
|
||||
await new CreateFileUseCase().call(fileOutPath, Buffer.from(JSON.stringify(model.formBuilder)));
|
||||
await CalculationInstanceDBModel.findById(id).updateOne({
|
||||
processStatus: "RUN",
|
||||
lastProcessExecCommand: execCommand,
|
||||
});
|
||||
|
||||
new ExecProcessUseCase().call(
|
||||
// @ts-expect-error
|
||||
`${model.project.rootDir}/`,
|
||||
|
|
|
@ -14,7 +14,7 @@ export class ExecSimulationUseCase extends CallbackStrategyWithValidationModel<E
|
|||
App.staticFilesStoreDir(),
|
||||
el.execCommand.replace("${dir_path}", "/Users/idontsudo/train"),
|
||||
"btBuilder",
|
||||
new ProcessWatcher(2000, "localhost")
|
||||
new ProcessWatcher()
|
||||
);
|
||||
return Result.ok("200");
|
||||
});
|
||||
|
|
|
@ -1,13 +1,29 @@
|
|||
import { CrudController } from "../../core/controllers/crud_controller";
|
||||
import { ExecRunTimeCommandValidationModel } from "./model/run_time_validation_model";
|
||||
import { ExecRuntimeDatabaseModel } from "./model/run_time_database_model";
|
||||
import { CoreHttpController, SubRouter, HttpMethodType } from "../../core/controllers/http_controller";
|
||||
import { CoreHttpController, SubRouter, HttpMethodType, CallbackStrategyWithIdQuery, ResponseBase } from "../../core/controllers/http_controller";
|
||||
import { ExecBtBuilderUseCase } from "./domain/exec_bt_builder_usecase";
|
||||
import { ExecSimulationUseCase } from "./domain/exec_simulation_usecase";
|
||||
import { GetBtBuilderStateUseCase } from "./domain/get_bt_builder_status_usecase";
|
||||
import { GetSimulationStateScenario } from "./domain/get_simulation_state_usecase";
|
||||
import { MongoIdValidation } from "../../core/validations/mongo_id_validation";
|
||||
import { CoreValidation } from "../../core/validations/core_validation";
|
||||
import { ReadByIdDataBaseModelUseCase } from "../../core/usecases/read_by_id_database_model_usecase";
|
||||
import { ICalculationInstance, CalculationInstanceDBModel } from "../calculations_instance/models/calculations_instance_database_model";
|
||||
import { Result } from "../../core/helpers/result";
|
||||
import { SpawnProcessUseCase } from "../../core/usecases/exec_process_usecase";
|
||||
import { ProcessWatcher } from "./service/process_watcher";
|
||||
|
||||
export class RunTimePresentation extends CoreHttpController<ExecRunTimeCommandValidationModel> {
|
||||
class ExecAnalyzeScenario extends CallbackStrategyWithIdQuery {
|
||||
|
||||
idValidationExpression: CoreValidation = new MongoIdValidation()
|
||||
call = async (id: string) =>
|
||||
(await new ReadByIdDataBaseModelUseCase<ICalculationInstance>(CalculationInstanceDBModel).call(id)).map(async (model) =>
|
||||
(await new SpawnProcessUseCase().call('/Users/idontsudo/webservice', `nix run github:nixos/nixpkgs#python312Packages.tensorboard -- --logdir ${model.instancePath}`, "", new ProcessWatcher())).map(() => Result.ok('ok'),),
|
||||
)
|
||||
}
|
||||
|
||||
export class RunTimePresentation extends CrudController<ExecRunTimeCommandValidationModel, any> {
|
||||
constructor() {
|
||||
super({
|
||||
url: "run_time",
|
||||
|
@ -16,6 +32,7 @@ export class RunTimePresentation extends CoreHttpController<ExecRunTimeCommandVa
|
|||
this.subRoutes.push(new SubRouter("POST", "/exec/bt/builder", new ExecBtBuilderUseCase()));
|
||||
this.subRoutes.push(new SubRouter("POST", "/get/bt/builder/state", new GetBtBuilderStateUseCase()));
|
||||
this.subRoutes.push(new SubRouter("POST", "/get/simulator/state", new GetSimulationStateScenario()));
|
||||
this.subRoutes.push(new SubRouter('POST', "exec/analyze", new ExecAnalyzeScenario()))
|
||||
this.subRoutes.push({
|
||||
method: "POST",
|
||||
subUrl: "/exec/simulation/",
|
||||
|
|
|
@ -4,19 +4,16 @@ import { ExecError, SpawnError } from "../../../core/models/exec_error_model";
|
|||
import { ExecutorResult } from "../../../core/models/executor_result";
|
||||
|
||||
export class ProcessWatcher extends TypedEvent<Result<ExecError | SpawnError, ExecutorResult>> {
|
||||
logs = "";
|
||||
delay: number;
|
||||
constructor(delay: number, pattern: string) {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.on(this.lister);
|
||||
setTimeout(() => {
|
||||
console.log(this.logs);
|
||||
}, delay);
|
||||
|
||||
}
|
||||
|
||||
lister = (event: Result<ExecError | SpawnError, ExecutorResult>) => {
|
||||
event.map(async (success) => {
|
||||
this.logs += success.data;
|
||||
console.log(success.data)
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,11 +17,7 @@ export class CreateRobotScenario extends CallbackStrategyWithValidationModel<Rob
|
|||
)
|
||||
).map((projectModel) => {
|
||||
const { rootDir } = projectModel[0];
|
||||
console.log(
|
||||
`python3 $PYTHON_ROBOT_BUILDER --path ${
|
||||
projectModel[0].rootDir + "/" + StaticFilesProject.robots + "/"
|
||||
} --name ${model.name} --nDOF ${model.nDof} --toolType ${model.toolType}`
|
||||
);
|
||||
|
||||
return new GetServerAddressUseCase().call().map(async (serverAddress) =>
|
||||
(
|
||||
await new ExecProcessUseCase().call(
|
||||
|
|
|
@ -3,7 +3,8 @@ import { App } from "./core/controllers/app";
|
|||
import { SocketSubscriber } from "./core/controllers/socket_controller";
|
||||
import { extensions } from "./core/extensions/extensions";
|
||||
import { httpRoutes } from "./core/controllers/routes";
|
||||
import { executorProgramService } from "./core/usecases/exec_process_usecase";
|
||||
import { SpawnProcessUseCase, executorProgramService } from "./core/usecases/exec_process_usecase";
|
||||
import { ProcessWatcher } from "./features/runtime/service/process_watcher";
|
||||
|
||||
extensions();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue