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 an endpoint to list infra objects #11032

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Khoyo
Copy link
Contributor

@Khoyo Khoyo commented Mar 4, 2025

No description provided.

@Khoyo Khoyo requested a review from a team as a code owner March 4, 2025 16:56
@github-actions github-actions bot added area:front Work on Standard OSRD Interface modules area:editoast Work on Editoast Service labels Mar 4, 2025
@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 25.00000% with 45 lines in your changes missing coverage. Please review.

Project coverage is 80.67%. Comparing base (0d068db) to head (8ceceae).
Report is 8 commits behind head on dev.

Files with missing lines Patch % Lines
editoast/src/views/infra/objects.rs 29.41% 24 Missing ⚠️
editoast/src/models/infra/object_queryable.rs 0.00% 19 Missing ⚠️
front/src/common/api/generatedEditoastApi.ts 71.42% 2 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #11032      +/-   ##
==========================================
- Coverage   80.69%   80.67%   -0.03%     
==========================================
  Files        1098     1098              
  Lines      111888   111972      +84     
  Branches      745      745              
==========================================
+ Hits        90290    90334      +44     
- Misses      21555    21595      +40     
  Partials       43       43              
Flag Coverage Δ
editoast 72.32% <18.86%> (-0.05%) ⬇️
front 89.93% <71.42%> (-0.01%) ⬇️
gateway 2.18% <ø> (ø)
osrdyne 2.53% <ø> (ø)
railjson_generator 87.58% <ø> (ø)
tests 87.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

tag = "infra",
params(InfraIdParam, ObjectTypeParam),
responses(
(status = 200, description = "The list of objects", body = ListObjectsResponse),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(status = 200, description = "The list of objects", body = ListObjectsResponse),
(status = 200, description = "The list of objects", body = inline(ListObjectsResponse)),

or

Suggested change
(status = 200, description = "The list of objects", body = ListObjectsResponse),
(status = 200, description = "The list of objects", body = Vec<String>),

directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, it's a "good idea" to return json objects as a top level response... (To allow adding stuff later without making it a breaking change) But i could go either way, wdyt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind an object at all, but in this case since the schema is only used at this one place better inline it

Comment on lines +137 to +138
Path(infra_id_param): Path<InfraIdParam>,
Path(object_type_param): Path<ObjectTypeParam>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Path(infra_id_param): Path<InfraIdParam>,
Path(object_type_param): Path<ObjectTypeParam>,
Path(InfraIdParam { infra_id }): Path<InfraIdParam>,
Path(ObjectTypeParam { object_type }): Path<ObjectTypeParam>,

params(InfraIdParam, ObjectTypeParam),
responses(
(status = 200, description = "The list of objects", body = ListObjectsResponse),
(status = 404, description = "Infra ID invalid")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(status = 404, description = "Infra ID invalid")

for consistency with the rest of the routes (that'll come with ViewErrors)


Ok(Json(ListObjectsResponse { ids: objects }))
}

#[cfg(test)]
mod tests {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a test would be nice

Copy link
Contributor

@woshilapin woshilapin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand yet the use case and/or the solution.

Comment on lines 24 to +25
"/objects/{object_type}" => get_objects,
"/objects/{object_type}/list" => list_objects,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me why we need both a get_objects and a list_objects. Couldn't we put the functionality directly in /objects/{object_type} (if no ID is provided in the body, it defaults to returning all of them?). In any case, it'd be nice to add a description in the PR to explain why this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we import the work schedules in OSRD, we look for their associated tracks, using GAIA. Sometimes, the track ids returned are in GAIA but not in the OSRD infrastructure. We don't want to keep these extra track ids.
To check this, we need an endpoint that returns track ids from the OSRD infrastructure. (Alternatively, the other solution would be to add another time-consuming track geometry verification step in the work schedule pipeline.)

Your suggestion would also be appropriate for this need

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The problem with the actual endpoint is that it crashes when at least one track id in the given payload is not in the OSRD infrastructure)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re why not return everything with an empty payload... That's mainly because that felt like a potential mistake waiting to happen, and that you probably do not want to download all tracksections just to get a list of ids

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we only need the list of ids, i don't know if it would be possible to return this as default behavior of the existing endpoint ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:editoast Work on Editoast Service area:front Work on Standard OSRD Interface modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants