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: explanation of why a simulation is not feasible refactor editoast #9434

Conversation

hamz2a
Copy link
Contributor

@hamz2a hamz2a commented Oct 23, 2024

closes #9476
Refactor error handling and method organization

  • Simplified how STDCMResponse::PathNotFound error is handled.
  • Reorganized STDCMRequestPayload methods for better structure.
  • Moved simulation_run_time to SimulationResponse for clarity.

@hamz2a hamz2a requested review from a team as code owners October 23, 2024 11:18
@hamz2a hamz2a requested a review from shenriotpro October 23, 2024 11:18
@hamz2a hamz2a marked this pull request as draft October 23, 2024 11:19
@github-actions github-actions bot added the area:editoast Work on Editoast Service label Oct 23, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2024

⚠️ 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 87.49%. Comparing base (508ac32) to head (0f81762).

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

Additional details and impacted files
@@              Coverage Diff              @@
##                dev    #9434       +/-   ##
=============================================
+ Coverage     39.62%   87.49%   +47.86%     
=============================================
  Files          1300       31     -1269     
  Lines         99167     1535    -97632     
  Branches       3283        0     -3283     
=============================================
- Hits          39297     1343    -37954     
+ Misses        57937      192    -57745     
+ Partials       1933        0     -1933     
Flag Coverage Δ
core ?
editoast ?
front ?
gateway ?
osrdyne ?
railjson_generator 87.49% <ø> (ø)
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.

@hamz2a hamz2a force-pushed the hai/editoast-explanation-of-why-a-simulation-is-not-feasible-refactor branch from 90fd83e to 3fcc0f0 Compare October 23, 2024 12:33
@hamz2a hamz2a changed the base branch from dev to hai/editoast-explanation-of-why-a-simulation-is-not-feasible October 23, 2024 12:49
@hamz2a hamz2a changed the title Hai/editoast explanation of why a simulation is not feasible refactor editoast: explanation of why a simulation is not feasible refactor Oct 23, 2024
@hamz2a hamz2a force-pushed the hai/editoast-explanation-of-why-a-simulation-is-not-feasible branch from 3012e7b to 4ecb4de Compare October 23, 2024 14:40
@hamz2a hamz2a force-pushed the hai/editoast-explanation-of-why-a-simulation-is-not-feasible branch from 4ecb4de to a19b328 Compare October 24, 2024 10:12
Base automatically changed from hai/editoast-explanation-of-why-a-simulation-is-not-feasible to dev October 24, 2024 10:47
@hamz2a hamz2a force-pushed the hai/editoast-explanation-of-why-a-simulation-is-not-feasible-refactor branch from 3fcc0f0 to 23c11f4 Compare October 25, 2024 08:56
@github-actions github-actions bot removed the area:editoast Work on Editoast Service label Oct 25, 2024
@hamz2a hamz2a force-pushed the hai/editoast-explanation-of-why-a-simulation-is-not-feasible-refactor branch from 23c11f4 to 217365c Compare October 25, 2024 09:01
@github-actions github-actions bot added the area:editoast Work on Editoast Service label Oct 25, 2024
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.

Thanks for the work, it's going into the right direction I believe. I'm not sure that I understand the first commit ❓Thank you for the separation and description of the other commits.

I believe we can continue on this track of isolating part of the STDCM flow, but there is already enough in the current PR so probably for later.

editoast/src/core/simulation.rs Outdated Show resolved Hide resolved
#[serde(tag = "status", rename_all = "snake_case")]
// We accepted the difference of memory size taken by variants
// Since there is only on success and others are error cases
#[allow(clippy::large_enum_variant)]
pub enum STDCMResponse {
pub enum STDCMCoreResponse {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that I understand the renaming. This struct is defined inside a module name core so we already know it's relative to core's logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed it to avoid conflicts and as, since we have another STDCMResponse in views, and both are used in the same file.

)
.await?;

let simulation_run_time = match virtual_train_sim_result.clone().simulation_run_time() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not believe you need to .clone() here.

Suggested change
let simulation_run_time = match virtual_train_sim_result.clone().simulation_run_time() {
let simulation_run_time = match virtual_train_sim_result.simulation_run_time() {

Copy link
Contributor Author

@hamz2a hamz2a Oct 29, 2024

Choose a reason for hiding this comment

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

We use it afterwards in PathNotFoundHandler.

}
}

fn elapsed_since_time_ms(time: &NaiveDateTime, zero: &DateTime<Utc>) -> u64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

zero means 0 in my mind. Maybe we can find another name? How about since (because it's in the name of the function)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it by start_time

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed it by start_time

@@ -351,6 +359,29 @@ async fn conflicts(
Ok(Json(conflict_detection_response.conflicts))
}

pub fn filter_core_work_schedule(
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this function be in an impl WorkSchedule? I'm really asking the question because you might have a better understanding than me if it makes sense or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. (it was renamed by map_to_core_work_schedule)

@hamz2a hamz2a force-pushed the hai/editoast-explanation-of-why-a-simulation-is-not-feasible-refactor branch 2 times, most recently from 374a154 to 0eb6401 Compare October 29, 2024 10:33
@hamz2a hamz2a changed the title editoast: explanation of why a simulation is not feasible refactor editoast: refactoring STDCM handler Oct 29, 2024
Signed-off-by: hamz2a <atrari.hamza@gmail.com>
Signed-off-by: hamz2a <atrari.hamza@gmail.com>
- Moved utility functions `get_earliest_step_time`, `get_earliest_step_tolerance_window`, `get_total_stop_time`, `get_maximum_departure_delay`, `get_earliest_departure_time` and `get_latest_simulation_end` into the `STDCMRequestPayload` struct as methods.
- Updated the `stdcm` function to utilize these new methods for better readability and maintainability.
- Removed redundant function definitions and improved code organization.

Signed-off-by: hamz2a <atrari.hamza@gmail.com>
Signed-off-by: hamz2a <atrari.hamza@gmail.com>
Signed-off-by: hamz2a <atrari.hamza@gmail.com>
Signed-off-by: hamz2a <atrari.hamza@gmail.com>
@hamz2a hamz2a force-pushed the hai/editoast-explanation-of-why-a-simulation-is-not-feasible-refactor branch from 0eb6401 to 0f81762 Compare October 29, 2024 11:05
@hamz2a
Copy link
Contributor Author

hamz2a commented Oct 29, 2024

Work has been moved into #9509 (just because of some git shenanigans!)

@hamz2a hamz2a closed this Oct 29, 2024
@hamz2a hamz2a changed the title editoast: refactoring STDCM handler editoast: explanation of why a simulation is not feasible refactor editoast Oct 29, 2024
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.

editoast: refactoring STDCM handler
3 participants