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: dev
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.86%. Comparing base (c806a2f) to head (090bcbc).
Report is 19 commits behind head on dev.

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

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #10273      +/-   ##
==========================================
+ Coverage   81.58%   81.86%   +0.28%     
==========================================
  Files        1062      763     -299     
  Lines      104970    76351   -28619     
  Branches      722      722              
==========================================
- Hits        85636    62504   -23132     
+ Misses      19293    13806    -5487     
  Partials       41       41              
Flag Coverage Δ
editoast ?
front 89.33% <ø> (+0.03%) ⬆️
gateway 2.18% <ø> (ø)
osrdyne 3.28% <ø> (ø)
railjson_generator 87.50% <ø> (ø)
tests ?

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
@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

@bougue-pe bougue-pe force-pushed the peb/editoast/add_etcs_brake_params_to_rs_model branch from fb63ad4 to 85ccac8 Compare January 9, 2025 08:49
Base automatically changed from peb/editoast/add_etcs_brake_params_to_rs_model to dev January 9, 2025 09:49
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é <bougue.pe@proton.me>
@bougue-pe bougue-pe force-pushed the peb/editoast/rm_validator branch from 8fbe1f3 to 090bcbc Compare January 9, 2025 13:33
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