optify 0.8.1__tar.gz → 0.8.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {optify-0.8.1 → optify-0.8.2}/PKG-INFO +1 -1
- {optify-0.8.1 → optify-0.8.2}/pyproject.toml +2 -2
- {optify-0.8.1 → optify-0.8.2}/python/optify/Cargo.lock +2 -2
- {optify-0.8.1 → optify-0.8.2}/python/optify/Cargo.toml +2 -2
- {optify-0.8.1 → optify-0.8.2}/rust/optify/Cargo.toml +1 -1
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/builder/builder_impl.rs +17 -11
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/provider/provider_impl.rs +7 -51
- {optify-0.8.1 → optify-0.8.2}/LICENSE.txt +0 -0
- {optify-0.8.1 → optify-0.8.2}/README.md +0 -0
- {optify-0.8.1 → optify-0.8.2}/optify/__init__.py +0 -0
- {optify-0.8.1 → optify-0.8.2}/optify/optify.pyi +0 -0
- {optify-0.8.1 → optify-0.8.2}/optify/py.typed +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/.gitignore +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/.vscode/settings.json +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/LICENSE.txt +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/README.md +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/optify/__init__.py +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/optify/optify.pyi +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/optify/py.typed +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/src/lib.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/src/preferences.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/src/provider.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/src/watcher.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/tests/test_builder.py +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/tests/test_optify.py +0 -0
- {optify-0.8.1 → optify-0.8.2}/python/optify/tests/test_provider.py +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/.claude/settings.json +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/README.md +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/benches/caching_benchmark.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/benches/loading_benchmark.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/build.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/builder/builder_options.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/builder/builder_trait.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/builder/loading_result.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/builder/mod.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/builder/watcher_builder.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/configurable_string/configurable_string_impl.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/configurable_string/locator.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/configurable_string/mod.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/json/mod.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/json/reader.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/lib.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/provider/constraints.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/provider/get_options_preferences.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/provider/mod.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/provider/provider_trait.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/provider/watcher.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/provider/watcher_options.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/schema/conditions.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/schema/feature.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/schema/metadata.rs +0 -0
- {optify-0.8.1 → optify-0.8.2}/rust/optify/src/schema/mod.rs +0 -0
|
@@ -26,11 +26,11 @@ build-backend = "maturin"
|
|
|
26
26
|
|
|
27
27
|
[package]
|
|
28
28
|
name = "optify"
|
|
29
|
-
version = "0.8.
|
|
29
|
+
version = "0.8.2"
|
|
30
30
|
|
|
31
31
|
[tool.poetry]
|
|
32
32
|
name = "optify"
|
|
33
|
-
version = "0.8.
|
|
33
|
+
version = "0.8.2"
|
|
34
34
|
description = "Simplifies getting the right configuration options for a process using pre-loaded configurations from files to manage options for experiments or flights."
|
|
35
35
|
authors = ["Justin D. Harris"]
|
|
36
36
|
maintainers = ["Justin D. Harris"]
|
|
@@ -1132,7 +1132,7 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
|
1132
1132
|
|
|
1133
1133
|
[[package]]
|
|
1134
1134
|
name = "optify"
|
|
1135
|
-
version = "0.20.
|
|
1135
|
+
version = "0.20.2"
|
|
1136
1136
|
dependencies = [
|
|
1137
1137
|
"config",
|
|
1138
1138
|
"dunce",
|
|
@@ -1150,7 +1150,7 @@ dependencies = [
|
|
|
1150
1150
|
|
|
1151
1151
|
[[package]]
|
|
1152
1152
|
name = "optify-python"
|
|
1153
|
-
version = "0.8.
|
|
1153
|
+
version = "0.8.2"
|
|
1154
1154
|
dependencies = [
|
|
1155
1155
|
"optify",
|
|
1156
1156
|
"pyo3",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "optify-python"
|
|
3
|
-
version = "0.8.
|
|
3
|
+
version = "0.8.2"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
|
|
6
6
|
description = "Simplifies getting the right configuration options for a process using pre-loaded configurations from files (JSON, YAML, etc.) to manage options for experiments or flights. This library is mainly made to support building implementations for other languages such as Node.js, Python, and Ruby. It is not meant to be consumed directly yet."
|
|
@@ -15,5 +15,5 @@ name = "optify"
|
|
|
15
15
|
crate-type = ["cdylib"]
|
|
16
16
|
|
|
17
17
|
[dependencies]
|
|
18
|
-
optify = { path = "../../rust/optify", version = "0.20.
|
|
18
|
+
optify = { path = "../../rust/optify", version = "0.20.2" }
|
|
19
19
|
pyo3 = "0.24.1"
|
|
@@ -12,9 +12,7 @@ use crate::builder::OptionsRegistryBuilder;
|
|
|
12
12
|
use crate::configurable_string::locator::find_configurable_values;
|
|
13
13
|
use crate::configurable_string::LoadedFiles;
|
|
14
14
|
use crate::json::reader::read_json_from_file_as;
|
|
15
|
-
use crate::provider::{
|
|
16
|
-
Aliases, Conditions, ConfigurableValuePointers, Features, OptionsProvider, Sources,
|
|
17
|
-
};
|
|
15
|
+
use crate::provider::{Aliases, Conditions, Features, OptionsProvider, Sources};
|
|
18
16
|
use crate::schema::feature::FeatureConfiguration;
|
|
19
17
|
use crate::schema::metadata::OptionsMetadata;
|
|
20
18
|
|
|
@@ -28,7 +26,7 @@ type Imports = HashMap<String, Vec<String>>;
|
|
|
28
26
|
#[derive(Clone)]
|
|
29
27
|
pub struct OptionsProviderBuilder {
|
|
30
28
|
aliases: Aliases,
|
|
31
|
-
|
|
29
|
+
all_configurable_value_pointers: HashSet<String>,
|
|
32
30
|
dependents: Dependents,
|
|
33
31
|
conditions: Conditions,
|
|
34
32
|
features: Features,
|
|
@@ -184,8 +182,8 @@ impl OptionsProviderBuilder {
|
|
|
184
182
|
pub fn new() -> Self {
|
|
185
183
|
OptionsProviderBuilder {
|
|
186
184
|
aliases: Aliases::new(),
|
|
185
|
+
all_configurable_value_pointers: HashSet::new(),
|
|
187
186
|
conditions: Conditions::new(),
|
|
188
|
-
configurable_value_pointers: ConfigurableValuePointers::new(),
|
|
189
187
|
dependents: Dependents::new(),
|
|
190
188
|
features: Features::new(),
|
|
191
189
|
imports: HashMap::new(),
|
|
@@ -198,10 +196,15 @@ impl OptionsProviderBuilder {
|
|
|
198
196
|
pub fn build_and_clear(&mut self) -> Result<OptionsProvider, String> {
|
|
199
197
|
self.prepare_build()?;
|
|
200
198
|
|
|
199
|
+
let all_configurable_value_pointers = self
|
|
200
|
+
.all_configurable_value_pointers
|
|
201
|
+
.iter()
|
|
202
|
+
.cloned()
|
|
203
|
+
.collect();
|
|
201
204
|
Ok(OptionsProvider::new(
|
|
202
205
|
std::mem::take(&mut self.aliases),
|
|
206
|
+
all_configurable_value_pointers,
|
|
203
207
|
std::mem::take(&mut self.conditions),
|
|
204
|
-
std::mem::take(&mut self.configurable_value_pointers),
|
|
205
208
|
std::mem::take(&mut self.features),
|
|
206
209
|
std::mem::take(&mut self.loaded_files),
|
|
207
210
|
std::mem::take(&mut self.sources),
|
|
@@ -389,10 +392,8 @@ impl OptionsProviderBuilder {
|
|
|
389
392
|
.insert(canonical_feature_name.clone(), imports.clone());
|
|
390
393
|
}
|
|
391
394
|
if !info.configurable_value_pointers.is_empty() {
|
|
392
|
-
self.
|
|
393
|
-
|
|
394
|
-
info.configurable_value_pointers.clone(),
|
|
395
|
-
);
|
|
395
|
+
self.all_configurable_value_pointers
|
|
396
|
+
.extend(info.configurable_value_pointers.iter().cloned());
|
|
396
397
|
}
|
|
397
398
|
add_alias(
|
|
398
399
|
&mut self.aliases,
|
|
@@ -524,10 +525,15 @@ impl OptionsRegistryBuilder<OptionsProvider> for OptionsProviderBuilder {
|
|
|
524
525
|
fn build(&mut self) -> Result<OptionsProvider, String> {
|
|
525
526
|
self.prepare_build()?;
|
|
526
527
|
|
|
528
|
+
let all_configurable_value_pointers = self
|
|
529
|
+
.all_configurable_value_pointers
|
|
530
|
+
.iter()
|
|
531
|
+
.cloned()
|
|
532
|
+
.collect();
|
|
527
533
|
Ok(OptionsProvider::new(
|
|
528
534
|
self.aliases.clone(),
|
|
535
|
+
all_configurable_value_pointers,
|
|
529
536
|
self.conditions.clone(),
|
|
530
|
-
self.configurable_value_pointers.clone(),
|
|
531
537
|
self.features.clone(),
|
|
532
538
|
self.loaded_files.clone(),
|
|
533
539
|
self.sources.clone(),
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
use std::{
|
|
2
|
-
collections::{HashMap, HashSet},
|
|
3
|
-
path::Path,
|
|
4
|
-
sync::RwLock,
|
|
5
|
-
};
|
|
1
|
+
use std::{collections::HashMap, path::Path, sync::RwLock};
|
|
6
2
|
|
|
7
3
|
use crate::{
|
|
8
4
|
builder::{OptionsProviderBuilder, OptionsRegistryBuilder},
|
|
@@ -22,7 +18,6 @@ pub(crate) type SourceValue = config::File<config::FileSourceString, config::Fil
|
|
|
22
18
|
|
|
23
19
|
pub(crate) type Aliases = HashMap<unicase::UniCase<String>, String>;
|
|
24
20
|
pub(crate) type Conditions = HashMap<String, ConditionExpression>;
|
|
25
|
-
pub(crate) type ConfigurableValuePointers = HashMap<String, Vec<String>>;
|
|
26
21
|
pub(crate) type Features = HashMap<String, OptionsMetadata>;
|
|
27
22
|
pub(crate) type Sources = HashMap<String, SourceValue>;
|
|
28
23
|
|
|
@@ -34,9 +29,9 @@ pub struct CacheOptions {}
|
|
|
34
29
|
/// ⚠️ Development in progress ⚠️\
|
|
35
30
|
/// Not truly considered public and mainly available to support bindings for other languages.
|
|
36
31
|
pub struct OptionsProvider {
|
|
32
|
+
all_configurable_value_pointers: Vec<String>,
|
|
37
33
|
aliases: Aliases,
|
|
38
34
|
conditions: Conditions,
|
|
39
|
-
configurable_value_pointers: ConfigurableValuePointers,
|
|
40
35
|
features: Features,
|
|
41
36
|
loaded_files: LoadedFiles,
|
|
42
37
|
sources: Sources,
|
|
@@ -49,16 +44,16 @@ pub struct OptionsProvider {
|
|
|
49
44
|
impl OptionsProvider {
|
|
50
45
|
pub(crate) fn new(
|
|
51
46
|
aliases: Aliases,
|
|
47
|
+
all_configurable_value_pointers: Vec<String>,
|
|
52
48
|
conditions: Conditions,
|
|
53
|
-
configurable_value_pointers: ConfigurableValuePointers,
|
|
54
49
|
features: Features,
|
|
55
50
|
loaded_files: LoadedFiles,
|
|
56
51
|
sources: Sources,
|
|
57
52
|
) -> Self {
|
|
58
53
|
OptionsProvider {
|
|
54
|
+
all_configurable_value_pointers,
|
|
59
55
|
aliases,
|
|
60
56
|
conditions,
|
|
61
|
-
configurable_value_pointers,
|
|
62
57
|
features,
|
|
63
58
|
loaded_files,
|
|
64
59
|
sources,
|
|
@@ -174,7 +169,6 @@ impl OptionsProvider {
|
|
|
174
169
|
pub fn process_configurable_strings(
|
|
175
170
|
&self,
|
|
176
171
|
value: &mut serde_json::Value,
|
|
177
|
-
feature_names: &[String],
|
|
178
172
|
key_prefix: Option<&str>,
|
|
179
173
|
preferences: Option<&GetOptionsPreferences>,
|
|
180
174
|
) -> Result<(), String> {
|
|
@@ -186,40 +180,7 @@ impl OptionsProvider {
|
|
|
186
180
|
return Ok(());
|
|
187
181
|
}
|
|
188
182
|
|
|
189
|
-
|
|
190
|
-
// There are no configurable strings to process, assume they are not enabled for the provider, even for use in overrides.
|
|
191
|
-
return Ok(());
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// When overrides are present, dynamically discover all configurable strings
|
|
195
|
-
// because overrides may contain ConfigurableStrings not in the original features
|
|
196
|
-
let has_overrides = preferences
|
|
197
|
-
.map(|p| p.overrides_json.is_some())
|
|
198
|
-
.unwrap_or(false);
|
|
199
|
-
|
|
200
|
-
// TODO It would be nice to save memory and use a `HashSet<&String>` instead of a `HashSet<String>`.
|
|
201
|
-
// `HashSet<String>` is needed when there are overrides, but that should be the exception rather than the rule.
|
|
202
|
-
let pointers: HashSet<String> = if has_overrides {
|
|
203
|
-
// Dynamically find all configurable strings in the merged value
|
|
204
|
-
crate::configurable_string::locator::find_configurable_values(Some(value))
|
|
205
|
-
.into_iter()
|
|
206
|
-
.collect()
|
|
207
|
-
} else {
|
|
208
|
-
// Collect all configurable pointers for the requested features.
|
|
209
|
-
feature_names
|
|
210
|
-
.iter()
|
|
211
|
-
.filter_map(|feature_name| self.configurable_value_pointers.get(feature_name))
|
|
212
|
-
.flat_map(|pointers| pointers.iter())
|
|
213
|
-
.cloned()
|
|
214
|
-
.collect()
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
if pointers.is_empty() {
|
|
218
|
-
// There are no configurable strings to process.
|
|
219
|
-
return Ok(());
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
for pointer in &pointers {
|
|
183
|
+
for pointer in &self.all_configurable_value_pointers {
|
|
223
184
|
let relative_pointer = match key_prefix {
|
|
224
185
|
Some(key_prefix) => {
|
|
225
186
|
if !pointer.starts_with(key_prefix) {
|
|
@@ -333,7 +294,7 @@ impl OptionsRegistry for OptionsProvider {
|
|
|
333
294
|
|
|
334
295
|
match config.try_deserialize::<serde_json::Value>() {
|
|
335
296
|
Ok(mut value) => {
|
|
336
|
-
self.process_configurable_strings(&mut value,
|
|
297
|
+
self.process_configurable_strings(&mut value, None, preferences)?;
|
|
337
298
|
Ok(value)
|
|
338
299
|
}
|
|
339
300
|
Err(e) => Err(e.to_string()),
|
|
@@ -437,12 +398,7 @@ impl OptionsRegistry for OptionsProvider {
|
|
|
437
398
|
|
|
438
399
|
match config.get::<serde_json::Value>(key) {
|
|
439
400
|
Ok(mut value) => {
|
|
440
|
-
self.process_configurable_strings(
|
|
441
|
-
&mut value,
|
|
442
|
-
&filtered_feature_names,
|
|
443
|
-
Some(key),
|
|
444
|
-
preferences,
|
|
445
|
-
)?;
|
|
401
|
+
self.process_configurable_strings(&mut value, Some(key), preferences)?;
|
|
446
402
|
if cache_options.is_some() {
|
|
447
403
|
let are_configurable_strings_enabled = preferences
|
|
448
404
|
.map(|p| p.are_configurable_strings_enabled)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{optify-0.8.1 → optify-0.8.2}/rust/optify/src/configurable_string/configurable_string_impl.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|