Skip to content

Conversation

@Synar
Copy link
Contributor

@Synar Synar commented Dec 19, 2025

Graou train schedules parsing logic was spread amongst 5 different files, with functions called at various points of the importing process, without any unifying convention.

In particular, this meant we had to carry a TrainLists parameter on top of the TrainFromJson one in ImportTimetableItemList just for the purpose of storing half-formatted graou train schedules.

Instead :

  • move all Graou validation logic that can cause the request to fail to graouApi
  • move all Graou parsing/formatting logic in a single new helper file
  • fully format Graou train schedules in a single place of ImportTimetableItemConfig, as is done for json, xml and nge files
  • drop trainLists
  • simplify and document the code as much as possible

I'm not 100% sure about where the validation logic should live, and how strict we want to be with it. For example, should we really reject all train schedules because one uic was missing?

Also close #10159 by querying all chs for each step, as is done in many other places in the front. The fixup commit at the end is an alternative version of the code (which I favor, but does require a new type). Both commits can be extracted to another pr if you wish.

For reviewing, I suggest taking a look at the overall new code flow in ImportTimetableItemConfig as well as parseGraouTrains, and then go commit by commit. I tried to be as atomic as possible (perhaps too much?). Each commit compiles and runs.

Next step could be to write a couple unit tests, at least for the overall Graou import.

Edit : added a last commit that improve and standardize validation, see the commit text for details. It can be moved to another pr if you wish.

@Synar Synar requested a review from a team as a code owner December 19, 2025 10:11
@github-actions github-actions bot added the area:front Work on Standard OSRD Interface modules label Dec 19, 2025
@Synar Synar self-assigned this Dec 19, 2025
@Synar Synar moved this to Awaiting merge in Board PI 18 Dec 19, 2025
@Synar Synar removed this from Board PI 18 Dec 19, 2025
@Synar Synar requested review from clarani and emersion December 19, 2025 10:13
@Synar Synar force-pushed the ali/fix-refactor-graou-import branch from b3ac4b4 to de39021 Compare December 19, 2025 10:23
@Synar Synar moved this to Awaiting merge in Board PI 18 Dec 26, 2025
@Synar Synar force-pushed the ali/fix-refactor-graou-import branch from de39021 to 48472c8 Compare December 26, 2025 14:53
@clarani
Copy link
Contributor

clarani commented Jan 2, 2026

Can we wait for this PR to be merged before reviewing this one ?

Synar added 16 commits January 5, 2026 23:27
This is a step in centralizing all graou parsing logic,
in order to improve code maintainability and enable us to streamline the import process.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
This is a step in centralizing all graou parsing logic,
in order to improve code maintainability and enable us to streamline the import process.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
This is a step in centralizing all graou parsing logic,
in order to improve code maintainability and enable us to streamline the import process.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
This is a step in centralizing all graou parsing logic,
in order to improve code maintainability and enable us to streamline the import process.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
This is a step in centralizing all graou parsing logic,
in order to improve code maintainability and enable us to streamline the import process.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
The only difference between trainList (used for Graou) and trainJson (used for all other sources) import
was that trainList contained train schedules that were only partially parsed,
as we performed some processing of Graou trains before filling the list and some after.

There is however no good reason not to fully parse Graou trains before filling the list, and fuse trainList into trainJson.

This lets us both:
- simplify the properties and logic of ImportTimetableItemTrainsList
- streamline the process of parsing Graou trains and avoid exposing intermediate results

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
Transforming the uic by filling the checksum is a parsing/formatting operation,
which naturally belongs with other parsing/formatting operations rather than in the api call.
Furthermore, it makes sense to do it right before converting the GraouTrainSchedule string uic to a TrainSchedule number uic.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
This reduce the number of functions exposed by parseGraouTrains,
making the parsing more streamlined and self contained.
The final goal would be to only expose generateTrainSchedulesPayloads as far as parsing/formatting is concerned.

Additionally drops an unnecessary loop.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
Conmputing stopFor duration at the same time as arrival and departure times makes sense,
and enables us to remove a large loop and function call while streamlining the import process.

Also use Duration.subtractDate and .toISOString instead of manual computations for standardization.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
Contribute to centralizing all graou parsing logic.

Also simplify the rs matching logic, drop a custom type and avoid type casting.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
Finish adding doc strings to functions that were lacking them.

Also move populateUicChecksum next to other internal parsing functions.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
While previous commits attempted to centralize parsing logic,
this commit goal is to centralize validation logic, which is mostly done in the api call.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
Wrapping everything in a single try/catch/finally makes the function more robust (parsing failures can occur) and streamlined.

The "if (filteredTrains && !isEmpty(filteredTrains))" condition was unnecessary and was dropped.

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
Signed-off-by: Alice K. <alice.khoudli@gmail.com>
- move all the validation logic inside graouApi
- be more resilient to errors by filtering invalid schedules and steps instead of throwing, as graou api erros are frequent
- add toast warning for filtered schedules
- fix the translation strings for the filtered steps toast warning

Signed-off-by: Alice K. <alice.khoudli@gmail.com>
@Synar Synar force-pushed the ali/fix-refactor-graou-import branch from 48472c8 to ccbf4e7 Compare January 5, 2026 23:08
@Synar
Copy link
Contributor Author

Synar commented Jan 5, 2026

Can we wait for this PR to be merged before reviewing this one ?

I was on vacation, but now I suppose the question is moot haha.

@SharglutDev
Copy link
Contributor

To keep everyone updated, we will soon lose access to graou api so the feature shall be removed from osrd.

@Synar will soon add a commit to remove everything concerning it from the codebase.

@emersion
Copy link
Member

emersion commented Jan 8, 2026

Why will we loose access?

@flomonster
Copy link
Member

Why will we loose access?

@nicolaswurtz Informed me that the service will drop (migrate) soon. In any case, we will no longer have access to the endpoint. And we should think about a more standard way of retrieving open source data (e.g. GTFS).

@Synar Synar closed this Jan 14, 2026
@github-project-automation github-project-automation bot moved this from Awaiting merge to Awaiting Validation in Board PI 18 Jan 14, 2026
@Maymanaf Maymanaf moved this from Awaiting Validation to Done in Board PI 18 Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:front Work on Standard OSRD Interface modules

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Open data import picks random CH codes instead of BV/00

6 participants