From b4a080220b2e5d4717f09e67ce78e42ca9ff2dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Henriot?= Date: Thu, 8 Feb 2024 11:59:04 +0100 Subject: [PATCH] core, editoast: allow to customize pathfinding timeout --- core/openapi.yaml | 4 ++ .../osrd/cli/StandaloneSimulationCommand.java | 3 +- .../pathfinding/PathfindingBlocksEndpoint.kt | 13 +++-- .../pathfinding/request/PathfindingRequest.kt | 3 +- .../kotlin/fr/sncf/osrd/graph/Pathfinding.kt | 4 +- .../sncf/osrd/utils/graph/PathfindingTests.kt | 6 +-- .../PathfindingElectrificationTest.kt | 38 +++++++++++--- .../pathfinding/PathfindingSignalingTest.kt | 11 +++-- .../sncf/osrd/pathfinding/PathfindingTest.kt | 49 +++++++++++-------- editoast/openapi.yaml | 4 ++ editoast/src/core/pathfinding.rs | 4 +- editoast/src/views/pathfinding/mod.rs | 3 +- editoast/src/views/timetable/import.rs | 7 ++- front/src/common/api/osrdEditoastApi.ts | 1 + 14 files changed, 107 insertions(+), 43 deletions(-) diff --git a/core/openapi.yaml b/core/openapi.yaml index c044f03dbc8..a44ca8ab4f9 100644 --- a/core/openapi.yaml +++ b/core/openapi.yaml @@ -747,6 +747,10 @@ components: offset: 138.32 rolling_stocks: $ref: "#/components/schemas/RollingStock" + timeout: + type: number + nullable: true + format: double STDCMRequest: properties: infra: diff --git a/core/src/main/java/fr/sncf/osrd/cli/StandaloneSimulationCommand.java b/core/src/main/java/fr/sncf/osrd/cli/StandaloneSimulationCommand.java index ea34188fddd..4b9dcdf22b7 100644 --- a/core/src/main/java/fr/sncf/osrd/cli/StandaloneSimulationCommand.java +++ b/core/src/main/java/fr/sncf/osrd/cli/StandaloneSimulationCommand.java @@ -101,7 +101,8 @@ public int run() { var results = new HashMap(); for (var trainScheduleGroup : input.trainScheduleGroups) { logger.info("Running simulation for schedule group: {}", trainScheduleGroup.id); - var rawPathfindingResult = runPathfinding(infra, trainScheduleGroup.waypoints, rollingStocks.values()); + var rawPathfindingResult = + runPathfinding(infra, trainScheduleGroup.waypoints, rollingStocks.values(), null); var pathfindingResult = convertPathfindingResult( infra.blockInfra(), infra.rawInfra(), rawPathfindingResult, diagnosticRecorder); var routePath = pathfindingResult.routePaths.stream() diff --git a/core/src/main/kotlin/fr/sncf/osrd/api/pathfinding/PathfindingBlocksEndpoint.kt b/core/src/main/kotlin/fr/sncf/osrd/api/pathfinding/PathfindingBlocksEndpoint.kt index e2a58a7b55b..67f4fe31782 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/api/pathfinding/PathfindingBlocksEndpoint.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/api/pathfinding/PathfindingBlocksEndpoint.kt @@ -61,7 +61,8 @@ class PathfindingBlocksEndpoint(private val infraManager: InfraManager) : Take { RJSRollingStockParser.parse(rjsRollingStock) } .toList() - val path = runPathfinding(infra, reqWaypoints, rollingStocks) + val timeout = request.timeout + val path = runPathfinding(infra, reqWaypoints, rollingStocks, timeout) val res = convertPathfindingResult(infra.blockInfra, infra.rawInfra, path, recorder) validatePathfindingResult(res, reqWaypoints, infra.rawInfra) RsJson(RsWithBody(PathfindingResult.adapterResult.toJson(res))) @@ -200,7 +201,8 @@ private fun isWaypointOnTrack( fun runPathfinding( infra: FullInfra, reqWaypoints: Array>, - rollingStocks: Collection? + rollingStocks: Collection?, + timeout: Double? ): PathfindingResultId { // Parse the waypoints val waypoints = ArrayList>>() @@ -222,7 +224,7 @@ fun runPathfinding( val remainingDistanceEstimators = makeHeuristics(infra, waypoints) // Compute the paths from the entry waypoint to the exit waypoint - return computePaths(infra, waypoints, constraints, remainingDistanceEstimators) + return computePaths(infra, waypoints, constraints, remainingDistanceEstimators, timeout) } /** Initialize the heuristics */ @@ -267,10 +269,12 @@ private fun computePaths( infra: FullInfra, waypoints: ArrayList>>, constraints: List>, - remainingDistanceEstimators: List> + remainingDistanceEstimators: List>, + timeout: Double? ): PathfindingResultId { val pathFound = Pathfinding(GraphAdapter(infra.blockInfra, infra.rawInfra)) + .setTimeout(timeout) .setEdgeToLength { block: BlockId -> infra.blockInfra.getBlockLength(block) } .setRemainingDistanceEstimator(remainingDistanceEstimators) .addBlockedRangeOnEdges(constraints) @@ -289,6 +293,7 @@ private fun computePaths( if (possiblePathWithoutErrorNoConstraints != null) { for (currentConstraint in constraints) { Pathfinding(GraphAdapter(infra.blockInfra, infra.rawInfra)) + .setTimeout(timeout) .setEdgeToLength { block: BlockId -> infra.blockInfra.getBlockLength(block) } .addBlockedRangeOnEdges(currentConstraint) .setRemainingDistanceEstimator(remainingDistanceEstimators) diff --git a/core/src/main/kotlin/fr/sncf/osrd/api/pathfinding/request/PathfindingRequest.kt b/core/src/main/kotlin/fr/sncf/osrd/api/pathfinding/request/PathfindingRequest.kt index 9ab2bcdf291..c60656db95f 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/api/pathfinding/request/PathfindingRequest.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/api/pathfinding/request/PathfindingRequest.kt @@ -20,7 +20,8 @@ class PathfindingRequest /** expectedVersion The expected infrastructure version */ @Json(name = "expected_version") var expectedVersion: String, /** List of rolling stocks that must be able to use this path */ - @Json(name = "rolling_stocks") var rollingStocks: List + @Json(name = "rolling_stocks") var rollingStocks: List, + var timeout: Double? ) { companion object { diff --git a/core/src/main/kotlin/fr/sncf/osrd/graph/Pathfinding.kt b/core/src/main/kotlin/fr/sncf/osrd/graph/Pathfinding.kt index 73955a55cc3..1aa9f897b8c 100644 --- a/core/src/main/kotlin/fr/sncf/osrd/graph/Pathfinding.kt +++ b/core/src/main/kotlin/fr/sncf/osrd/graph/Pathfinding.kt @@ -143,8 +143,8 @@ class Pathfinding( } /** Sets the pathfinding's timeout */ - fun setTimeout(timeout: Double): Pathfinding { - this.timeout = timeout + fun setTimeout(timeout: Double?): Pathfinding { + if (timeout != null) this.timeout = timeout return this } diff --git a/core/src/test/java/fr/sncf/osrd/utils/graph/PathfindingTests.kt b/core/src/test/java/fr/sncf/osrd/utils/graph/PathfindingTests.kt index 1273f3ed8fc..8c010dcb0f3 100644 --- a/core/src/test/java/fr/sncf/osrd/utils/graph/PathfindingTests.kt +++ b/core/src/test/java/fr/sncf/osrd/utils/graph/PathfindingTests.kt @@ -650,14 +650,14 @@ class PathfindingTests { } @ParameterizedTest - @CsvSource("0, true", "10, false") - fun pathfindingTimesOut(timeout: Long, timesOut: Boolean) { + @CsvSource("0, true", "10, false", ", false") + fun pathfindingTimesOut(timeout: Long?, timesOut: Boolean) { val builder = SimpleGraphBuilder() builder.makeNodes(2) builder.makeEdge(0, 1, 100.meters) val g = builder.build() val pathfinding = - Pathfinding(g).setEdgeToLength { edge -> edge.length }.setTimeout(timeout.toDouble()) + Pathfinding(g).setEdgeToLength { edge -> edge.length }.setTimeout(timeout?.toDouble()) if (!timesOut) { val res = pathfinding.runPathfindingEdgesOnly(listOf(listOf(builder.getEdgeLocation("0-1")))) diff --git a/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingElectrificationTest.kt b/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingElectrificationTest.kt index 7b6f4b24df5..fdef672bd7c 100644 --- a/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingElectrificationTest.kt +++ b/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingElectrificationTest.kt @@ -46,7 +46,12 @@ class PathfindingElectrificationTest : ApiTest() { // Run a pathfinding with a non-electric train val normalPath = - runPathfinding(infra.fullInfra(), waypoints, listOf(TestTrains.REALISTIC_FAST_TRAIN)) + runPathfinding( + infra.fullInfra(), + waypoints, + listOf(TestTrains.REALISTIC_FAST_TRAIN), + null + ) Assertions.assertNotNull(normalPath) assert(TestTrains.FAST_ELECTRIC_TRAIN.modeNames.contains("25000V")) for (block in infra.blockPool) block.voltage = "25000V" @@ -60,7 +65,12 @@ class PathfindingElectrificationTest : ApiTest() { // Run another pathfinding with an electric train val electricPath = - runPathfinding(infra.fullInfra(), waypoints, listOf(TestTrains.FAST_ELECTRIC_TRAIN)) + runPathfinding( + infra.fullInfra(), + waypoints, + listOf(TestTrains.FAST_ELECTRIC_TRAIN), + null + ) Assertions.assertNotNull(electricPath) // We check that the path is different, we need to avoid the non-electrified track @@ -80,7 +90,12 @@ class PathfindingElectrificationTest : ApiTest() { for (block in infra.blockPool) block.voltage = "" val exception = Assertions.assertThrows(OSRDError::class.java) { - runPathfinding(infra.fullInfra(), waypoints, listOf(TestTrains.FAST_ELECTRIC_TRAIN)) + runPathfinding( + infra.fullInfra(), + waypoints, + listOf(TestTrains.FAST_ELECTRIC_TRAIN), + null + ) } Assertions.assertEquals(exception.osrdErrorType, ErrorType.PathfindingElectrificationError) } @@ -103,7 +118,12 @@ class PathfindingElectrificationTest : ApiTest() { // Run a pathfinding with a non-electric train val normalPath = - runPathfinding(infra.fullInfra(), waypoints, listOf(TestTrains.REALISTIC_FAST_TRAIN)) + runPathfinding( + infra.fullInfra(), + waypoints, + listOf(TestTrains.REALISTIC_FAST_TRAIN), + null + ) Assertions.assertNotNull(normalPath) assert(TestTrains.FAST_ELECTRIC_TRAIN.modeNames.contains("25000V")) for (block in infra.blockPool) block.voltage = "25000V" @@ -126,7 +146,12 @@ class PathfindingElectrificationTest : ApiTest() { ) { // Run another pathfinding with an electric train val electricPath = - runPathfinding(infra.fullInfra(), waypoints, listOf(TestTrains.FAST_ELECTRIC_TRAIN)) + runPathfinding( + infra.fullInfra(), + waypoints, + listOf(TestTrains.FAST_ELECTRIC_TRAIN), + null + ) Assertions.assertNotNull(electricPath) } else { val exception = @@ -134,7 +159,8 @@ class PathfindingElectrificationTest : ApiTest() { runPathfinding( infra.fullInfra(), waypoints, - listOf(TestTrains.FAST_ELECTRIC_TRAIN) + listOf(TestTrains.FAST_ELECTRIC_TRAIN), + null ) } Assertions.assertEquals( diff --git a/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingSignalingTest.kt b/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingSignalingTest.kt index 917dd709ad6..6869ef04dfb 100644 --- a/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingSignalingTest.kt +++ b/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingSignalingTest.kt @@ -61,7 +61,12 @@ class PathfindingSignalingTest { // Run a pathfinding with a non TVM train, expecting not to find any path AssertionsForClassTypes.assertThatThrownBy { - runPathfinding(infra.fullInfra(), waypoints, listOf(TestTrains.TRAIN_WITHOUT_TVM)) + runPathfinding( + infra.fullInfra(), + waypoints, + listOf(TestTrains.TRAIN_WITHOUT_TVM), + null + ) } .isExactlyInstanceOf(OSRDError::class.java) .satisfies({ exception: Throwable? -> @@ -80,7 +85,7 @@ class PathfindingSignalingTest { waypoints[1][0] = waypointEnd val pathfindingResult = - runPathfinding(infra.fullInfra(), waypoints, listOf(TestTrains.TRAIN_WITHOUT_TVM)) + runPathfinding(infra.fullInfra(), waypoints, listOf(TestTrains.TRAIN_WITHOUT_TVM), null) AssertionsForClassTypes.assertThat(pathfindingResult.ranges) .isEqualTo( @@ -102,7 +107,7 @@ class PathfindingSignalingTest { waypoints[1][0] = waypointEnd val pathfindingResult = - runPathfinding(infra.fullInfra(), waypoints, listOf(TestTrains.TRAIN_WITHOUT_TVM)) + runPathfinding(infra.fullInfra(), waypoints, listOf(TestTrains.TRAIN_WITHOUT_TVM), null) AssertionsForClassTypes.assertThat(pathfindingResult.ranges) .isEqualTo( diff --git a/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingTest.kt b/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingTest.kt index 45d0bafe6cf..3e7ec1be98b 100644 --- a/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingTest.kt +++ b/core/src/test/kotlin/fr/sncf/osrd/pathfinding/PathfindingTest.kt @@ -58,7 +58,7 @@ class PathfindingTest : ApiTest() { waypoints[1] = waypointsEnd val requestBody = PathfindingRequest.adapter.toJson( - PathfindingRequest(waypoints, "tiny_infra/infra.json", "1", listOf()) + PathfindingRequest(waypoints, "tiny_infra/infra.json", "1", listOf(), null) ) val result = TakesUtils.readBodyResponse( @@ -140,7 +140,7 @@ class PathfindingTest : ApiTest() { waypoints[2] = makeBidirectionalEndPoint(waypointEnd) val requestBody = PathfindingRequest.adapter.toJson( - PathfindingRequest(waypoints, "tiny_infra/infra.json", "1", listOf()) + PathfindingRequest(waypoints, "tiny_infra/infra.json", "1", listOf(), null) ) val result = TakesUtils.readBodyResponse( @@ -223,7 +223,7 @@ class PathfindingTest : ApiTest() { waypoints[1][0] = waypointEnd val requestBody = PathfindingRequest.adapter.toJson( - PathfindingRequest(waypoints, "tiny_infra/infra.json", "1", listOf()) + PathfindingRequest(waypoints, "tiny_infra/infra.json", "1", listOf(), null) ) val res = TakesUtils.readHeadResponse( @@ -232,7 +232,9 @@ class PathfindingTest : ApiTest() { ) AssertionsForClassTypes.assertThat(res[0]).contains("400") val infra = Helpers.tinyInfra - AssertionsForClassTypes.assertThatThrownBy { runPathfinding(infra, waypoints, listOf()) } + AssertionsForClassTypes.assertThatThrownBy { + runPathfinding(infra, waypoints, listOf(), null) + } .isExactlyInstanceOf(OSRDError::class.java) .satisfies({ exception -> AssertionsForClassTypes.assertThat((exception as OSRDError?)!!.osrdErrorType) @@ -249,7 +251,7 @@ class PathfindingTest : ApiTest() { val waypoints = Array(2) { Array(1) { waypoint } } val requestBody = PathfindingRequest.adapter.toJson( - PathfindingRequest(waypoints, "tiny_infra/infra.json", "1", listOf()) + PathfindingRequest(waypoints, "tiny_infra/infra.json", "1", listOf(), null) ) val response = PathfindingBlocksEndpoint(infraManager) @@ -257,7 +259,9 @@ class PathfindingTest : ApiTest() { val res = TakesUtils.readHeadResponse(response) AssertionsForClassTypes.assertThat(res[0]).contains("400") val infra = Helpers.tinyInfra - AssertionsForClassTypes.assertThatThrownBy { runPathfinding(infra, waypoints, listOf()) } + AssertionsForClassTypes.assertThatThrownBy { + runPathfinding(infra, waypoints, listOf(), null) + } .isExactlyInstanceOf(OSRDError::class.java) .satisfies({ exception -> AssertionsForClassTypes.assertThat((exception as OSRDError?)!!.osrdErrorType) @@ -282,12 +286,12 @@ class PathfindingTest : ApiTest() { val infra = Helpers.fullInfraFromRJS(rjsInfra) // Check that we can go through the infra with a small train - assertThat(runPathfinding(infra, waypoints, listOf(TestTrains.REALISTIC_FAST_TRAIN))) + assertThat(runPathfinding(infra, waypoints, listOf(TestTrains.REALISTIC_FAST_TRAIN), null)) .isNotNull() // Check that we can't go through the infra with a large train AssertionsForClassTypes.assertThatThrownBy { - runPathfinding(infra, waypoints, listOf(TestTrains.FAST_TRAIN_LARGE_GAUGE)) + runPathfinding(infra, waypoints, listOf(TestTrains.FAST_TRAIN_LARGE_GAUGE), null) } .isExactlyInstanceOf(OSRDError::class.java) .satisfies({ exception -> @@ -300,7 +304,9 @@ class PathfindingTest : ApiTest() { // Check that we can go until right before the blocked section with a large train waypoints[1][0] = PathfindingWaypoint("ne.micro.foo_to_bar", 999.0, EdgeDirection.START_TO_STOP) - assertThat(runPathfinding(infra, waypoints, listOf(TestTrains.FAST_TRAIN_LARGE_GAUGE))) + assertThat( + runPathfinding(infra, waypoints, listOf(TestTrains.FAST_TRAIN_LARGE_GAUGE), null) + ) .isNotNull() } @@ -315,7 +321,8 @@ class PathfindingTest : ApiTest() { // Run a pathfinding with a non-electric train val infra = Helpers.fullInfraFromRJS(rjsInfra) - val normalPath = runPathfinding(infra, waypoints, listOf(TestTrains.REALISTIC_FAST_TRAIN)) + val normalPath = + runPathfinding(infra, waypoints, listOf(TestTrains.REALISTIC_FAST_TRAIN), null) // Replace with custom electrifications // Set voltage to 25000V everywhere except for trackSectionToBlock @@ -374,7 +381,8 @@ class PathfindingTest : ApiTest() { runPathfinding( infraWithNonElectrifiedTrack, waypoints, - listOf(TestTrains.FAST_ELECTRIC_TRAIN) + listOf(TestTrains.FAST_ELECTRIC_TRAIN), + null ) // Check that the paths are different, we need to avoid the non-electrified track @@ -396,7 +404,8 @@ class PathfindingTest : ApiTest() { runPathfinding( Helpers.fullInfraFromRJS(rjsInfra), waypoints, - listOf(TestTrains.FAST_ELECTRIC_TRAIN) + listOf(TestTrains.FAST_ELECTRIC_TRAIN), + null ) } .isExactlyInstanceOf(OSRDError::class.java) @@ -420,7 +429,7 @@ class PathfindingTest : ApiTest() { waypoints[1] = waypointsEnd val requestBody = PathfindingRequest.adapter.toJson( - PathfindingRequest(waypoints, "tiny_infra/infra.json", "", listOf()) + PathfindingRequest(waypoints, "tiny_infra/infra.json", "", listOf(), null) ) val result = TakesUtils.readBodyResponse( @@ -523,7 +532,7 @@ class PathfindingTest : ApiTest() { waypoints[1] = waypointsEnd val requestBody = PathfindingRequest.adapter.toJson( - PathfindingRequest(waypoints, "tiny_infra/infra.json", "", listOf()) + PathfindingRequest(waypoints, "tiny_infra/infra.json", "", listOf(), null) ) val result = TakesUtils.readBodyResponse( @@ -548,7 +557,7 @@ class PathfindingTest : ApiTest() { waypoints[1] = waypointsEnd val requestBody = PathfindingRequest.adapter.toJson( - PathfindingRequest(waypoints, "small_infra/infra.json", "1", listOf()) + PathfindingRequest(waypoints, "small_infra/infra.json", "1", listOf(), null) ) val result = TakesUtils.readBodyResponse( @@ -580,7 +589,7 @@ class PathfindingTest : ApiTest() { waypoints[1] = waypointsEnd val requestBody = PathfindingRequest.adapter.toJson( - PathfindingRequest(waypoints, "small_infra/infra.json", "1", listOf()) + PathfindingRequest(waypoints, "small_infra/infra.json", "1", listOf(), null) ) val result = TakesUtils.readBodyResponse( @@ -612,7 +621,7 @@ class PathfindingTest : ApiTest() { waypoints[1] = waypointsEnd val requestBody = PathfindingRequest.adapter.toJson( - PathfindingRequest(waypoints, "small_infra/infra.json", "1", listOf()) + PathfindingRequest(waypoints, "small_infra/infra.json", "1", listOf(), null) ) val result = TakesUtils.readBodyResponse( @@ -656,7 +665,7 @@ class PathfindingTest : ApiTest() { waypoints[1] = waypointsEnd val requestBody = PathfindingRequest.adapter.toJson( - PathfindingRequest(waypoints, "small_infra/infra.json", "1", listOf()) + PathfindingRequest(waypoints, "small_infra/infra.json", "1", listOf(), null) ) val result = TakesUtils.readBodyResponse( @@ -714,7 +723,7 @@ class PathfindingTest : ApiTest() { ) val infra = Helpers.fullInfraFromRJS(rjsInfra) - val path = runPathfinding(infra, waypoints, listOf(TestTrains.REALISTIC_FAST_TRAIN)) + val path = runPathfinding(infra, waypoints, listOf(TestTrains.REALISTIC_FAST_TRAIN), null) val res = convertPathfindingResult( infra.blockInfra, @@ -868,7 +877,7 @@ class PathfindingTest : ApiTest() { val endIndex = if (inverted) 0 else 1 waypoints[startIndex] = scheduleGroup.waypoints[0] waypoints[endIndex] = scheduleGroup.waypoints[scheduleGroup.waypoints.size - 1] - return PathfindingRequest(waypoints, infraPath, "", listOf()) + return PathfindingRequest(waypoints, infraPath, "", listOf(), null) } } } diff --git a/editoast/openapi.yaml b/editoast/openapi.yaml index d026fede6da..5d04e7331d1 100644 --- a/editoast/openapi.yaml +++ b/editoast/openapi.yaml @@ -3368,6 +3368,10 @@ components: items: $ref: '#/components/schemas/TimetableImportPathStep' type: array + pathfinding_timeout: + format: double + nullable: true + type: number rolling_stock: example: 2TGV2N2 type: string diff --git a/editoast/src/core/pathfinding.rs b/editoast/src/core/pathfinding.rs index f14d1d890ce..511054f9c7f 100644 --- a/editoast/src/core/pathfinding.rs +++ b/editoast/src/core/pathfinding.rs @@ -18,6 +18,7 @@ pub struct PathfindingRequest { expected_version: String, waypoints: PathfindingWaypoints, rolling_stocks: Vec, + timeout: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] @@ -81,12 +82,13 @@ impl Waypoint { } impl PathfindingRequest { - pub fn new(infra: i64, expected_version: String) -> Self { + pub fn new(infra: i64, expected_version: String, timeout: Option) -> Self { Self { infra, expected_version, waypoints: Default::default(), rolling_stocks: Default::default(), + timeout, } } diff --git a/editoast/src/views/pathfinding/mod.rs b/editoast/src/views/pathfinding/mod.rs index fd0c37a7c30..1aee5b2efce 100644 --- a/editoast/src/views/pathfinding/mod.rs +++ b/editoast/src/views/pathfinding/mod.rs @@ -428,7 +428,8 @@ async fn call_core_pf_and_save_result( let track_map = payload.fetch_track_map(conn).await?; let mut waypoints = payload.parse_waypoints(&track_map)?; let mut rolling_stocks = payload.parse_rolling_stocks(conn).await?; - let mut path_request = CorePathfindingRequest::new(infra.id.unwrap(), infra.version.unwrap()); + let mut path_request = + CorePathfindingRequest::new(infra.id.unwrap(), infra.version.unwrap(), None); path_request .with_waypoints(&mut waypoints) .with_rolling_stocks(&mut rolling_stocks); diff --git a/editoast/src/views/timetable/import.rs b/editoast/src/views/timetable/import.rs index 4ffb7435a7a..01ca115375c 100644 --- a/editoast/src/views/timetable/import.rs +++ b/editoast/src/views/timetable/import.rs @@ -45,6 +45,7 @@ pub struct TimetableImportItem { rolling_stock: String, path: Vec, trains: Vec, + pathfinding_timeout: Option, } #[derive(Debug, Clone, Deserialize, ToSchema)] @@ -196,7 +197,11 @@ async fn import_item( let rolling_stock: RollingStock = rolling_stock_model.into(); // PATHFINDING - let mut pf_request = PathfindingRequest::new(infra_id, infra_version.to_owned()); + let mut pf_request = PathfindingRequest::new( + infra_id, + infra_version.to_owned(), + import_item.pathfinding_timeout, + ); pf_request.with_rolling_stocks(&mut vec![rolling_stock.clone()]); let ops_uic = ops_uic_from_path(&import_item.path); let ops_id = ops_id_from_path(&import_item.path); diff --git a/front/src/common/api/osrdEditoastApi.ts b/front/src/common/api/osrdEditoastApi.ts index 00a68d5d7f1..da374ae9c07 100644 --- a/front/src/common/api/osrdEditoastApi.ts +++ b/front/src/common/api/osrdEditoastApi.ts @@ -2354,6 +2354,7 @@ export type TimetableImportTrain = { }; export type TimetableImportItem = { path: TimetableImportPathStep[]; + pathfinding_timeout?: number | null; rolling_stock: string; trains: TimetableImportTrain[]; };