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

front: nge saving node's positions #9105

Merged
merged 5 commits into from
Dec 20, 2024
Merged

front: nge saving node's positions #9105

merged 5 commits into from
Dec 20, 2024

Conversation

sim51
Copy link
Contributor

@sim51 sim51 commented Sep 30, 2024

Related to /~https://github.com/osrd-project/osrd-confidential/issues/597

What is done :

  • Editoast API
  • Sync between OSRD/NGE
  • Using a layout algo for node's position
  • On load, deduplicate nodes
  • Creating new nodes in NGE
  • testing import from viriato, basic & opendata
  • check the trainrun modification

Close #9031

@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2024

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

Codecov Report

Attention: Patch coverage is 96.15070% with 47 lines in your changes missing coverage. Please review.

Project coverage is 80.15%. Comparing base (29b4005) to head (84d327f).
Report is 93 commits behind head on dev.

Files with missing lines Patch % Lines
editoast/src/views/scenario/macro_nodes.rs 92.05% 27 Missing ⚠️
front/src/common/api/generatedEditoastApi.ts 60.97% 16 Missing ⚠️
editoast/src/models/tags.rs 76.92% 3 Missing ⚠️
editoast/src/views/pagination.rs 75.00% 1 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #9105      +/-   ##
==========================================
+ Coverage   80.10%   80.15%   +0.04%     
==========================================
  Files        1054     1057       +3     
  Lines      105648   106171     +523     
  Branches      759      759              
==========================================
+ Hits        84631    85100     +469     
- Misses      20976    21029      +53     
- Partials       41       42       +1     
Flag Coverage Δ
editoast 74.43% <91.90%> (+0.17%) ⬆️
front 89.29% <98.09%> (+<0.01%) ⬆️
gateway 2.18% <ø> (ø)
osrdyne 3.28% <ø> (ø)
railjson_generator 87.50% <ø> (ø)
tests 87.00% <ø> (ø)

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.

@emersion emersion self-requested a review September 30, 2024 08:24
@sim51 sim51 force-pushed the bsi/ng-save-node branch 3 times, most recently from 3a13325 to 28830b5 Compare September 30, 2024 13:32
@sim51 sim51 changed the title NGE: saving node's positions front: nge saving node's positions Sep 30, 2024
@sim51 sim51 force-pushed the bsi/ng-save-node branch 4 times, most recently from 26bed5f to 10fbfa2 Compare September 30, 2024 15:12
Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

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

Just some very early comments. Please feel free to disregard the individual comments if you're going to change the underlying code anyways.

It appears like this contains a big refactoring together with a big new feature. This is very painful to review. Please split it up into logical commits (e.g. refactoring without any behavior change as a first commit, new feature as a second commit).

@sim51 sim51 marked this pull request as ready for review October 23, 2024 10:34
@sim51 sim51 requested review from a team as code owners October 23, 2024 10:34
@github-actions github-actions bot added area:front Work on Standard OSRD Interface modules area:editoast Work on Editoast Service labels Oct 23, 2024
@sim51 sim51 force-pushed the bsi/ng-save-node branch 3 times, most recently from 4ecb266 to eff057d Compare October 23, 2024 12:24
Copy link
Contributor

@leovalais leovalais left a comment

Choose a reason for hiding this comment

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

Great work on the editoast part! 😄 Here's a first pass of review.

I'm wondering if we really should build on top of the /project/id/study/id/... API though. If I recall correctly, this URL scheme was chosen because we wanted to replace the IDs with slugs. But that was almost two years ago and we're not planning to implement this feature anytime soon as far as I know. And even if we had it, it's not great in terms of API design to not be able to access an object by its ID directly. (We're also likely to boil down to the resource ID for the permission checks anyway, so we might as well have the endpoint and redirect from the slug chain.)

I suggest getting rid of the prefixes and simply access these endpoints at /macro_node and /macro_node/{id}. This would simplify the implementation as well. Wdyt? (ping @flomonster)

editoast/src/models/macro_node.rs Outdated Show resolved Hide resolved
editoast/src/models/macro_node.rs Outdated Show resolved Hide resolved
editoast/src/models/macro_node.rs Outdated Show resolved Hide resolved
editoast/src/models/macro_node.rs Outdated Show resolved Hide resolved
editoast/src/models/fixtures.rs Outdated Show resolved Hide resolved
editoast/src/views/scenario/macro_nodes.rs Outdated Show resolved Hide resolved
editoast/src/views/scenario/macro_nodes.rs Outdated Show resolved Hide resolved
editoast/src/views/scenario/macro_nodes.rs Outdated Show resolved Hide resolved
editoast/src/views/scenario/mod.rs Outdated Show resolved Hide resolved
editoast/src/views/scenario/mod.rs Outdated Show resolved Hide resolved
@leovalais
Copy link
Contributor

Also is it OK to link Viriato.json and basic.json publicly on GitHub?

@sim51
Copy link
Contributor Author

sim51 commented Oct 24, 2024

@leovalais can you check again ? Normally I did all the requested changes.
Thanks!

@leovalais
Copy link
Contributor

Tested the feature, a few questions:

  • The coordinates of the nodes seem to always be integers, yet the table columns are floats (unlike what's stated in the design ticket). The only time I could get a float to be stored was when making a non-placement modification (name, labels, ...) of a node that was placed algorithmically. Even then the value was something like 324.99xxxxxx. Could the coordinates be rounded so that we only have to deal with integers on editoast side?

  • The deletion of a train schedule can lead to persisted "ghost nodes" in the DB. These should probably be removed at the same time.

  1. Create two schedules A and B
  2. Open NGE
  3. Move all 4 nodes around to persist them.
  4. Go back to the Micro tab
  5. Delete schedule A
  6. Reopen NGE
  7. The nodes of A aren't shown anymore, but still exist in the DB, making them impossible to remove from the UI

This also has a side-effect: if you re-create the circulation, any metadata from the old nodes (tags, name) becomes automatically attached to the nodes of the new schedule.

  • From the Micro tab, how do you create a schedule so that the nodes representing it in NGE use either op_id:X or trigram:X? I only could create nodes with uic:X and track_offset:X (but that's probably a skill issue on my end tbh).

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

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

Here are a few comments we've come up when reviewing with @clarani!

@sim51 sim51 force-pushed the bsi/ng-save-node branch 2 times, most recently from bc52f12 to 3c6565b Compare December 5, 2024 15:26
@github-actions github-actions bot added the area:front Work on Standard OSRD Interface modules label Dec 5, 2024
@sim51 sim51 force-pushed the bsi/ng-save-node branch 5 times, most recently from 9fefabc to ced2f26 Compare December 6, 2024 14:54
@sim51
Copy link
Contributor Author

sim51 commented Dec 6, 2024

@emersion & @clarani

I review the way how I stored the nodes in the state and their relative indices.
So now a node has a ngeId & dbId, and methods have the corresponding suffix (ex: getNodeByNgeId)

Normally this refacto solved all your last comments, except two which are not critical, the index of labels and the rename of a field in the database.

BTW, I found & fixed a bug when you want to delete a project or a study.

@sim51 sim51 requested review from clarani and emersion December 10, 2024 08:45
Copy link
Contributor

@clarani clarani left a comment

Choose a reason for hiding this comment

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

I found some bugs:

  • the created trigrams in NGE are not correctly displayed
  • the positions of the nodes are not saved in the database

sim51 and others added 4 commits December 12, 2024 17:27
Signed-off-by: Benoit Simard <contact@bsimard.com>
Signed-off-by: Benoit Simard <contact@bsimard.com>
Signed-off-by: Simon Ser <contact@emersion.fr>
Signed-off-by: Benoit Simard <contact@bsimard.com>
@sim51 sim51 force-pushed the bsi/ng-save-node branch 2 times, most recently from ba9764d to 0cd0959 Compare December 13, 2024 15:29
When calling the dtoImport, we ask the transchedule state to the
database

Signed-off-by: Benoit Simard <contact@bsimard.com>
Copy link
Contributor

@clarani clarani left a comment

Choose a reason for hiding this comment

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

LGTM ✅

Copy link
Contributor

@leovalais leovalais left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the changes!

@sim51 sim51 dismissed emersion’s stale review December 18, 2024 10:03

already reviewed by clara last week

@sim51 sim51 added this pull request to the merge queue Dec 20, 2024
Merged via the queue into dev with commit 7582bdd Dec 20, 2024
27 checks passed
@sim51 sim51 deleted the bsi/ng-save-node branch December 20, 2024 09:31
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.

nge: newly created node position isn't persisted after search this node in infra
7 participants