Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: miscellaneous cleanup (rm /cache_status) #9644

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public int run() {
new FkRegex("/v2/signal_projection", new SignalProjectionEndpointV2(infraManager)),
new FkRegex("/detect_conflicts", new ConflictDetectionEndpoint()),
new FkRegex("/v2/conflict_detection", new ConflictDetectionEndpointV2(infraManager)),
new FkRegex("/cache_status", new InfraCacheStatusEndpoint(infraManager)),
new FkRegex("/version", new VersionEndpoint()),
new FkRegex("/stdcm", new STDCMEndpoint(infraManager)),
new FkRegex("/v2/stdcm", new STDCMEndpointV2(infraManager)),
Expand Down
9 changes: 0 additions & 9 deletions core/src/main/java/fr/sncf/osrd/cli/WorkerCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import fr.sncf.osrd.api.api_v2.pathfinding.PathfindingBlocksEndpointV2
import fr.sncf.osrd.api.api_v2.project_signals.SignalProjectionEndpointV2
import fr.sncf.osrd.api.api_v2.standalone_sim.SimulationEndpoint
import fr.sncf.osrd.api.api_v2.stdcm.STDCMEndpointV2
import fr.sncf.osrd.api.pathfinding.PathfindingBlocksEndpoint
import fr.sncf.osrd.api.stdcm.STDCMEndpoint
import fr.sncf.osrd.reporting.exceptions.ErrorType
import fr.sncf.osrd.reporting.exceptions.OSRDError
import fr.sncf.osrd.reporting.warnings.DiagnosticRecorderImpl
Expand Down Expand Up @@ -120,20 +118,13 @@ class WorkerCommand : CliCommand {

val endpoints =
mapOf(
"/pathfinding/routes" to PathfindingBlocksEndpoint(infraManager),
"/v2/pathfinding/blocks" to PathfindingBlocksEndpointV2(infraManager),
"/v2/path_properties" to PathPropEndpoint(infraManager),
"/standalone_simulation" to
StandaloneSimulationEndpoint(infraManager, electricalProfileSetManager),
"/v2/standalone_simulation" to
SimulationEndpoint(infraManager, electricalProfileSetManager),
"/project_signals" to SignalProjectionEndpoint(infraManager),
"/v2/signal_projection" to SignalProjectionEndpointV2(infraManager),
"/detect_conflicts" to ConflictDetectionEndpoint(),
"/v2/conflict_detection" to ConflictDetectionEndpointV2(infraManager),
"/cache_status" to InfraCacheStatusEndpoint(infraManager),
"/version" to VersionEndpoint(),
"/stdcm" to STDCMEndpoint(infraManager),
"/v2/stdcm" to STDCMEndpointV2(infraManager),
"/infra_load" to InfraLoadEndpoint(infraManager),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import fr.sncf.osrd.sim_infra.api.RawSignalingInfra
import fr.sncf.osrd.utils.DistanceRangeMap
import fr.sncf.osrd.utils.buildElectrificationMap
import fr.sncf.osrd.utils.units.Distance.Companion.toMeters
import java.util.function.BiFunction

object EnvelopeTrainPath {
/** Create EnvelopePath from a path and a ElectricalProfileMapping */
Expand Down Expand Up @@ -59,13 +58,12 @@ object EnvelopeTrainPath {
val res = mutableMapOf<String, DistanceRangeMap<Electrification>>()
for (entry in profileMap.entries) {
val electrificationMapWithProfiles = electrificationMap.clone()
electrificationMapWithProfiles.updateMap<String>(
entry.value,
BiFunction { obj: Electrification, profile: String ->
obj.withElectricalProfile(profile)
}
)
res.put(entry.key, electrificationMapWithProfiles)
electrificationMapWithProfiles.updateMap(entry.value) {
obj: Electrification,
profile: String ->
obj.withElectricalProfile(profile)
}
res[entry.key] = electrificationMapWithProfiles
}
return res
}
Expand All @@ -76,9 +74,9 @@ object EnvelopeTrainPath {
): ImmutableRangeMap<Double, Electrification> {
val res = TreeRangeMap.create<Double, Electrification>()
for (entry in map.asList()) {
res.put(Range.closed<Double>(toMeters(entry.lower), toMeters(entry.upper)), entry.value)
res.put(Range.closed(toMeters(entry.lower), toMeters(entry.upper)), entry.value)
}
return ImmutableRangeMap.copyOf<Double, Electrification>(res)
return ImmutableRangeMap.copyOf(res)
}

/** Converts an ElectrificationMapByPowerClass as a DistanceRangeMap into a RangeMap */
Expand All @@ -87,7 +85,7 @@ object EnvelopeTrainPath {
): Map<String, ImmutableRangeMap<Double, Electrification>> {
val res = mutableMapOf<String, ImmutableRangeMap<Double, Electrification>>()
for (entry in electrificationMapByPowerClass.entries) {
res.put(entry.key, convertElectrificationMap(entry.value))
res[entry.key] = convertElectrificationMap(entry.value)
}
return res
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ fun computeMRSP(
attrs.add(speedLimitProp.source)
}
if (attrs.any { it is UnknownTag }) attrs.add(HasMissingSpeedTag)
if (speed != 0.0) // Add the envelope part corresponding to the restricted speed section
if (speed != 0.0) {
// Add the envelope part corresponding to the restricted speed section
builder.addPart(
EnvelopePart.generateTimes(
attrs,
doubleArrayOf(start, end),
doubleArrayOf(speed, speed)
)
)
}
}

// Add a limit corresponding to the hardware's maximum operational speed
Expand Down
40 changes: 0 additions & 40 deletions core/src/test/java/fr/sncf/osrd/api/InfraCacheStatusTest.java

This file was deleted.

18 changes: 4 additions & 14 deletions editoast/src/views/infra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -957,16 +957,11 @@ pub mod tests {
#[rstest]
async fn infra_get() {
let db_pool = DbConnectionPoolV2::for_tests();
let mut core = MockingClient::new();
core.stub("/cache_status")
.method(reqwest::Method::POST)
.response(StatusCode::OK)
.body("{}")
.finish();
let core_client = CoreClient::Mocked(MockingClient::default());

let app = TestAppBuilder::new()
.db_pool(db_pool.clone())
.core_client(core.into())
.core_client(core_client)
.build();
let empty_infra = create_empty_infra(&mut db_pool.get_ok()).await;

Expand Down Expand Up @@ -1160,16 +1155,11 @@ pub mod tests {
#[rstest]
async fn infra_lock() {
let db_pool = DbConnectionPoolV2::for_tests();
let mut core = MockingClient::new();
core.stub("/cache_status")
.method(reqwest::Method::POST)
.response(StatusCode::OK)
.body("{}")
.finish();
let core_client = CoreClient::Mocked(MockingClient::default());

let app = TestAppBuilder::new()
.db_pool(db_pool.clone())
.core_client(core.into())
.core_client(core_client)
.build();
let empty_infra = create_empty_infra(&mut db_pool.get_ok()).await;

Expand Down
Loading