-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from NREL/f2-release-prep
allow for publication on crates.io
- Loading branch information
Showing
20 changed files
with
3,517 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
[workspace] | ||
|
||
members = [ | ||
"fastsim-cli", # command line app | ||
"fastsim-core", # pure rust core with optional pyo3 feature | ||
"fastsim-py", # python module exposing fastsim-core | ||
"fastsim-cli", # command line app | ||
"fastsim-core", # pure rust core with optional pyo3 feature | ||
"fastsim-py", # python module exposing fastsim-core | ||
"fastsim-core/fastsim-proc-macros", | ||
] | ||
|
||
[profile.release] | ||
# https://deterministic.space/high-performance-rust.html | ||
opt-level = 3 # Use better optimizations. | ||
lto = "fat" # aggressively optimize inter-crate linking | ||
codegen-units = 1 # optimize connection between modules | ||
opt-level = 3 # Use better optimizations. | ||
lto = "fat" # aggressively optimize inter-crate linking | ||
codegen-units = 1 # optimize connection between modules | ||
|
||
[workspace.dependencies] | ||
anyhow = "1.0.57" | ||
pyo3 = "0.19" | ||
pyo3-log = "*" | ||
serde = "1.0.143" | ||
serde_json = "1.0.83" | ||
serde_yaml = "0.9.22" | ||
serde_yaml = "0.9.22" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,47 @@ | ||
[package] | ||
name = "fastsim-core" | ||
version = "0.1.0" | ||
version = "0.1.2" | ||
edition = "2021" | ||
license-file = "../../LICENSE.md" | ||
authors = ["NREL/MTES/CIMS/MBAP Group <fastsim@nrel.gov>"] | ||
description = "Core FASTSim models for vehicle energy usage simulation" | ||
homepage = "https://www.nrel.gov/transportation/fastsim.html" | ||
readme = "../../README.md" | ||
repository = "https://github.com/NREL/fastsim" | ||
|
||
[dependencies] | ||
pyo3 = { workspace = true, features = ["extension-module", "anyhow"], optional = true } | ||
proc-macros = { package = "fastsim-proc-macros", version = "~0" } | ||
pyo3 = { workspace = true, features = [ | ||
"extension-module", | ||
"anyhow", | ||
], optional = true } | ||
anyhow = { workspace = true } | ||
serde = { workspace = true, features = ["derive"] } | ||
serde_yaml = {workspace = true} | ||
ndarray = { version = "0.15.4", features=["serde"] } | ||
serde_yaml = { workspace = true } | ||
ndarray = { version = "0.15.4", features = ["serde"] } | ||
csv = "1.1" | ||
proc-macros = { path = "proc-macros" } | ||
serde_json = "1.0.81" | ||
bincode = "1.3.3" | ||
log = "0.4.17" | ||
polynomial = "0.2.4" | ||
argmin = "0.7.0" | ||
argmin-math = { version = "0.2.1", features = ["ndarray_latest-nolinalg-serde"] } | ||
argmin-math = { version = "0.2.1", features = [ | ||
"ndarray_latest-nolinalg-serde", | ||
] } | ||
validator = { version = "0.16", features = ["derive"] } | ||
lazy_static = "1.4.0" | ||
regex = "1.7.1" | ||
|
||
[package.metadata] | ||
include = [ | ||
"resources/longparams.json", | ||
"resources/udds.csv", | ||
"resources/hwfet.csv", | ||
"build.rs", | ||
] | ||
|
||
[package.metadata.docs.rs] | ||
rustdoc-args = [ "--html-in-header", "./src/html/docs-header.html" ] | ||
rustdoc-args = ["--html-in-header", "./src/html/docs-header.html"] | ||
|
||
[features] | ||
pyo3 = ["dep:pyo3"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//! Ensures that files that are duplicated in Python resources folder | ||
//! and locally in this crate are identical | ||
use std::env; | ||
use std::fs; | ||
use std::path::PathBuf; | ||
|
||
fn main() { | ||
// path when running `cargo publish` in fastsim-core/ | ||
let publish_path = "../../../../python/fastsim/resources".to_string(); | ||
// path when building using build_and_test.sh | ||
let build_path = "../../python/fastsim/resources".to_string(); | ||
|
||
let prepath: String = match PathBuf::from(publish_path.clone()).exists() { | ||
true => publish_path, | ||
false => build_path, | ||
}; | ||
|
||
if !PathBuf::from(prepath.clone()).exists() { | ||
// no need for further checks since this indicates that it's | ||
// likely that python fastsim is not available and thus | ||
// fastsim-core is likely being compiled as a dependency | ||
return; | ||
} | ||
|
||
let truth_files = [ | ||
format!( | ||
"{}/{}/longparams.json", | ||
env::current_dir().unwrap().as_os_str().to_str().unwrap(), | ||
prepath | ||
), | ||
format!( | ||
"{}/{}/cycles/udds.csv", | ||
env::current_dir().unwrap().as_os_str().to_str().unwrap(), | ||
prepath | ||
), | ||
format!( | ||
"{}/{}/cycles/hwfet.csv", | ||
env::current_dir().unwrap().as_os_str().to_str().unwrap(), | ||
prepath | ||
), | ||
]; | ||
|
||
let compare_files = [ | ||
format!( | ||
"{}/resources/longparams.json", | ||
env::current_dir().unwrap().as_os_str().to_str().unwrap() | ||
), | ||
format!( | ||
"{}/resources/udds.csv", | ||
env::current_dir().unwrap().as_os_str().to_str().unwrap() | ||
), | ||
format!( | ||
"{}/resources/hwfet.csv", | ||
env::current_dir().unwrap().as_os_str().to_str().unwrap() | ||
), | ||
]; | ||
|
||
for (tf, cf) in truth_files.iter().zip(compare_files) { | ||
let tfc = fs::read_to_string(tf).unwrap_or_else(|_| panic!("{tf} does not exist.")); | ||
|
||
let cfc = fs::read_to_string(cf.clone()).unwrap_or_else(|_| panic!("{cf} does not exist.")); | ||
|
||
if tfc != cfc { | ||
panic!("Reference file {tf} does not match file being compared: {cf}. Copy {tf} to {cf} to fix this.") | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
authors = ["NREL/MTES/CIMS/MBAP Group <fastsim@nrel.gov>"] | ||
name = "fastsim-proc-macros" | ||
version = "0.1.2" | ||
edition = "2021" | ||
license-file = "../../../LICENSE.md" | ||
readme = "../../../README.md" | ||
description = "Procedural macros for FASTSim" | ||
homepage = "https://www.nrel.gov/transportation/fastsim.html" | ||
repository = "https://github.com/NREL/fastsim" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
proc-macro-error = "1.0.4" | ||
proc-macro2 = "1.0.37" | ||
quote = "1.0.18" | ||
regex = "1.6.0" | ||
syn = { version = "1.0.92", features = ["full"] } | ||
|
||
[lib] | ||
proc-macro = true |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.