From fc74da862143641eb69adac897928ff4013bc00d Mon Sep 17 00:00:00 2001 From: Steuteville Date: Tue, 19 Dec 2023 14:58:12 -0700 Subject: [PATCH] adding new from_github vehicle method --- rust/fastsim-core/src/vehicle.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rust/fastsim-core/src/vehicle.rs b/rust/fastsim-core/src/vehicle.rs index adcf98f3..9af5755d 100644 --- a/rust/fastsim-core/src/vehicle.rs +++ b/rust/fastsim-core/src/vehicle.rs @@ -6,6 +6,7 @@ use crate::params::*; use crate::proc_macros::{add_pyo3_api, doc_field, ApproxEq}; #[cfg(feature = "pyo3")] use crate::pyo3imports::*; +use crate::utils::create_project_subdir; use lazy_static::lazy_static; use regex::Regex; @@ -1033,6 +1034,23 @@ impl RustVehicle { v.set_derived().unwrap(); v } + /// Downloads specified vehicle from vehicle repo into fastsim/python/fastsim/resources/vehdb. + /// + /// Arguments: + /// ---------- + /// vehicle (string): name of the vehicle to be downloaded + + // make separate function that gets list of yaml files off of github, then user can choose from that for input -- Rust function + // exposed to python, put in utilities + pub fn from_github(vehicle_file_name: String) { + let mut vehicle_url: String = "https://github.com/NREL/fastsim-vehicles/blob/main/public/".to_string(); + vehicle_url.push_str(&vehicle_file_name); + // find or create fastsim data directory with subdirectory "vehicles" and return path + let data_directory: Option = create_project_subdir("vehicles"); + // see if you can find file_name in vehicle data + // if file doesn't already exist in directory, and once we have file path to directory: + // download_file_from_url(vehicle_url, data_directory) + } } impl Default for RustVehicle {