Welcome to Luxos tooling
Intro
The luxos tooling project (opens in a new tab) (github (opens in a new tab)) provides:
- A consistent API to access miners through the the luxos python package (eg.
import luxos
) - A bunch of utility cli scripts to help everyday maintenance (
luxos
andhealth-checker
at the moment)
You can find these related resources available:
Install
Detailed instruction on how to install it are provided 👉 here, to install the latest released code:
# to install it
$> pip install luxos
Quick start
Once installed the luxos (opens in a new tab) package, you can:
- Leverage the
luxos
cli scripts - Use the python api
Usage (cli)
The luxos wheel package comes with a luxos comand line script:
This will reboot all miners in the miner.csv
file list:
$> luxos --ipfile miners.csv --cmd rebootdevice --timeout 2 --verbose
There's an async
version that can work better on multiple miners, just use the --async
flag:
$> luxos --ipfile miners.csv --cmd version --timeout 2 --async --all
> 10.206.1.153:4028
| {
| "STATUS": [
| {
| "Code": 22,
| "Description": "LUXminer 2024.5.1.155432-f2badc0f",
Usage (utils api)
The luxos
package comes with an luxos.utils
module to expose a simplified version of the internal API,
useful to quickly execute commands on miners.
execute_command/rexec
This is way to get version data from a single miner using the API:
>>> from luxos.utils import execute_command
>>> execute_command("127.0.0.1", 4028, 2, "version", "", False)
{'STATUS': [{'Code': 22, 'Description': 'LUXminer ...
The async version:
>>> import asyncio
>>> from luxos import utils
>>> asyncio.run(utils.rexec("127.0.0.1", 4028, "vesion"))
{'STATUS': [{'Code': 22, 'Description': 'LUXminer ...
rexec
takes care of formatting the parameters also, the full signature is:
rexec(host="127.0.0.1", port=4028,
cmd="version", parameters="",
timeout=2., retry=1, retry_delay=3.)
parameters
can be a string, a list of any type (it will be converted into a str) or a dictionary (same conversion to string will apply).
timeout is the timeout for a call, retry is the number of try before giving up, and retry_delay controls the delay between retry.
launch
The luxos.utils.lauch
allows to rexec commands to a list of miners stored in a file:
>>> import asyncio
>>> from luxos import utils
# task is a callable with (host, port) signature
>>> async def task(host: str, port: int):
... return await utils.rexec(host, port, "version")
# miners.csv contains a list of ip addresses, one per line
>>> addresses = utils.load_ips_from_csv("miners.csv")
# batched is a keyword argument to limit execution rate
>>> asyncio.run(utils.launch(addresses, task, batch=None))
[{'STATUS': [{'Code': 22, 'Description': 'LUXmin ....
# the one-liner version
>>> asyncio.run(utils.launch(addresses, utils.rexec, "version", batch=None))