scirs2_datasets/
stability.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum StabilityLevel {
10 Stable,
16
17 Experimental,
22
23 Internal,
28}
29
30pub trait ApiStability {
32 const STABILITY: StabilityLevel;
34
35 const INTRODUCED_IN: Option<&'static str> = None;
37
38 const STABILIZED_IN: Option<&'static str> = None;
40
41 const DEPRECATED_IN: Option<&'static str> = None;
43}
44
45#[macro_export]
47macro_rules! api_stability {
48 (stable, $item:item) => {
49 #[doc = " **API Stability: Stable** - Guaranteed backward compatibility within major versions"]
50 $item
51 };
52 (experimental, $item:item) => {
53 #[doc = " **API Stability: Experimental** - Subject to change in minor versions"]
54 $item
55 };
56 (internal, $item:item) => {
57 #[doc = " **API Stability: Internal** - Not part of the public API"]
58 $item
59 };
60}
61
62pub struct ApiVersion;
64
65impl ApiVersion {
66 pub const CURRENT: &'static str = "0.1.0-beta.4";
68
69 pub const MIN_SUPPORTED: &'static str = "0.1.0";
71
72 pub const NEXT_PLANNED: &'static str = "0.2.0";
74}
75
76pub struct CompatibilityGuarantees;
81
82impl CompatibilityGuarantees {
83 pub const CORE_API_STABLE: &'static str = "
92 The following APIs are considered stable and will maintain backward compatibility:
93
94 - Dataset struct and its public methods (n_samples, n_features, etc.)
95 - Toy dataset loaders (load_iris, load_boston, load_breast_cancer, etc.)
96 - Core data generators (make_classification, make_regression, make_blobs, etc.)
97 - Cross-validation utilities (k_fold_split, stratified_k_fold_split, etc.)
98 - Basic dataset utilities (train_test_split, normalize_features, etc.)
99 - Error types and Result definitions
100 ";
101
102 pub const EXPERIMENTAL_API: &'static str = "
111 The following APIs are experimental and may change in minor versions:
112
113 - GPU acceleration (gpu module)
114 - Cloud storage integration (cloud module)
115 - Distributed processing (distributed module)
116 - Advanced ML pipeline features (ml_integration advanced features)
117 - Domain-specific datasets (domain_specific module)
118 - Streaming dataset processing (streaming module)
119 - Advanced data generators (advanced_generators module)
120 ";
121
122 pub const INTERNAL_API: &'static str = "
129 The following APIs are internal and may change without notice:
130
131 - Cache implementation details
132 - Internal registry structures
133 - Private utility functions
134 - Internal error handling mechanisms
135 - Performance optimization internals
136 ";
137}
138
139pub struct DeprecationPolicy;
143
144impl DeprecationPolicy {
145 pub const TIMELINE: &'static str = "
152 Deprecation Timeline:
153
154 - Major version bumps (x.0.0): Deprecated APIs may be removed
155 - Minor version bumps (0.x.0): Stable APIs will not be deprecated,
156 experimental APIs may be deprecated
157 - Patch version bumps (0.0.x): No API changes except bug fixes
158
159 Deprecation Process:
160 1. API is marked as deprecated with #[deprecated] attribute
161 2. Alternative API is provided (if applicable)
162 3. Deprecation notice is included in release notes
163 4. API remains available for at least one major version
164 5. API is removed in subsequent major version
165 ";
166
167 pub const MIGRATION: &'static str = "
169 Migration Guidelines:
170
171 When APIs are deprecated, migration paths will be provided:
172 - Clear documentation of replacement APIs
173 - Migration examples in release notes
174 - Automated migration tools when possible
175 - Community support during transition periods
176 ";
177}
178
179pub struct CompatibilityMatrix;
183
184impl CompatibilityMatrix {
185 pub fn is_compatible(current: &str, required: &str) -> bool {
187 let current_parts: Vec<&str> = current.split('.').collect();
190 let required_parts: Vec<&str> = required.split('.').collect();
191
192 if current_parts.len() < 2 || required_parts.len() < 2 {
193 return false;
194 }
195
196 current_parts[0] == required_parts[0]
198 }
199
200 pub fn compatibility_level(current: &str, required: &str) -> CompatibilityLevel {
202 if Self::is_compatible(current, required) {
203 CompatibilityLevel::Compatible
204 } else {
205 CompatibilityLevel::Incompatible
206 }
207 }
208}
209
210#[derive(Debug, Clone, Copy, PartialEq, Eq)]
212pub enum CompatibilityLevel {
213 Compatible,
215 Incompatible,
217}
218
219pub struct StabilityChecker;
223
224impl StabilityChecker {
225 pub fn supports_api_version(required_version: &str) -> bool {
227 CompatibilityMatrix::is_compatible(ApiVersion::CURRENT, required_version)
228 }
229
230 pub fn get_stability_level(api_name: &str) -> StabilityLevel {
232 match api_name {
233 "Dataset"
235 | "load_iris"
236 | "load_boston"
237 | "load_breast_cancer"
238 | "load_wine"
239 | "load_digits"
240 | "make_classification"
241 | "make_regression"
242 | "make_blobs"
243 | "make_circles"
244 | "make_moons"
245 | "k_fold_split"
246 | "stratified_k_fold_split"
247 | "train_test_split" => StabilityLevel::Stable,
248
249 "GpuContext"
251 | "CloudClient"
252 | "DistributedProcessor"
253 | "MLPipeline"
254 | "StreamingIterator" => StabilityLevel::Experimental,
255
256 _ => StabilityLevel::Experimental,
258 }
259 }
260
261 pub fn validate_experimental_usage(api_name: &str) -> Result<(), String> {
263 match Self::get_stability_level(api_name) {
264 StabilityLevel::Experimental => {
265 eprintln!(
266 "Warning: '{api_name}' is an experimental API and may change in future versions"
267 );
268 Ok(())
269 }
270 StabilityLevel::Internal => Err(format!(
271 "Error: '{api_name}' is an internal API and should not be used directly"
272 )),
273 StabilityLevel::Stable => Ok(()),
274 }
275 }
276}
277
278pub mod feature_flags {
280 use super::StabilityLevel;
281
282 pub const GPU: (&str, StabilityLevel) = ("gpu", StabilityLevel::Experimental);
284
285 pub const CLOUD: (&str, StabilityLevel) = ("cloud", StabilityLevel::Experimental);
287
288 pub const DISTRIBUTED: (&str, StabilityLevel) = ("distributed", StabilityLevel::Experimental);
290
291 pub const ML_ADVANCED: (&str, StabilityLevel) = ("ml_advanced", StabilityLevel::Experimental);
293
294 pub const STREAMING: (&str, StabilityLevel) = ("streaming", StabilityLevel::Experimental);
296
297 pub const DOMAIN_SPECIFIC: (&str, StabilityLevel) =
299 ("domain_specific", StabilityLevel::Experimental);
300}
301
302#[cfg(test)]
303mod tests {
304 use super::*;
305
306 #[test]
307 fn test_compatibility_matrix() {
308 assert!(CompatibilityMatrix::is_compatible("0.1.0", "0.1.0"));
309 assert!(CompatibilityMatrix::is_compatible("0.1.1", "0.1.0"));
310 assert!(!CompatibilityMatrix::is_compatible("1.0.0", "0.1.0"));
311 assert!(!CompatibilityMatrix::is_compatible("0.1.0", "1.0.0"));
312 }
313
314 #[test]
315 fn test_stability_checker() {
316 assert_eq!(
317 StabilityChecker::get_stability_level("Dataset"),
318 StabilityLevel::Stable
319 );
320 assert_eq!(
321 StabilityChecker::get_stability_level("GpuContext"),
322 StabilityLevel::Experimental
323 );
324 }
325
326 #[test]
327 fn test_api_version() {
328 assert!(ApiVersion::CURRENT.contains('.'));
330 assert!(ApiVersion::MIN_SUPPORTED.contains('.'));
331 assert!(ApiVersion::NEXT_PLANNED.contains('.'));
332
333 assert!(ApiVersion::CURRENT >= ApiVersion::MIN_SUPPORTED);
335 }
336}