-
Notifications
You must be signed in to change notification settings - Fork 45
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
base: peb/editoast/add_etcs_brake_params_to_rs_model
Are you sure you want to change the base?
editoast: remove 'validator' dependency #10273
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
fe27737
to
d1ab72f
Compare
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]>
95c908a
to
8fbe1f3
Compare
There was a problem hiding this 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> |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
let rolling_stock: RollingStock = | ||
serde_json::from_reader(BufReader::new(rolling_stock_file))?; | ||
let rolling_stock: Changeset<RollingStockModel> = rolling_stock.into(); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
After #10147 (comment)
TODO: