feat: add Storage trait and JSONL journal backend
Replace the internal Vec<CompletedTrial<V>> with a pluggable Storage<V> trait. MemoryStorage is the default (no behavior change for existing users). Behind the `journal` feature flag, JournalStorage persists trials to a JSONL file with fs2 file locking for multi-process safety. - Storage<V> trait with push(), trials_arc(), refresh() methods - MemoryStorage<V> wraps Arc<RwLock<Vec<CompletedTrial<V>>>> - JournalStorage<V> appends JSON lines with exclusive file locks - Study::with_sampler_and_storage() general constructor - Study::with_journal() convenience constructor (journal feature) - Refresh from storage on create_trial() for multi-process discovery - MSRV bumped to 1.89
This commit is contained in:
@@ -233,6 +233,7 @@ pub mod pareto;
|
||||
pub mod pruner;
|
||||
mod rng_util;
|
||||
pub mod sampler;
|
||||
pub mod storage;
|
||||
mod study;
|
||||
mod trial;
|
||||
mod types;
|
||||
@@ -269,6 +270,9 @@ pub use sampler::random::RandomSampler;
|
||||
#[cfg(feature = "sobol")]
|
||||
pub use sampler::sobol::SobolSampler;
|
||||
pub use sampler::tpe::TpeSampler;
|
||||
#[cfg(feature = "journal")]
|
||||
pub use storage::JournalStorage;
|
||||
pub use storage::{MemoryStorage, Storage};
|
||||
pub use study::Study;
|
||||
#[cfg(feature = "serde")]
|
||||
pub use study::StudySnapshot;
|
||||
@@ -314,6 +318,9 @@ pub mod prelude {
|
||||
#[cfg(feature = "sobol")]
|
||||
pub use crate::sampler::sobol::SobolSampler;
|
||||
pub use crate::sampler::tpe::TpeSampler;
|
||||
#[cfg(feature = "journal")]
|
||||
pub use crate::storage::JournalStorage;
|
||||
pub use crate::storage::{MemoryStorage, Storage};
|
||||
pub use crate::study::Study;
|
||||
#[cfg(feature = "serde")]
|
||||
pub use crate::study::StudySnapshot;
|
||||
|
||||
Reference in New Issue
Block a user