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: endpoints to retrieve stdcm payloads #10212

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

hamz2a
Copy link
Contributor

@hamz2a hamz2a commented Dec 31, 2024

Part of #9724

Warning

We need to wait for this PR to be merged before merging that one.

@hamz2a hamz2a requested a review from a team as a code owner December 31, 2024 15:13
@github-actions github-actions bot added area:front Work on Standard OSRD Interface modules area:editoast Work on Editoast Service labels Dec 31, 2024
@codecov-commenter
Copy link

codecov-commenter commented Dec 31, 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.88196% with 14 lines in your changes missing coverage. Please review.

Project coverage is 81.78%. Comparing base (d7e5438) to head (587adc5).
Report is 11 commits behind head on dev.

Files with missing lines Patch % Lines
front/src/common/api/generatedEditoastApi.ts 60.00% 6 Missing ⚠️
editoast/src/client/runserver.rs 0.00% 4 Missing ⚠️
editoast/src/views/stdcm_logs.rs 98.40% 4 Missing ⚠️

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

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #10212      +/-   ##
==========================================
+ Coverage   81.67%   81.78%   +0.10%     
==========================================
  Files        1071     1072       +1     
  Lines      106107   106452     +345     
  Branches      727      727              
==========================================
+ Hits        86663    87058     +395     
+ Misses      19405    19355      -50     
  Partials       39       39              
Flag Coverage Δ
editoast 74.20% <98.15%> (+0.44%) ⬆️
front 89.35% <60.00%> (-0.01%) ⬇️
gateway 2.18% <ø> (ø)
osrdyne 3.28% <ø> (ø)
railjson_generator 87.50% <ø> (ø)
tests 87.05% <ø> (ø)

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.

@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch from d728975 to a539bb6 Compare December 31, 2024 15:58
@hamz2a hamz2a requested a review from a team as a code owner December 31, 2024 15:58
@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch 3 times, most recently from 1a7b3f8 to c53a199 Compare January 6, 2025 15:49
@hamz2a hamz2a requested a review from SharglutDev January 6, 2025 16:15
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.

Nice work, especially on the tests! I left a few comments.

editoast/src/views/test_app.rs Outdated Show resolved Hide resolved
front/public/locales/en/errors.json Outdated Show resolved Hide resolved
editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
editoast/src/core/stdcm.rs Outdated Show resolved Hide resolved
editoast/src/core/stdcm.rs Show resolved Hide resolved
editoast/src/models/stdcm_log.rs Outdated Show resolved Hide resolved
editoast/src/models/stdcm_log.rs Outdated Show resolved Hide resolved
editoast/src/views/stdcm_logs.rs Outdated Show resolved Hide resolved
editoast/src/views/stdcm_logs.rs Outdated Show resolved Hide resolved
editoast/src/views/stdcm_logs.rs Outdated Show resolved Hide resolved
editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
front/public/locales/en/errors.json Outdated Show resolved Hide resolved
front/public/locales/fr/errors.json Outdated Show resolved Hide resolved
@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch 3 times, most recently from 0ad6f2e to be2ccfb Compare January 8, 2025 12:00
@hamz2a hamz2a requested review from woshilapin and leovalais January 8, 2025 12:07
@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch from be2ccfb to 3c73f4d Compare January 8, 2025 12:12
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.

Thank you for all the improvements, I've resolved most of my comments (only left one opened, feel free to resolve if you fix, if you disagree, either way).

@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch from 3c73f4d to 7b6d3b7 Compare January 8, 2025 13:49
editoast/openapi.yaml Outdated Show resolved Hide resolved
editoast/openapi.yaml Outdated Show resolved Hide resolved
editoast/src/models/stdcm_log.rs Outdated Show resolved Hide resolved
editoast/src/views/stdcm_logs.rs Outdated Show resolved Hide resolved
editoast/src/views/stdcm_logs.rs Outdated Show resolved Hide resolved
editoast/src/core/stdcm.rs Show resolved Hide resolved
editoast/src/views/stdcm_logs.rs Outdated Show resolved Hide resolved
editoast/src/views/stdcm_logs.rs Outdated Show resolved Hide resolved
@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch from 7b6d3b7 to b4e9163 Compare January 9, 2025 10:22
@hamz2a hamz2a requested a review from leovalais January 9, 2025 10:27
@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch 4 times, most recently from 4123388 to 9e93647 Compare January 9, 2025 14:39
front/src/common/api/generatedEditoastApi.ts Outdated Show resolved Hide resolved
front/src/common/api/generatedEditoastApi.ts Outdated Show resolved Hide resolved
editoast/src/core/stdcm.rs Show resolved Hide resolved
@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch from 120b7d9 to 217791b Compare January 13, 2025 14:14
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, thank you for all the changes!

editoast/src/views/timetable/stdcm/request.rs Outdated Show resolved Hide resolved
@hamz2a hamz2a requested a review from leovalais January 13, 2025 15:52
Copy link
Contributor

@SharglutDev SharglutDev left a comment

Choose a reason for hiding this comment

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

Lgtm

@leovalais
Copy link
Contributor

leovalais commented Jan 14, 2025

While trying to test the new endpoints I cam across a few bugs 🥲

With authorization disabled:
image

With authorization enabled, the first request works, but its trace id is 00000000.....
The second request fails:
Capture d’écran 2025-01-14 à 09 59 09

Steps to reproduce:

  1. (I loaded a new DB dump)
  2. Authorization enabled
  3. Open the frontend
  4. Give mock.identity the role Superuser
  5. LMR request
  6. The log appear on DB with trace-id 00000000000...
  7. Another LMR request
  8. Contraint violation

@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch 3 times, most recently from c98f0a5 to 539dbed Compare January 15, 2025 15:04
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.

Really nice and exhaustive suite of tests. Thank you.

editoast/src/views/stdcm_logs.rs Outdated Show resolved Hide resolved
@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch from 539dbed to 6ecfb3e Compare January 15, 2025 16:08
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.

Thanks a lot for all the changes! I'll test it a bit to make sure I didn't miss anything but things look fine to me :)

editoast/src/client/runserver.rs Outdated Show resolved Hide resolved
editoast/src/views/stdcm_logs.rs Outdated Show resolved Hide resolved
@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch from 6ecfb3e to c520cf9 Compare January 16, 2025 10:53
@leovalais
Copy link
Contributor

Sorry found a new problem:

❯ xh :8090/stdcm_logs x-remote-user-identity:'mock.identity/Example User'
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Content-Length: 190
Content-Type: application/json
Date: Thu, 16 Jan 2025 11:31:29 GMT
Vary: origin, access-control-request-method, access-control-request-headers

{
    "status": 400,
    "type": "editoast:pagination:InvalidPageSize",
    "context": {
        "max_page_size": 10,
        "provided_page_size": 25
    },
    "message": "Invalid page size (25), expected an integer 0 < page_size <= 10"
}

@hamz2a
Copy link
Contributor Author

hamz2a commented Jan 16, 2025

Sorry found a new problem:

❯ xh :8090/stdcm_logs x-remote-user-identity:'mock.identity/Example User'
HTTP/1.1 400 Bad Request
Access-Control-Allow-Origin: *
Content-Length: 190
Content-Type: application/json
Date: Thu, 16 Jan 2025 11:31:29 GMT
Vary: origin, access-control-request-method, access-control-request-headers

{
    "status": 400,
    "type": "editoast:pagination:InvalidPageSize",
    "context": {
        "max_page_size": 10,
        "provided_page_size": 25
    },
    "message": "Invalid page size (25), expected an integer 0 < page_size <= 10"
}

The error occurs because the default value for pagination is 25, but for this endpoint, we've set it to 10 as specified in the pagination validation.

@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch 2 times, most recently from 3df2b85 to d527e1d Compare January 16, 2025 16:42
@hamz2a
Copy link
Contributor Author

hamz2a commented Jan 16, 2025

As we discussed, we'll keep the page_size at 25, but the endpoint is less verbose, it now returns results like: [{'id': 1, 'trace_id': 'AZERT'}, {'id': 2, 'trace_id': null}].
I've also updated the endpoint to allow access to the logs byid.

@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch 4 times, most recently from 94511f6 to 6edeb3f Compare January 16, 2025 18:59
Signed-off-by: hamz2a <atrari.hamza@gmail.com>
@hamz2a hamz2a force-pushed the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch from 6edeb3f to 587adc5 Compare January 16, 2025 19:33
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.

Thanks and sorry about all the back and forth! I can see a few things to improve (especially the /stdcm_log vs /stdcm_logS, these mistakes are hard to find 😨), but that's for another PR if any. Let's merge this :)

@hamz2a hamz2a added this pull request to the merge queue Jan 17, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 17, 2025
@hamz2a hamz2a added this pull request to the merge queue Jan 17, 2025
Merged via the queue into dev with commit ec18e08 Jan 17, 2025
27 checks passed
@hamz2a hamz2a deleted the hai/editoast-endpoint-to-retrieve-stdcm-payloads branch January 17, 2025 11:44
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