Simulations: make polars dependancy optional (#385)
* Remove explicit target * Use default profile for windows build * Use stable-gnu for tests * Make polars optional feature in simulations * Remove unnecessary ci debug steps
This commit is contained in:
parent
3b90cb786c
commit
03b9f69a01
|
@ -49,7 +49,6 @@ jobs:
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
|
||||||
toolchain: stable-gnu
|
toolchain: stable-gnu
|
||||||
target: x86_64-pc-windows-gnu
|
target: x86_64-pc-windows-gnu
|
||||||
override: true
|
override: true
|
||||||
|
@ -65,12 +64,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
args: --all --no-default-features --features ${{ matrix.feature }}
|
args: --all --no-default-features --features ${{ matrix.feature }}
|
||||||
# Freeup some space for Windows tests
|
|
||||||
- name: Clean target dir (Windows)
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: clean
|
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
|
|
|
@ -50,7 +50,6 @@ jobs:
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
|
||||||
toolchain: stable-gnu
|
toolchain: stable-gnu
|
||||||
target: x86_64-pc-windows-gnu
|
target: x86_64-pc-windows-gnu
|
||||||
override: true
|
override: true
|
||||||
|
@ -66,12 +65,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
command: build
|
command: build
|
||||||
args: --all --no-default-features --features ${{ matrix.feature }}
|
args: --all --no-default-features --features ${{ matrix.feature }}
|
||||||
# Freeup some space for Windows tests
|
|
||||||
- name: Clean target dir (Windows)
|
|
||||||
if: matrix.os == 'windows-latest'
|
|
||||||
uses: actions-rs/cargo@v1
|
|
||||||
with:
|
|
||||||
command: clean
|
|
||||||
- uses: actions-rs/cargo@v1
|
- uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
command: test
|
command: test
|
||||||
|
|
|
@ -28,7 +28,7 @@ nomos-core = { path = "../nomos-core" }
|
||||||
nomos-consensus = { path = "../nomos-services/consensus" }
|
nomos-consensus = { path = "../nomos-services/consensus" }
|
||||||
once_cell = "1.17"
|
once_cell = "1.17"
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12"
|
||||||
polars = { version = "0.27", features = ["serde", "object", "json", "csv-file", "parquet", "dtype-struct"] }
|
polars = { version = "0.27", features = ["serde", "object", "json", "csv-file", "parquet", "dtype-struct"], optional = true }
|
||||||
rand = { version = "0.8", features = ["small_rng"] }
|
rand = { version = "0.8", features = ["small_rng"] }
|
||||||
rayon = "1.7"
|
rayon = "1.7"
|
||||||
scopeguard = "1"
|
scopeguard = "1"
|
||||||
|
@ -43,4 +43,7 @@ tracing-subscriber = { version = "0.3", features = ["env-filter", "tracing-log"]
|
||||||
getrandom = { version = "0.2", features = ["js"] }
|
getrandom = { version = "0.2", features = ["js"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3.4"
|
tempfile = "3.4"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
polars = ["dep:polars"]
|
||||||
|
|
|
@ -23,9 +23,9 @@ use simulations::node::carnot::{CarnotRecord, CarnotSettings, CarnotState};
|
||||||
use simulations::node::{NodeId, NodeIdExt};
|
use simulations::node::{NodeId, NodeIdExt};
|
||||||
use simulations::output_processors::Record;
|
use simulations::output_processors::Record;
|
||||||
use simulations::runner::{BoxedNode, SimulationRunnerHandle};
|
use simulations::runner::{BoxedNode, SimulationRunnerHandle};
|
||||||
use simulations::streaming::{
|
#[cfg(feature = "polars")]
|
||||||
io::IOSubscriber, naive::NaiveSubscriber, polars::PolarsSubscriber, StreamType,
|
use simulations::streaming::polars::PolarsSubscriber;
|
||||||
};
|
use simulations::streaming::{io::IOSubscriber, naive::NaiveSubscriber, StreamType};
|
||||||
// internal
|
// internal
|
||||||
use simulations::{runner::SimulationRunner, settings::SimulationSettings};
|
use simulations::{runner::SimulationRunner, settings::SimulationSettings};
|
||||||
mod log;
|
mod log;
|
||||||
|
@ -163,6 +163,7 @@ where
|
||||||
let settings = stream_settings.unwrap_io();
|
let settings = stream_settings.unwrap_io();
|
||||||
runner.simulate_and_subscribe::<IOSubscriber<CarnotRecord>>(settings)?
|
runner.simulate_and_subscribe::<IOSubscriber<CarnotRecord>>(settings)?
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "polars")]
|
||||||
Some(StreamType::Polars) => {
|
Some(StreamType::Polars) => {
|
||||||
let settings = stream_settings.unwrap_polars();
|
let settings = stream_settings.unwrap_polars();
|
||||||
runner.simulate_and_subscribe::<PolarsSubscriber<CarnotRecord>>(settings)?
|
runner.simulate_and_subscribe::<PolarsSubscriber<CarnotRecord>>(settings)?
|
||||||
|
|
|
@ -25,6 +25,7 @@ pub fn to_overlay_node<R: Rng>(
|
||||||
simulations::streaming::StreamSettings::IO(_) => {
|
simulations::streaming::StreamSettings::IO(_) => {
|
||||||
simulations::streaming::SubscriberFormat::Csv
|
simulations::streaming::SubscriberFormat::Csv
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "polars")]
|
||||||
simulations::streaming::StreamSettings::Polars(p) => p.format,
|
simulations::streaming::StreamSettings::Polars(p) => p.format,
|
||||||
};
|
};
|
||||||
match &settings.overlay_settings {
|
match &settings.overlay_settings {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
use consensus_engine::View;
|
use consensus_engine::View;
|
||||||
|
#[cfg(feature = "polars")]
|
||||||
use polars::export::ahash::HashMap;
|
use polars::export::ahash::HashMap;
|
||||||
|
#[cfg(not(feature = "polars"))]
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
pub(crate) struct TimeoutHandler {
|
pub(crate) struct TimeoutHandler {
|
||||||
|
|
|
@ -11,6 +11,7 @@ use crate::output_processors::{Record, RecordType, Runtime};
|
||||||
|
|
||||||
pub mod io;
|
pub mod io;
|
||||||
pub mod naive;
|
pub mod naive;
|
||||||
|
#[cfg(feature = "polars")]
|
||||||
pub mod polars;
|
pub mod polars;
|
||||||
pub mod runtime_subscriber;
|
pub mod runtime_subscriber;
|
||||||
pub mod settings_subscriber;
|
pub mod settings_subscriber;
|
||||||
|
@ -83,6 +84,7 @@ pub enum StreamType {
|
||||||
#[default]
|
#[default]
|
||||||
IO,
|
IO,
|
||||||
Naive,
|
Naive,
|
||||||
|
#[cfg(feature = "polars")]
|
||||||
Polars,
|
Polars,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +95,7 @@ impl FromStr for StreamType {
|
||||||
match s.trim().to_ascii_lowercase().as_str() {
|
match s.trim().to_ascii_lowercase().as_str() {
|
||||||
"io" => Ok(Self::IO),
|
"io" => Ok(Self::IO),
|
||||||
"naive" => Ok(Self::Naive),
|
"naive" => Ok(Self::Naive),
|
||||||
|
#[cfg(feature = "polars")]
|
||||||
"polars" => Ok(Self::Polars),
|
"polars" => Ok(Self::Polars),
|
||||||
tag => Err(format!(
|
tag => Err(format!(
|
||||||
"Invalid {tag} streaming type, only [naive, polars] are supported",
|
"Invalid {tag} streaming type, only [naive, polars] are supported",
|
||||||
|
@ -116,6 +119,7 @@ impl<'de> serde::Deserialize<'de> for StreamType {
|
||||||
pub enum StreamSettings {
|
pub enum StreamSettings {
|
||||||
Naive(naive::NaiveSettings),
|
Naive(naive::NaiveSettings),
|
||||||
IO(io::IOStreamSettings),
|
IO(io::IOStreamSettings),
|
||||||
|
#[cfg(feature = "polars")]
|
||||||
Polars(polars::PolarsSettings),
|
Polars(polars::PolarsSettings),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +144,7 @@ impl StreamSettings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "polars")]
|
||||||
pub fn unwrap_polars(self) -> polars::PolarsSettings {
|
pub fn unwrap_polars(self) -> polars::PolarsSettings {
|
||||||
match self {
|
match self {
|
||||||
StreamSettings::Polars(settings) => settings,
|
StreamSettings::Polars(settings) => settings,
|
||||||
|
|
Loading…
Reference in New Issue