paramify 0.1.4__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.
- paramify-0.1.4/LICENSE +21 -0
- paramify-0.1.4/MANIFEST.in +4 -0
- paramify-0.1.4/PKG-INFO +281 -0
- paramify-0.1.4/README.md +240 -0
- paramify-0.1.4/examples/__pycache__/logger.cpython-312.pyc +0 -0
- paramify-0.1.4/examples/config.json +60 -0
- paramify-0.1.4/examples/config.yaml +62 -0
- paramify-0.1.4/examples/logger.py +65 -0
- paramify-0.1.4/examples/simple_params.py +34 -0
- paramify-0.1.4/examples/simple_params_web.py +36 -0
- paramify-0.1.4/paramify/__init__.py +0 -0
- paramify-0.1.4/paramify/paramify.py +258 -0
- paramify-0.1.4/paramify/paramify_web.py +106 -0
- paramify-0.1.4/paramify/static/assets/index-C3Xrcbp_.js +6794 -0
- paramify-0.1.4/paramify/static/assets/index-DwXyNpx-.css +1 -0
- paramify-0.1.4/paramify/static/index.html +17 -0
- paramify-0.1.4/paramify.egg-info/PKG-INFO +281 -0
- paramify-0.1.4/paramify.egg-info/SOURCES.txt +30 -0
- paramify-0.1.4/paramify.egg-info/dependency_links.txt +1 -0
- paramify-0.1.4/paramify.egg-info/requires.txt +3 -0
- paramify-0.1.4/paramify.egg-info/top_level.txt +2 -0
- paramify-0.1.4/setup.cfg +4 -0
- paramify-0.1.4/setup.py +45 -0
- paramify-0.1.4/tests/__init__.py +0 -0
- paramify-0.1.4/tests/test_paramify_callback.py +60 -0
- paramify-0.1.4/tests/test_paramify_cli.py +47 -0
- paramify-0.1.4/tests/test_paramify_dynamic.py +64 -0
- paramify-0.1.4/tests/test_paramify_init.py +88 -0
- paramify-0.1.4/tests/test_paramify_misc.py +61 -0
- paramify-0.1.4/tests/test_paramify_performance.py +95 -0
- paramify-0.1.4/tests/test_paramify_persist.py +80 -0
- paramify-0.1.4/tests/test_paramify_validation.py +61 -0
paramify-0.1.4/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 LuxAI S.A.
|
|
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.
|
paramify-0.1.4/PKG-INFO
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: paramify
|
|
3
|
+
Version: 0.1.4
|
|
4
|
+
Summary: A lightweight Python library for dynamic parameter management and runtime configuration.
|
|
5
|
+
Home-page: https://github.com/luxai-qtrobot/paramify
|
|
6
|
+
Author: Ali PAikan
|
|
7
|
+
Author-email: ali.paikan@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Documentation, https://github.com/luxai-qtrobot/paramify#readme
|
|
10
|
+
Project-URL: Source, https://github.com/luxai-qtrobot/paramify
|
|
11
|
+
Project-URL: Tracker, https://github.com/luxai-qtrobot/paramify/issues
|
|
12
|
+
Keywords: parameter management configuration dynamic runtime UI
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
23
|
+
Requires-Python: >=3.7
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: Flask>=2.0.0
|
|
27
|
+
Requires-Dist: pydantic>=1.10.0
|
|
28
|
+
Requires-Dist: ruamel.yaml>=0.17.0
|
|
29
|
+
Dynamic: author
|
|
30
|
+
Dynamic: author-email
|
|
31
|
+
Dynamic: classifier
|
|
32
|
+
Dynamic: description
|
|
33
|
+
Dynamic: description-content-type
|
|
34
|
+
Dynamic: home-page
|
|
35
|
+
Dynamic: keywords
|
|
36
|
+
Dynamic: license
|
|
37
|
+
Dynamic: project-url
|
|
38
|
+
Dynamic: requires-dist
|
|
39
|
+
Dynamic: requires-python
|
|
40
|
+
Dynamic: summary
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
# Paramify
|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
**Paramify** is a lightweight Python library designed to simplify dynamic parameter management. It allows developers to define, validate, and manage parameters dynamically using a JSON or YAML schema, with optional support for **command-line integration** and a **web-based parameter configuration**.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Key Features
|
|
52
|
+
|
|
53
|
+
- **Dynamic Parameter Management**: Easily define and manage parameters using a simple JSON schema.
|
|
54
|
+
- **Command-Line Integration**: Automatically generate CLI arguments using `argparser` based on your configuration, allowing runtime overrides without separate definitions.
|
|
55
|
+
- **Web Interface**: Expose parameters through a user-friendly Flask-based UI for runtime configuration.
|
|
56
|
+
- **Validation**: Automatically validate parameters with the help of Pydantic.
|
|
57
|
+
- **Custom Callbacks**: Define optional callbacks to handle updates to specific parameters.
|
|
58
|
+
- **JSON/YAML Integration**: Load and manage parameters directly from JSON or YAML files for flexible configurations.
|
|
59
|
+
- **Scope-Based Control:** Specify a parameter's scope as `"runtime"`, `"cli"` and `"all"`
|
|
60
|
+
- **Extensible**: Developers can extend the base class to add custom behaviors.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Here is an example of the Paramify web interface:
|
|
64
|
+
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Installation
|
|
70
|
+
|
|
71
|
+
To install Paramify, use the following command:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
pip install paramify
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Quick Start
|
|
80
|
+
|
|
81
|
+
### 1. Programmatic Parameter Management
|
|
82
|
+
|
|
83
|
+
Below is an example of using Paramify for managing parameters dynamically:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from logger import Logger
|
|
87
|
+
from paramify.paramify import Paramify
|
|
88
|
+
|
|
89
|
+
# Define optional callback functions
|
|
90
|
+
class MyApp(Paramify):
|
|
91
|
+
def on_param1_set(self, value):
|
|
92
|
+
Logger.info(f"param1 was updated to {value}")
|
|
93
|
+
|
|
94
|
+
def on_param2_set(self, value):
|
|
95
|
+
Logger.info(f"param2 was updated to {value}")
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
if __name__ == '__main__':
|
|
99
|
+
params = {
|
|
100
|
+
"parameters": [
|
|
101
|
+
{"name": "param1", "type": "bool", "label": "Enable Feature", "default": True},
|
|
102
|
+
{"name": "param2", "type": "int", "label": "Integer Value", "default": 4},
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
app = MyApp(params)
|
|
107
|
+
|
|
108
|
+
# Access default or loaded values
|
|
109
|
+
Logger.info(app.parameters.param1)
|
|
110
|
+
Logger.info(app.parameters.param2)
|
|
111
|
+
|
|
112
|
+
# Update values and trigger callbacks
|
|
113
|
+
app.set_param1(False)
|
|
114
|
+
app.set_param2(23)
|
|
115
|
+
|
|
116
|
+
# View current parameters
|
|
117
|
+
Logger.info(app.get_parameters())
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
This example demonstrates how to define parameters, set values programmatically, and trigger custom callbacks.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### 2. Web-Based Parameter Management
|
|
125
|
+
|
|
126
|
+
Below is an example of using **ParamifyWeb** to expose parameters through a web interface:
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
import json
|
|
130
|
+
from logger import Logger
|
|
131
|
+
from paramify.paramify_web import ParamifyWeb
|
|
132
|
+
|
|
133
|
+
# Define optional callback functions
|
|
134
|
+
class MyApp(ParamifyWeb):
|
|
135
|
+
def on_param1_set(self, value):
|
|
136
|
+
Logger.info(f"Boolean parameter was updated to {value}")
|
|
137
|
+
|
|
138
|
+
def on_param2_set(self, value):
|
|
139
|
+
Logger.info(f"Integer parameter was updated to {value}")
|
|
140
|
+
|
|
141
|
+
def on_param3_set(self, value):
|
|
142
|
+
Logger.info(f"Float parameter was updated to {value}")
|
|
143
|
+
|
|
144
|
+
def on_param4_set(self, value):
|
|
145
|
+
Logger.info(f"Selectable parameter was updated to {value}")
|
|
146
|
+
|
|
147
|
+
def on_param5_set(self, value):
|
|
148
|
+
Logger.info(f"List parameter was updated to {value}")
|
|
149
|
+
|
|
150
|
+
def on_param6_set(self, value):
|
|
151
|
+
Logger.info(f"Simple string was updated to {value}")
|
|
152
|
+
|
|
153
|
+
def on_param7_set(self, value):
|
|
154
|
+
Logger.info(f"Text area value was updated to {value}")
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
if __name__ == '__main__':
|
|
158
|
+
# Initialize the app with parameters from a YAML file
|
|
159
|
+
app = MyApp('config.yaml')
|
|
160
|
+
|
|
161
|
+
# Prevent the script from exiting immediately
|
|
162
|
+
input("Press Enter to continue...")
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
This example demonstrates how to load parameters from a YAML file and expose them via a web interface. Callback functions are triggered when parameters are updated.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## YAML Configuration Example
|
|
170
|
+
|
|
171
|
+
Here is an example of a JSON configuration file:
|
|
172
|
+
```yaml
|
|
173
|
+
name: "My Example App"
|
|
174
|
+
description: "This is an example app to demonstrate the usage of Paramify"
|
|
175
|
+
parameters:
|
|
176
|
+
- name: "param1"
|
|
177
|
+
type: "bool"
|
|
178
|
+
label: "Enable Feature"
|
|
179
|
+
description: "A boolean parameter to enable or disable a feature."
|
|
180
|
+
default: true
|
|
181
|
+
scope: "all" # cli, runtime, all
|
|
182
|
+
|
|
183
|
+
- name: "param2"
|
|
184
|
+
type: "int"
|
|
185
|
+
label: "Integer Value"
|
|
186
|
+
description: "An integer parameter for numeric configuration."
|
|
187
|
+
default: 4
|
|
188
|
+
ui:
|
|
189
|
+
element: "slider"
|
|
190
|
+
min: 1
|
|
191
|
+
max: 10
|
|
192
|
+
|
|
193
|
+
- name: "param3"
|
|
194
|
+
type: "str"
|
|
195
|
+
label: "Select Option"
|
|
196
|
+
description: "A parameter to select from predefined options."
|
|
197
|
+
default: "option 2"
|
|
198
|
+
ui:
|
|
199
|
+
element: "select"
|
|
200
|
+
items:
|
|
201
|
+
- "option 1"
|
|
202
|
+
- "option 2"
|
|
203
|
+
- "option 3"
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## JSON Configuration Example
|
|
208
|
+
|
|
209
|
+
Here is an example of a JSON configuration file:
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"name": "My Example App",
|
|
214
|
+
"description": "This is an example app to demonstrate the usage of Paramify",
|
|
215
|
+
"parameters": [
|
|
216
|
+
{
|
|
217
|
+
"name": "param1",
|
|
218
|
+
"type": "bool",
|
|
219
|
+
"label": "Enable Feature",
|
|
220
|
+
"description": "A boolean parameter to enable or disable a feature.",
|
|
221
|
+
"default": true
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": "param2",
|
|
225
|
+
"type": "int",
|
|
226
|
+
"label": "Integer Value",
|
|
227
|
+
"description": "An integer parameter for numeric configuration.",
|
|
228
|
+
"default": 4,
|
|
229
|
+
"ui": {"element": "slider", "min": 1, "max": 10}
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "param3",
|
|
233
|
+
"type": "str",
|
|
234
|
+
"label": "Select Option",
|
|
235
|
+
"description": "A parameter to select from predefined options.",
|
|
236
|
+
"default": "option 2",
|
|
237
|
+
"ui": {"element": "select", "items": ["option 1", "option 2", "option 3"]}
|
|
238
|
+
}
|
|
239
|
+
]
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## Command-Line Integration
|
|
246
|
+
Paramify automatically generates CLI arguments based on your parameter schema, eliminating the need for separate argument definitions. Parameters defined with scope: `"cli"` or scope: `"all"` (it is the default) are included in the command-line interface, allowing users to override default values directly from the terminal.
|
|
247
|
+
|
|
248
|
+
Here is an example of the generated CLI for a simple application using Paramify:
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
usage: simple_params_web.py [-h] [--param1] [--param2 PARAM2] [--param3 PARAM3]
|
|
252
|
+
|
|
253
|
+
This is an example app to demonstrate the usage of Paramify
|
|
254
|
+
|
|
255
|
+
options:
|
|
256
|
+
-h, --help show this help message and exit
|
|
257
|
+
--param1 A boolean parameter to enable or disable a feature.
|
|
258
|
+
--param2 PARAM2 An integer parameter for numeric configuration.
|
|
259
|
+
--param3 PARAM3 A parameter to select from predefined options.
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Features Overview
|
|
265
|
+
|
|
266
|
+
- **Ease of Use**: Simple, human-readable JSON schema for parameter definitions.
|
|
267
|
+
- **Web UI**: Manage and modify parameters in real-time through a web interface.
|
|
268
|
+
- **Custom Logic**: Implement application-specific callbacks for parameters.
|
|
269
|
+
- **JSON/YAML Support**: Load configurations from external JSON or YAML files for flexibility.
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## Contributing
|
|
274
|
+
|
|
275
|
+
Contributions are welcome! Feel free to open issues or submit pull requests to improve this library.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## License
|
|
280
|
+
|
|
281
|
+
This project is licensed under the MIT License. See the `LICENSE` file for details.
|
paramify-0.1.4/README.md
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
|
|
2
|
+
# Paramify
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
**Paramify** is a lightweight Python library designed to simplify dynamic parameter management. It allows developers to define, validate, and manage parameters dynamically using a JSON or YAML schema, with optional support for **command-line integration** and a **web-based parameter configuration**.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Key Features
|
|
11
|
+
|
|
12
|
+
- **Dynamic Parameter Management**: Easily define and manage parameters using a simple JSON schema.
|
|
13
|
+
- **Command-Line Integration**: Automatically generate CLI arguments using `argparser` based on your configuration, allowing runtime overrides without separate definitions.
|
|
14
|
+
- **Web Interface**: Expose parameters through a user-friendly Flask-based UI for runtime configuration.
|
|
15
|
+
- **Validation**: Automatically validate parameters with the help of Pydantic.
|
|
16
|
+
- **Custom Callbacks**: Define optional callbacks to handle updates to specific parameters.
|
|
17
|
+
- **JSON/YAML Integration**: Load and manage parameters directly from JSON or YAML files for flexible configurations.
|
|
18
|
+
- **Scope-Based Control:** Specify a parameter's scope as `"runtime"`, `"cli"` and `"all"`
|
|
19
|
+
- **Extensible**: Developers can extend the base class to add custom behaviors.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Here is an example of the Paramify web interface:
|
|
23
|
+
|
|
24
|
+

|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
To install Paramify, use the following command:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install paramify
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
### 1. Programmatic Parameter Management
|
|
41
|
+
|
|
42
|
+
Below is an example of using Paramify for managing parameters dynamically:
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
from logger import Logger
|
|
46
|
+
from paramify.paramify import Paramify
|
|
47
|
+
|
|
48
|
+
# Define optional callback functions
|
|
49
|
+
class MyApp(Paramify):
|
|
50
|
+
def on_param1_set(self, value):
|
|
51
|
+
Logger.info(f"param1 was updated to {value}")
|
|
52
|
+
|
|
53
|
+
def on_param2_set(self, value):
|
|
54
|
+
Logger.info(f"param2 was updated to {value}")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
if __name__ == '__main__':
|
|
58
|
+
params = {
|
|
59
|
+
"parameters": [
|
|
60
|
+
{"name": "param1", "type": "bool", "label": "Enable Feature", "default": True},
|
|
61
|
+
{"name": "param2", "type": "int", "label": "Integer Value", "default": 4},
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
app = MyApp(params)
|
|
66
|
+
|
|
67
|
+
# Access default or loaded values
|
|
68
|
+
Logger.info(app.parameters.param1)
|
|
69
|
+
Logger.info(app.parameters.param2)
|
|
70
|
+
|
|
71
|
+
# Update values and trigger callbacks
|
|
72
|
+
app.set_param1(False)
|
|
73
|
+
app.set_param2(23)
|
|
74
|
+
|
|
75
|
+
# View current parameters
|
|
76
|
+
Logger.info(app.get_parameters())
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This example demonstrates how to define parameters, set values programmatically, and trigger custom callbacks.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### 2. Web-Based Parameter Management
|
|
84
|
+
|
|
85
|
+
Below is an example of using **ParamifyWeb** to expose parameters through a web interface:
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
import json
|
|
89
|
+
from logger import Logger
|
|
90
|
+
from paramify.paramify_web import ParamifyWeb
|
|
91
|
+
|
|
92
|
+
# Define optional callback functions
|
|
93
|
+
class MyApp(ParamifyWeb):
|
|
94
|
+
def on_param1_set(self, value):
|
|
95
|
+
Logger.info(f"Boolean parameter was updated to {value}")
|
|
96
|
+
|
|
97
|
+
def on_param2_set(self, value):
|
|
98
|
+
Logger.info(f"Integer parameter was updated to {value}")
|
|
99
|
+
|
|
100
|
+
def on_param3_set(self, value):
|
|
101
|
+
Logger.info(f"Float parameter was updated to {value}")
|
|
102
|
+
|
|
103
|
+
def on_param4_set(self, value):
|
|
104
|
+
Logger.info(f"Selectable parameter was updated to {value}")
|
|
105
|
+
|
|
106
|
+
def on_param5_set(self, value):
|
|
107
|
+
Logger.info(f"List parameter was updated to {value}")
|
|
108
|
+
|
|
109
|
+
def on_param6_set(self, value):
|
|
110
|
+
Logger.info(f"Simple string was updated to {value}")
|
|
111
|
+
|
|
112
|
+
def on_param7_set(self, value):
|
|
113
|
+
Logger.info(f"Text area value was updated to {value}")
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
if __name__ == '__main__':
|
|
117
|
+
# Initialize the app with parameters from a YAML file
|
|
118
|
+
app = MyApp('config.yaml')
|
|
119
|
+
|
|
120
|
+
# Prevent the script from exiting immediately
|
|
121
|
+
input("Press Enter to continue...")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
This example demonstrates how to load parameters from a YAML file and expose them via a web interface. Callback functions are triggered when parameters are updated.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## YAML Configuration Example
|
|
129
|
+
|
|
130
|
+
Here is an example of a JSON configuration file:
|
|
131
|
+
```yaml
|
|
132
|
+
name: "My Example App"
|
|
133
|
+
description: "This is an example app to demonstrate the usage of Paramify"
|
|
134
|
+
parameters:
|
|
135
|
+
- name: "param1"
|
|
136
|
+
type: "bool"
|
|
137
|
+
label: "Enable Feature"
|
|
138
|
+
description: "A boolean parameter to enable or disable a feature."
|
|
139
|
+
default: true
|
|
140
|
+
scope: "all" # cli, runtime, all
|
|
141
|
+
|
|
142
|
+
- name: "param2"
|
|
143
|
+
type: "int"
|
|
144
|
+
label: "Integer Value"
|
|
145
|
+
description: "An integer parameter for numeric configuration."
|
|
146
|
+
default: 4
|
|
147
|
+
ui:
|
|
148
|
+
element: "slider"
|
|
149
|
+
min: 1
|
|
150
|
+
max: 10
|
|
151
|
+
|
|
152
|
+
- name: "param3"
|
|
153
|
+
type: "str"
|
|
154
|
+
label: "Select Option"
|
|
155
|
+
description: "A parameter to select from predefined options."
|
|
156
|
+
default: "option 2"
|
|
157
|
+
ui:
|
|
158
|
+
element: "select"
|
|
159
|
+
items:
|
|
160
|
+
- "option 1"
|
|
161
|
+
- "option 2"
|
|
162
|
+
- "option 3"
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## JSON Configuration Example
|
|
167
|
+
|
|
168
|
+
Here is an example of a JSON configuration file:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{
|
|
172
|
+
"name": "My Example App",
|
|
173
|
+
"description": "This is an example app to demonstrate the usage of Paramify",
|
|
174
|
+
"parameters": [
|
|
175
|
+
{
|
|
176
|
+
"name": "param1",
|
|
177
|
+
"type": "bool",
|
|
178
|
+
"label": "Enable Feature",
|
|
179
|
+
"description": "A boolean parameter to enable or disable a feature.",
|
|
180
|
+
"default": true
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "param2",
|
|
184
|
+
"type": "int",
|
|
185
|
+
"label": "Integer Value",
|
|
186
|
+
"description": "An integer parameter for numeric configuration.",
|
|
187
|
+
"default": 4,
|
|
188
|
+
"ui": {"element": "slider", "min": 1, "max": 10}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"name": "param3",
|
|
192
|
+
"type": "str",
|
|
193
|
+
"label": "Select Option",
|
|
194
|
+
"description": "A parameter to select from predefined options.",
|
|
195
|
+
"default": "option 2",
|
|
196
|
+
"ui": {"element": "select", "items": ["option 1", "option 2", "option 3"]}
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Command-Line Integration
|
|
205
|
+
Paramify automatically generates CLI arguments based on your parameter schema, eliminating the need for separate argument definitions. Parameters defined with scope: `"cli"` or scope: `"all"` (it is the default) are included in the command-line interface, allowing users to override default values directly from the terminal.
|
|
206
|
+
|
|
207
|
+
Here is an example of the generated CLI for a simple application using Paramify:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
usage: simple_params_web.py [-h] [--param1] [--param2 PARAM2] [--param3 PARAM3]
|
|
211
|
+
|
|
212
|
+
This is an example app to demonstrate the usage of Paramify
|
|
213
|
+
|
|
214
|
+
options:
|
|
215
|
+
-h, --help show this help message and exit
|
|
216
|
+
--param1 A boolean parameter to enable or disable a feature.
|
|
217
|
+
--param2 PARAM2 An integer parameter for numeric configuration.
|
|
218
|
+
--param3 PARAM3 A parameter to select from predefined options.
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## Features Overview
|
|
224
|
+
|
|
225
|
+
- **Ease of Use**: Simple, human-readable JSON schema for parameter definitions.
|
|
226
|
+
- **Web UI**: Manage and modify parameters in real-time through a web interface.
|
|
227
|
+
- **Custom Logic**: Implement application-specific callbacks for parameters.
|
|
228
|
+
- **JSON/YAML Support**: Load configurations from external JSON or YAML files for flexibility.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Contributing
|
|
233
|
+
|
|
234
|
+
Contributions are welcome! Feel free to open issues or submit pull requests to improve this library.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## License
|
|
239
|
+
|
|
240
|
+
This project is licensed under the MIT License. See the `LICENSE` file for details.
|
|
Binary file
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "My Example App",
|
|
3
|
+
"description": "This is an example app to demonstrate the usage of ParamifyWeb",
|
|
4
|
+
"parameters": [
|
|
5
|
+
{
|
|
6
|
+
"name": "param1",
|
|
7
|
+
"type": "bool",
|
|
8
|
+
"label": "Enable Feature",
|
|
9
|
+
"description": "A boolean parameter to enable or disable a feature.",
|
|
10
|
+
"default": true,
|
|
11
|
+
"scope": "runtime"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "param2",
|
|
15
|
+
"type": "int",
|
|
16
|
+
"label": "Integer Value",
|
|
17
|
+
"description": "An integer parameter for numeric configuration.",
|
|
18
|
+
"default": 4,
|
|
19
|
+
"ui": {"element": "slider", "min": 1, "max": 10}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "param3",
|
|
23
|
+
"type": "float",
|
|
24
|
+
"label": "Floating Point Value",
|
|
25
|
+
"description": "A float parameter for precision configuration.",
|
|
26
|
+
"default": 7.5
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "param4",
|
|
30
|
+
"type": "str",
|
|
31
|
+
"label": "Select Option",
|
|
32
|
+
"description": "A parameter to select from predefined options.",
|
|
33
|
+
"default": "option 2",
|
|
34
|
+
"ui": {"element": "select", "items": ["option 1", "option 2", "option 3"]}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "param5",
|
|
38
|
+
"type": "list",
|
|
39
|
+
"label": "List of Values",
|
|
40
|
+
"description": "A parameter to manage a list of strings.",
|
|
41
|
+
"default": ["value 1", "value 2"],
|
|
42
|
+
"ui": {"create": true}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "param6",
|
|
46
|
+
"type": "str",
|
|
47
|
+
"label": "Simple String",
|
|
48
|
+
"description": "A simple string parameter.",
|
|
49
|
+
"default": "Hello Paramify"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "param7",
|
|
53
|
+
"type": "str",
|
|
54
|
+
"label": "Text Area",
|
|
55
|
+
"description": "A long text input parameter.",
|
|
56
|
+
"default": "",
|
|
57
|
+
"ui": {"element": "textarea"}
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
name: "My Example App"
|
|
2
|
+
description: "This is an example app to demonstrate the usage of ParamifyWeb"
|
|
3
|
+
parameters:
|
|
4
|
+
- name: "param1"
|
|
5
|
+
type: "bool"
|
|
6
|
+
label: "Enable Feature"
|
|
7
|
+
description: "A boolean parameter to enable or disable a feature."
|
|
8
|
+
default: true
|
|
9
|
+
scope: "all" # cli, runtime, all
|
|
10
|
+
|
|
11
|
+
- name: "param2"
|
|
12
|
+
type: "int"
|
|
13
|
+
label: "Integer Value"
|
|
14
|
+
description: "An integer parameter for numeric configuration."
|
|
15
|
+
default: 4
|
|
16
|
+
ui:
|
|
17
|
+
element: "slider"
|
|
18
|
+
min: 1
|
|
19
|
+
max: 10
|
|
20
|
+
|
|
21
|
+
- name: "param3"
|
|
22
|
+
type: "float"
|
|
23
|
+
label: "Floating Point Value"
|
|
24
|
+
description: "A float parameter for precision configuration."
|
|
25
|
+
default: 7.5
|
|
26
|
+
|
|
27
|
+
- name: "param4"
|
|
28
|
+
type: "str"
|
|
29
|
+
label: "Select Option"
|
|
30
|
+
description: "A parameter to select from predefined options."
|
|
31
|
+
default: "option 2"
|
|
32
|
+
ui:
|
|
33
|
+
element: "select"
|
|
34
|
+
items:
|
|
35
|
+
- "option 1"
|
|
36
|
+
- "option 2"
|
|
37
|
+
- "option 3"
|
|
38
|
+
|
|
39
|
+
- name: "param5"
|
|
40
|
+
type: "list"
|
|
41
|
+
label: "List of Values"
|
|
42
|
+
description: "A parameter to manage a list of strings."
|
|
43
|
+
default:
|
|
44
|
+
- "value 1"
|
|
45
|
+
- "value 2"
|
|
46
|
+
ui:
|
|
47
|
+
create: true
|
|
48
|
+
|
|
49
|
+
- name: "param6"
|
|
50
|
+
type: "str"
|
|
51
|
+
label: "Simple String"
|
|
52
|
+
description: "A simple string parameter."
|
|
53
|
+
default: "Hello Paramify"
|
|
54
|
+
|
|
55
|
+
- name: "param7"
|
|
56
|
+
type: "str"
|
|
57
|
+
label: "Text Area"
|
|
58
|
+
description: "A long text input parameter."
|
|
59
|
+
default: ""
|
|
60
|
+
ui:
|
|
61
|
+
element: "textarea"
|
|
62
|
+
|