PR #259
https://github.com/NatLabRockies/fastsim-vehicles
Already existing metadata fields:
name
doc
chassis.drive_type: FWD/RWD/AWD/4WD
Introduce metadata fields:
| Scenario |
min_fastsim_version in file |
Installed version |
Warning emitted? |
| Normal load |
3.1.0 |
3.1.0 |
No |
| File needs a newer patch |
3.1.1 |
3.1.0 |
Yes — "requires FASTSim >= 3.1.1" |
| File needs a newer minor |
3.2.0 |
3.1.0 |
Yes — "requires FASTSim >= 3.2.0" |
| File needs a newer major |
4.0.0 |
3.1.0 |
Yes — "requires FASTSim >= 4.0.0" |
| File is from an older patch |
3.1.0 |
3.1.1 |
No |
| File is from an older minor |
3.0.0 |
3.1.0 |
No |
| File is from an older major |
2.0.0 |
3.1.0 |
Yes — "older major version … breaking changes" |
| Field missing from file |
(field absent, defaults to current) |
3.1.0 |
No |
Loaded via from_yaml / from_json (string) |
any |
any |
No — only from_file, from_resource, from_url route through from_reader |
Fill out preliminary schema structure in github.com/NatLabRockies/fastsim-vehicles
Convenience functions:
# on Vehicle class:
def from_db(
cls,
db_path_or_url: str | None = None,
schema: int = 1,
**kwargs: Any,
) -> Self:
"""Load a vehicle from a schema-versioned FASTSim vehicle database.
Parameters
----------
db_path_or_url : str | None, default None
Database source selector.
- ``None``: use the schema-specific default remote database URL.
- ``"http://..."`` or ``"https://..."``: use remote database loading.
- any other string: treat as a local filesystem database path.
schema : int, default 1
Database schema version used for dispatch. Currently only ``schema=1``
is supported.
**kwargs
Arguments forwarded to the schema-specific loader.
Valid kwargs for ``schema=1``:
- ``make`` (str): vehicle make, e.g. ``"Ford"``
- ``model`` (str): vehicle model, e.g. ``"F-150"``
- ``year`` (str): vehicle model year, e.g. ``"2022"``
- ``model_version`` (int): model revision, e.g. ``1``
- ``fastsim_version`` (int, optional): FASTSim version namespace. Defaults to the installed FASTSim major version (e.g. ``3``).
- ``skip_init`` (bool, optional): forwarded to Rust loader, defaults to ``False``.
Returns
-------
Vehicle
Loaded vehicle instance.
"""
# %%
import fastsim
# %%
# Providing a path to a local database
fastsim.Vehicle.from_db(
"/Users/kcarow/Repositories/fastsim-vehicles",
make="ford",
model="fusion",
year="2012",
model_version="v1"
)
# %%
# Can provide `~` etc and it will resolve
fastsim.Vehicle.from_db(
"~/Repositories/fastsim-vehicles",
make="ford",
model="fusion",
year="2012",
model_version="v1"
)
# %%
# Loads from https://github.com/NatLabRockies/fastsim-vehicles if nothing provided
fastsim.Vehicle.from_db(
make="ford",
model="fusion",
year="2012",
model_version="v1"
)
# %%
Remove cal_and_val
- lower priority, not blocking
PR #259
https://github.com/NatLabRockies/fastsim-vehicles
Already existing metadata fields:
namedocchassis.drive_type: FWD/RWD/AWD/4WDIntroduce metadata fields:
min_fastsim_versionin file3.1.03.1.03.1.13.1.03.2.03.1.04.0.03.1.03.1.03.1.13.0.03.1.02.0.03.1.03.1.0from_yaml/from_json(string)from_file,from_resource,from_urlroute throughfrom_readeryear: Option<String>u32fieldOption<String>just fineFill out preliminary schema structure in github.com/NatLabRockies/fastsim-vehicles
Convenience functions:
Remove cal_and_val