Name | valmix JSON |
Version |
1.0.0
JSON |
| download |
home_page | None |
Summary | Adjust numerical values from a terminal user interface. |
upload_time | 2025-07-14 09:00:38 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
multiprocessing
value
tui
user
interface
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Valmix
<img align="right" width=400 src="https://github.com/stephane-caron/valmix/assets/1189580/280c02b9-46a4-4a61-bb42-3befd1c59879">
[](https://github.com/stephane-caron/valmix/actions)
[](https://stephane-caron.github.io/valmix/)
[](https://coveralls.io/github/stephane-caron/valmix?branch=main)
[](https://pypi.org/project/valmix/)
Valmix ("value mixer") gives a systematic way to tune Python program parameters from your terminal (similar to `alsamixer` for Linux users familiar with it). Wrap your parameters in `multiprocessing` values, pass them to both your program and `valmix.run()`, and a terminal user interface will appear 🪔 allowing you to modify parameters in real time while your program is running.
Code is shorter than words in [Usage](#usage) below :wink:
## Installation
### From conda-forge
```console
conda install -c conda-forge valmix
```
### From PyPI
```console
pip install valmix
```
## Usage
Suppose you have a Python program with parameters you want to tune:
```py
def main(kp: float, kd: float):
pass # your code here
```
Valmix gives a systematic way to tune these parameters from the command line. First, wrap your parameters in `multiprocessing.Value`s:
```py
import multiprocessing as mp
kp = mp.Value("f", 10.0)
kd = mp.Value("f", 1.0)
```
Next, update your program to read from the multiprocessing values. For example:
```py
import numpy as np
import time
def main(kp: mp.Value, kd: mp.Value):
with open("/tmp/output", "w") as output:
for _ in range(100):
u = np.clip(kp.value * 1.0 + kd.value * 0.1, 5.0, 20.0)
output.write(f"{u}\n")
output.flush()
time.sleep(1.0)
```
Finally, run your program and Valmix together, specifying the tuning range for each value:
```py
main_process = mp.Process(target=main, args=(kp, kd))
main_process.start()
valmix.run(
{
"kp": (kp, np.arange(0.0, 20.0, 0.5)),
"kd": (kd, np.arange(0.0, 10.0, 0.5)),
}
)
```
This will fire up a terminal user interface (TUI) where you can tune `kp` and `kd` while the program runs in the background:

Useful for instance to [tune robot behaviors](https://github.com/upkie/upkie/blob/main/examples/wheeled_balancing.py) in real-time 😉
## See also
Related software:
- [Textual](https://textual.textualize.io/): terminal user interface (TUI) framework for Python, used to build this tool.
Raw data
{
"_id": null,
"home_page": null,
"name": "valmix",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "St\u00e9phane Caron <stephane.caron@inria.fr>",
"keywords": "multiprocessing, value, tui, user, interface",
"author": null,
"author_email": "St\u00e9phane Caron <stephane.caron@inria.fr>",
"download_url": "https://files.pythonhosted.org/packages/77/15/40cc4a676ac44dec126f23252d9426048d79d6757f6c004768bd51d4ffa6/valmix-1.0.0.tar.gz",
"platform": null,
"description": "# Valmix\n\n<img align=\"right\" width=400 src=\"https://github.com/stephane-caron/valmix/assets/1189580/280c02b9-46a4-4a61-bb42-3befd1c59879\">\n\n[](https://github.com/stephane-caron/valmix/actions)\n[](https://stephane-caron.github.io/valmix/)\n[](https://coveralls.io/github/stephane-caron/valmix?branch=main)\n[](https://pypi.org/project/valmix/)\n\nValmix (\"value mixer\") gives a systematic way to tune Python program parameters from your terminal (similar to `alsamixer` for Linux users familiar with it). Wrap your parameters in `multiprocessing` values, pass them to both your program and `valmix.run()`, and a terminal user interface will appear \ud83e\ude94 allowing you to modify parameters in real time while your program is running.\n\nCode is shorter than words in [Usage](#usage) below :wink:\n\n## Installation\n\n### From conda-forge\n\n```console\nconda install -c conda-forge valmix\n```\n\n### From PyPI\n\n```console\npip install valmix\n```\n\n## Usage\n\nSuppose you have a Python program with parameters you want to tune:\n\n```py\ndef main(kp: float, kd: float):\n pass # your code here\n```\n\nValmix gives a systematic way to tune these parameters from the command line. First, wrap your parameters in `multiprocessing.Value`s:\n\n```py\nimport multiprocessing as mp\n\nkp = mp.Value(\"f\", 10.0)\nkd = mp.Value(\"f\", 1.0)\n```\n\nNext, update your program to read from the multiprocessing values. For example:\n\n```py\nimport numpy as np\nimport time\n\ndef main(kp: mp.Value, kd: mp.Value):\n with open(\"/tmp/output\", \"w\") as output:\n for _ in range(100):\n u = np.clip(kp.value * 1.0 + kd.value * 0.1, 5.0, 20.0)\n output.write(f\"{u}\\n\")\n output.flush()\n time.sleep(1.0)\n\n```\n\nFinally, run your program and Valmix together, specifying the tuning range for each value:\n\n```py\nmain_process = mp.Process(target=main, args=(kp, kd))\nmain_process.start()\n\nvalmix.run(\n {\n \"kp\": (kp, np.arange(0.0, 20.0, 0.5)),\n \"kd\": (kd, np.arange(0.0, 10.0, 0.5)),\n }\n)\n```\n\nThis will fire up a terminal user interface (TUI) where you can tune `kp` and `kd` while the program runs in the background:\n\n\n\nUseful for instance to [tune robot behaviors](https://github.com/upkie/upkie/blob/main/examples/wheeled_balancing.py) in real-time \ud83d\ude09\n\n## See also\n\nRelated software:\n\n- [Textual](https://textual.textualize.io/): terminal user interface (TUI) framework for Python, used to build this tool.\n",
"bugtrack_url": null,
"license": null,
"summary": "Adjust numerical values from a terminal user interface.",
"version": "1.0.0",
"project_urls": {
"Changelog": "https://github.com/stephane-caron/valmix/blob/main/CHANGELOG.md",
"Homepage": "https://github.com/stephane-caron/valmix",
"Source": "https://github.com/stephane-caron/valmix",
"Tracker": "https://github.com/stephane-caron/valmix/issues"
},
"split_keywords": [
"multiprocessing",
" value",
" tui",
" user",
" interface"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "c4b15469925c9042c104c32bc919f916cad97f59683cf1a25a3eaed768c41d6a",
"md5": "8a638e991b5ca1795d9a6f4352caf6f7",
"sha256": "d92a1c316ac90d465b2462d3604c2dafb4fd1edc4483fce910c8a0b724aabcc6"
},
"downloads": -1,
"filename": "valmix-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8a638e991b5ca1795d9a6f4352caf6f7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 10835,
"upload_time": "2025-07-14T09:00:35",
"upload_time_iso_8601": "2025-07-14T09:00:35.888788Z",
"url": "https://files.pythonhosted.org/packages/c4/b1/5469925c9042c104c32bc919f916cad97f59683cf1a25a3eaed768c41d6a/valmix-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "771540cc4a676ac44dec126f23252d9426048d79d6757f6c004768bd51d4ffa6",
"md5": "a5948c5223f8bf8163f4374790cbc083",
"sha256": "48f992e92b61b4adab1460397ff45cb8e6770578683741e0d14cc61f881213e1"
},
"downloads": -1,
"filename": "valmix-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "a5948c5223f8bf8163f4374790cbc083",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 52105,
"upload_time": "2025-07-14T09:00:38",
"upload_time_iso_8601": "2025-07-14T09:00:38.641008Z",
"url": "https://files.pythonhosted.org/packages/77/15/40cc4a676ac44dec126f23252d9426048d79d6757f6c004768bd51d4ffa6/valmix-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-14 09:00:38",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "stephane-caron",
"github_project": "valmix",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "valmix"
}