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: remove 'validator' dependency #10273

Draft
wants to merge 1 commit into
base: peb/editoast/add_etcs_brake_params_to_rs_model
Choose a base branch
from

Conversation

bougue-pe
Copy link
Contributor

After #10147 (comment)

TODO:

  • fix tests
  • use Changeset and #[serde(remote = "Self")] if possible
  • maybe change error type returned by the free function
  • remove any 'validator' use

@github-actions github-actions bot added the area:editoast Work on Editoast Service label Jan 7, 2025
@bougue-pe bougue-pe changed the title editoast: remove 'validator' editoast: remove 'validator' dependency Jan 7, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 7, 2025

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

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.70%. Comparing base (fb63ad4) to head (8fbe1f3).

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

Additional details and impacted files
@@                                Coverage Diff                                 @@
##           peb/editoast/add_etcs_brake_params_to_rs_model   #10273      +/-   ##
==================================================================================
+ Coverage                                           81.44%   81.70%   +0.25%     
==================================================================================
  Files                                                1060      778     -282     
  Lines                                              104354    76128   -28226     
  Branches                                              722      722              
==================================================================================
- Hits                                                84994    62198   -22796     
+ Misses                                              19319    13889    -5430     
  Partials                                               41       41              
Flag Coverage Δ
editoast ?
front 89.20% <ø> (ø)
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.

@bougue-pe bougue-pe force-pushed the peb/editoast/add_etcs_brake_params_to_rs_model branch from fe27737 to d1ab72f Compare January 8, 2025 08:50
TODO:
* fix tests
* use Changeset<RollingStock> and #[serde(remote = "Self")] if possible
* maybe change error type returned by the free function
* remove any 'validator' use

Signed-off-by: Pierre-Etienne Bougué <[email protected]>
@bougue-pe bougue-pe force-pushed the peb/editoast/rm_validator branch from 95c908a to 8fbe1f3 Compare January 8, 2025 10:21
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.

So far, it looks good, most of the comments I was about to do are part of the TODO list, so waiting for the follow-up 😄

effort_curves: &EffortCurves,
electrical_power_startup_time: Option<f64>,
raise_pantograph_time: Option<f64>,
) -> std::result::Result<(), ValidationError> {
) -> Result<(), D::Error>
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw that it's part of your TODO list. The errors are going to change, but in the meantime, we might want to stick to the less ideal, but coherent way of doing: using crate::error::Result which uses InternalError.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this function being called by Deserialize::deserialize prevents from using InternalError

Comment on lines 30 to 32
let rolling_stock: RollingStock =
serde_json::from_reader(BufReader::new(rolling_stock_file))?;
let rolling_stock: Changeset<RollingStockModel> = rolling_stock.into();
Copy link
Contributor

Choose a reason for hiding this comment

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

In the spirit of "parse don't validate", I'd argue that the validation should occur at the deserialization of the schema and not changeset (unlike what's currently being done on dev). There is an impl From<editoast_schema::RollingStock> for RollingStockChangeset existing in rolling_stock_model.rs. It might also be easier to pull the remote = "Self" trick on the schema as it's struct isn't generated.

Wdyt?

effort_curves: &EffortCurves,
electrical_power_startup_time: Option<f64>,
raise_pantograph_time: Option<f64>,
) -> std::result::Result<(), ValidationError> {
) -> Result<(), D::Error>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that this function being called by Deserialize::deserialize prevents from using InternalError

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants