Skip to content

Organize and feature-gate FASTSim-2 compatibility code#301

Open
kylecarow wants to merge 24 commits into
fastsim-3from
f3/compat
Open

Organize and feature-gate FASTSim-2 compatibility code#301
kylecarow wants to merge 24 commits into
fastsim-3from
f3/compat

Conversation

@kylecarow

@kylecarow kylecarow commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator
  • create compat mod and feature
    • feature gate dependencies that are needed with updated Cargo.lock
      • something about running cargo update in fastsim-3 with the existing setup causes failure on some platforms, this is the fix (rather than never updating Cargo.lock)
  • move all compatibility code to compat
    • from_f2_file still needs to live in the impl with other pymethods, not a huge deal
    • remove all remaining references to fastsim2 in fastsim-3 outside of compat::fastsim2
  • compat/assets folder to organize any f2 assets (e.g. vehicle files)
    • include_dir instead of include_str
    • move f2-*.yaml loose files to compat/assets
  • refactor code that previously loaded fastsim-2 models to convert to fastsim-3 (e.g. mock_veh functions)
    • these now just load from resources
  • remove cal_and_val linkage to simdrivelabel
    • PHEV file just lives in fastsim-core now which makes more sense
  • add explicit test coverage for f2 to f3 vehicle conversion

This allows us to load F2 files in F3 with no added fuss or functions!

@kylecarow kylecarow changed the title Remove fastsim-2 as a dependency entirely Organize and feature-gate compatibility code Jul 18, 2026
@kylecarow kylecarow changed the title Organize and feature-gate compatibility code Organize and feature-gate FASTSim-2 compatibility code Jul 18, 2026
@kylecarow
kylecarow marked this pull request as ready for review July 18, 2026 22:33
.map_err(|err| Error::SerdeError(format!("{err}")))?;
Self::from_toml(buf, skip_init)
.map_err(|err| Error::SerdeError(format!("{err}")))?
Self::from_toml(buf, true).map_err(|err| Error::SerdeError(format!("{err}")))?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

this is an unrelated bug, skip init true prevents init from running twice in this call chain

#[cfg(feature = "resources")]
const RESOURCES_SUBDIR: &'static str = "vehicles";

// specialized from_reader that allows for compatibility with fastsim-2 vehicle files

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the specialized from_reader and from_* str methods are where the autoconversion magic happens, it takes a stab at deserializing from the FASTSim-2 format first, then falls back to normal deserialization. some finagling had to be done in from_reader to scroll back the buffer (otherwise it gets consumed in the compat pass)

type StructWithResources = Vehicle;

#[test]
#[cfg(all(feature = "compat", feature = "yaml"))]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

added a couple tests that check from_reader and from_yaml work directly on the compat fastsim-2 vehicle asset files, and they do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant