optify 0.13.0__cp315-cp315-win_amd64.whl

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/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .optify import *
Binary file
optify/optify.pyi ADDED
@@ -0,0 +1,54 @@
1
+ # Manually maintained interfaces as explained in: https://pyo3.rs/v0.25.1/python-typing-hints.html
2
+ # Eventually we should be able to automatically generate this as explained there.
3
+
4
+ from abc import ABC
5
+ from typing import List, Optional, Self
6
+
7
+
8
+ class GetOptionsPreferences:
9
+ def are_configurable_strings_enabled(self) -> bool: ...
10
+ def enable_configurable_strings(self) -> None: ...
11
+ def disable_configurable_strings(self) -> None: ...
12
+ def set_constraints_json(
13
+ self, constraints_json: Optional[str]) -> None: ...
14
+
15
+
16
+ class OptionsProviderBuilderBase(ABC):
17
+ def add_directory(self, directory: str) -> Self: ...
18
+
19
+
20
+ class OptionsProviderBase(ABC):
21
+ @classmethod
22
+ def build(cls, directory: str) -> Self: ...
23
+
24
+ @classmethod
25
+ def build_from_directories(
26
+ cls, directories: List[str]) -> Self: ...
27
+
28
+ def features(self) -> List[str]: ...
29
+
30
+
31
+ def get_filtered_features(self, feature_names: List[str], preferences: Optional[GetOptionsPreferences] = None) -> List[str]: ...
32
+
33
+ def get_options_json(self, key: str, feature_names: List[str]) -> str: ...
34
+
35
+ def get_options_json_with_preferences(
36
+ self, key: str, feature_names: List[str], preferences: Optional[GetOptionsPreferences]) -> str: ...
37
+
38
+ def map_feature_names(self, feature_names: List[str], preferences: Optional[GetOptionsPreferences] = None) -> List[Optional[str]]: ...
39
+
40
+
41
+ class OptionsProvider(OptionsProviderBase):
42
+ pass
43
+
44
+
45
+ class OptionsProviderBuilder(OptionsProviderBuilderBase):
46
+ def build(self) -> OptionsProvider: ...
47
+
48
+
49
+ class OptionsWatcher(OptionsProviderBase):
50
+ pass
51
+
52
+
53
+ class OptionsWatcherBuilder(OptionsProviderBuilderBase):
54
+ def build(self) -> OptionsWatcher: ...
optify/py.typed ADDED
File without changes
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: optify
3
+ Version: 0.13.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Requires-Dist: dacite>=1.9.2 ; extra == 'dev'
8
+ Requires-Dist: pydantic>=2.12.5 ; extra == 'dev'
9
+ Requires-Dist: pytest>=8.3.4,<9 ; extra == 'dev'
10
+ Provides-Extra: dev
11
+ License-File: LICENSE.txt
12
+ Summary: Simplifies getting the right configuration options for a process using pre-loaded configurations from files to manage options for experiments or flights.
13
+ Home-Page: https://github.com/juharris/optify/tree/main/rust/optify
14
+ Author: Justin D. Harris
15
+ License-Expression: MIT
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
18
+ Project-URL: Homepage, https://github.com/juharris/optify
19
+ Project-URL: Issues, https://github.com/juharris/optify/issues
20
+
21
+ # Optify Rust Bindings for Python
22
+
23
+ [![PyPI - Version](https://img.shields.io/pypi/v/optify?color=%23006dad)
24
+ ](https://pypi.org/project/optify)
25
+
26
+ ⚠️ Development in progress ⚠️\
27
+ APIs are not final and may change, for example, interfaces may be used in the future or method names may change.
28
+ This is just meant to be minimal to get started and help build a Python library.
29
+
30
+ See the [homepage] for details about how feature files are combined to build the options to process at runtime.
31
+
32
+ ## Usage
33
+
34
+ ```Python
35
+ import json
36
+ from optify import OptionsProvider
37
+
38
+ provider = OptionsProvider.build('path/to/configs')
39
+ config = provider.get_options_json('key', ['feature_A', 'feature_B'])
40
+ print(config)
41
+ ```
42
+
43
+ Outputs:
44
+
45
+ ```JSON
46
+ {
47
+ "myArray": [
48
+ "item 1",
49
+ "item 2"
50
+ ],
51
+ "myObject": {
52
+ "deeper": {
53
+ "new": "new value",
54
+ "num": 3333
55
+ },
56
+ "key": "val",
57
+ },
58
+ "rootString": "root string same"
59
+ }
60
+ ```
61
+
62
+ See the [tests directory](./tests/) for more examples.
63
+
64
+ ### Getting Typed Objects
65
+
66
+ The JSON output can be deserialized into typed objects using different libraries such as [dacite](https://github.com/konradhalas/dacite) (for dataclasses) or [Pydantic](https://docs.pydantic.dev/).
67
+
68
+ #### Using `dacite` with `dataclasses`
69
+
70
+ Install with `pip install dacite`
71
+
72
+ ```Python
73
+ import json
74
+ from dataclasses import dataclass
75
+
76
+ import dacite
77
+
78
+ from optify import OptionsProvider
79
+
80
+
81
+ @dataclass
82
+ class Deeper:
83
+ newValue: str
84
+ num: int
85
+
86
+
87
+ @dataclass
88
+ class MyObject:
89
+ key: str
90
+ deeper: Deeper
91
+
92
+
93
+ @dataclass
94
+ class MyConfig:
95
+ rootString: str
96
+ myArray: list[str]
97
+ myObject: MyObject
98
+
99
+
100
+ provider = OptionsProvider.build('path/to/configs')
101
+ options_json = provider.get_options_json('myConfig', ['feature_A', 'feature_B'])
102
+ config = dacite.from_dict(data_class=MyConfig, data=json.loads(options_json))
103
+
104
+ print(config.rootString)
105
+ print(config.myObject.deeper.newValue)
106
+ ```
107
+
108
+ #### Using Pydantic
109
+
110
+ Install with `pip install pydantic`
111
+
112
+ ```Python
113
+ import json
114
+
115
+ from pydantic import BaseModel
116
+
117
+ from optify import OptionsProvider
118
+
119
+
120
+ class Deeper(BaseModel):
121
+ newValue: str
122
+ num: int
123
+
124
+
125
+ class MyObject(BaseModel):
126
+ key: str
127
+ deeper: Deeper
128
+
129
+
130
+ class MyConfig(BaseModel):
131
+ rootString: str
132
+ myArray: list[str]
133
+ myObject: MyObject
134
+
135
+
136
+ provider = OptionsProvider.build('path/to/configs')
137
+ options_json = provider.get_options_json('myConfig', ['feature_A', 'feature_B'])
138
+ config = MyConfig.model_validate_json(options_json)
139
+
140
+ print(config.rootString)
141
+ print(config.myObject.deeper.newValue)
142
+ ```
143
+
144
+ ### Watching for Changes
145
+
146
+ Use `OptionsWatcher` instead of `OptionsProvider` during development to have it automatically reload the options it stores when the files change:
147
+
148
+ ```Python
149
+ from optify import OptionsWatcher
150
+
151
+ watcher = OptionsWatcher.build('path/to/configs')
152
+ ```
153
+
154
+ ## Development
155
+
156
+ ### Setup
157
+
158
+ ```shell
159
+ pyenv virtualenv 3.12 optify-dev
160
+ pyenv local optify-dev
161
+
162
+ pip install -e '.[dev]'
163
+ pip install maturin
164
+ ```
165
+
166
+ ### Build
167
+
168
+ ```shell
169
+ maturin develop
170
+ ```
171
+
172
+ ### Tests
173
+
174
+ ```shell
175
+ pytest
176
+ ```
177
+
178
+ ### Formatting
179
+
180
+ To automatically change the Rust code, run:
181
+
182
+ ```shell
183
+ cargo fmt && cargo clippy --fix --allow-dirty --allow-staged
184
+ ```
185
+
186
+ # Publishing
187
+
188
+ A GitHub Action will automatically publish new versions: https://github.com/juharris/optify/actions/workflows/python_publish.yml
189
+
190
+ [homepage]: https://github.com/juharris/optify
191
+
@@ -0,0 +1,9 @@
1
+ optify/__init__.py,sha256=gUi29XxZ0h5Og6MJAN8z_r1thCzcmC_UaaxsctVENUo,22
2
+ optify/optify.cp315-win_amd64.pyd,sha256=8Dj2mC_te3iL7mRfjBTX0w8OH-pxYAvj9GIHFFiFxZQ,8665088
3
+ optify/optify.pyi,sha256=E_xOalxIyUZNmPbnV9SVFGl7dx0hqOp08Sl8JUyWl14,1749
4
+ optify/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ optify-0.13.0.dist-info/METADATA,sha256=iGpx65VcHQh-BSYjllJVkwhEthzvfvI3vxqp8eaclTo,4227
6
+ optify-0.13.0.dist-info/WHEEL,sha256=1_h6kx0k2_JFDbRzyfVOsGEcPlSNf1uBTnmW3MNufiU,97
7
+ optify-0.13.0.dist-info/licenses/LICENSE.txt,sha256=GoecOr4U_5c3kPEeO9oDyd6y1twX2raeq4FX_e7WL5k,1073
8
+ optify-0.13.0.dist-info/sboms/optify-python.cyclonedx.json,sha256=lF-o7IeCIvlDzUWvmm0rz9Hu5VsKJYMlqwPg8rfPrmA,209319
9
+ optify-0.13.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.15.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp315-cp315-win_amd64
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Justin D. Harris
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.