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

editoast: add field weight to op #9775

Merged
merged 1 commit into from
Dec 6, 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class RJSInfra {
public static final JsonAdapter<RJSInfra> adapter =
new Moshi.Builder().add(ID.Adapter.FACTORY).build().adapter(RJSInfra.class);

public static final transient String CURRENT_VERSION = "3.4.11";
public static final transient String CURRENT_VERSION = "3.4.13";

/** The version of the infra format used */
public String version;
Expand Down
2 changes: 2 additions & 0 deletions editoast/editoast_schemas/src/infra/operational_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ pub struct OperationalPoint {
#[serde(default)]
#[schema(inline)]
pub extensions: OperationalPointExtensions,
#[serde(default)]
pub weight: Option<u8>,
}

#[derive(Debug, Derivative, Clone, Deserialize, Serialize, ToSchema)]
Expand Down
2 changes: 1 addition & 1 deletion editoast/editoast_schemas/src/infra/railjson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use super::Switch;
use super::SwitchType;
use super::TrackSection;

pub const RAILJSON_VERSION: &str = "3.4.12";
pub const RAILJSON_VERSION: &str = "3.4.13";

editoast_common::schemas! {
RailJson,
Expand Down
5 changes: 5 additions & 0 deletions editoast/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7291,6 +7291,11 @@ components:
type: array
items:
$ref: '#/components/schemas/OperationalPointPart'
weight:
type: integer
format: int32
nullable: true
minimum: 0
additionalProperties: false
OperationalPointExtensions:
type: object
Expand Down
1 change: 1 addition & 0 deletions editoast/osm_to_railjson/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ pub fn operational_points(
identifier: identifier(&rel.tags),
sncf: None,
},
weight: None,
})
}
})
Expand Down
1 change: 1 addition & 0 deletions front/src/common/api/generatedEditoastApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1992,6 +1992,7 @@ export type OperationalPoint = {
};
id: string;
parts: OperationalPointPart[];
weight?: number | null;
};
export type Waypoint =
| {
Expand Down
18 changes: 16 additions & 2 deletions front/src/reducers/osrdconf/infra_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,20 @@
},
"title": "Parts",
"type": "array"
},
"weight": {
"anyOf": [
{
"minimum": 0,
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "represents the significance of a PR",
"title": "Weight"
}
},
"required": [
Expand Down Expand Up @@ -2165,8 +2179,8 @@
"type": "array"
},
"version": {
"const": "3.4.12",
"default": "3.4.12",
"const": "3.4.13",
"default": "3.4.13",
"description": "Version of the schema",
"title": "Version"
}
Expand Down
2 changes: 1 addition & 1 deletion front/tests/assets/infra/infra.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.4.12",
"version": "3.4.13",
"track_sections": [
{
"id": "TA1",
Expand Down
3 changes: 2 additions & 1 deletion python/osrd_schemas/osrd_schemas/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

ALL_OBJECT_TYPES = []

RAILJSON_INFRA_VERSION_TYPE = Literal["3.4.12"]
RAILJSON_INFRA_VERSION_TYPE = Literal["3.4.13"]
RAILJSON_INFRA_VERSION = get_args(RAILJSON_INFRA_VERSION_TYPE)[0]

# Traits
Expand Down Expand Up @@ -197,6 +197,7 @@ class OperationalPoint(BaseObjectTrait):
"""

parts: List[OperationalPointPart]
weight: Optional[int] = Field(description="represents the significance of a PR", ge=0, default=None)


class TrackEndpoint(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion python/railjson_generator/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.4.8"

[tool.poetry]
name = "railjson_generator"
version = "0.4.8"
version = "0.4.9"
description = ""
authors = ["OSRD <[email protected]>"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Infra:
electrifications: List[Electrification] = field(default_factory=list)
neutral_sections: List[NeutralSection] = field(default_factory=list)

VERSION = "3.4.12"
VERSION = "3.4.13"

def add_route(self, *args, **kwargs):
self.routes.append(Route(*args, **kwargs))
Expand Down Expand Up @@ -88,6 +88,7 @@ def make_rjs_operational_points(self):
),
"identifier": infra.OperationalPointIdentifierExtension(uic=op.uic, name=op.label),
},
weight=None,
)
ops.append(new_op)
return ops
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ class OperationalPoint:
label: str
trigram: str
parts: List
weight: Optional[int]
uic: int

def __init__(self, label: str, trigram: Optional[str] = None, uic: int = 0):
def __init__(self, label: str, trigram: Optional[str] = None, uic: int = 0, weight: Optional[int] = None):
self.label = label
self.trigram = trigram or label[:3].upper()
self.parts = list()
self.uic = uic
self.weight = weight

def add_part(self, track, offset):
op_part = OperationalPointPart(self, offset)
Expand Down
2 changes: 1 addition & 1 deletion tests/data/infras/circle_infra/infra.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.4.12",
"version": "3.4.13",
"operational_points": [],
"routes": [],
"extended_switch_types": [],
Expand Down
3 changes: 2 additions & 1 deletion tests/data/infras/example_script/infra.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.4.12",
"version": "3.4.13",
"operational_points": [
{
"id": "my-op",
Expand All @@ -13,6 +13,7 @@
"position": 500.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand Down
2 changes: 1 addition & 1 deletion tests/data/infras/nested_switches/infra.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.4.12",
"version": "3.4.13",
"operational_points": [],
"routes": [
{
Expand Down
2 changes: 1 addition & 1 deletion tests/data/infras/one_line/infra.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.4.12",
"version": "3.4.13",
"operational_points": [],
"routes": [
{
Expand Down
6 changes: 5 additions & 1 deletion tests/data/infras/overlapping_routes/infra.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.4.12",
"version": "3.4.13",
"operational_points": [
{
"id": "op.a1",
Expand All @@ -9,6 +9,7 @@
"position": 0.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand All @@ -31,6 +32,7 @@
"position": 1000.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand All @@ -53,6 +55,7 @@
"position": 0.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand All @@ -75,6 +78,7 @@
"position": 1000.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand Down
10 changes: 9 additions & 1 deletion tests/data/infras/small_infra/infra.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.4.12",
"version": "3.4.13",
"operational_points": [
{
"id": "West_station",
Expand All @@ -17,6 +17,7 @@
"position": 500.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand All @@ -39,6 +40,7 @@
"position": 500.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand Down Expand Up @@ -73,6 +75,7 @@
"position": 450.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand All @@ -99,6 +102,7 @@
"position": 14000.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand All @@ -125,6 +129,7 @@
"position": 1025.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand All @@ -147,6 +152,7 @@
"position": 4300.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand All @@ -173,6 +179,7 @@
"position": 1500.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand All @@ -195,6 +202,7 @@
"position": 4400.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand Down
2 changes: 1 addition & 1 deletion tests/data/infras/three_trains/infra.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.4.12",
"version": "3.4.13",
"operational_points": [],
"routes": [
{
Expand Down
4 changes: 3 additions & 1 deletion tests/data/infras/tiny_infra/infra.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.4.12",
"version": "3.4.13",
"operational_points": [
{
"id": "op.station_foo",
Expand All @@ -13,6 +13,7 @@
"position": 100.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand All @@ -35,6 +36,7 @@
"position": 100.0
}
],
"weight": null,
"extensions": {
"sncf": {
"ci": 0,
Expand Down
Loading