Skip to main content

The all encompassing LuxOS python library.

Project description

LuxOS Tools Repository

PyPI version Python versions License - MIT Build PyPI - Downloads Mypy Ruff

This package contains a python package luxos and scripts to operate miners running LuxOS. See the full documentation here.

Install

To install the latest version:

   $> pip install -U luxos

Check the version:

python -c "import luxos; print(luxos.__version__, luxos.__hash__)"
# 0.0.5 08cc733ce8aedf406856c8ad9ccbe44e78917a37

Scripting

The luxos package comes with some helper scripts, to ease everyday miners' maintenance.

luxos (cli)

This will launch the version command on a miner, returning the json output:

luxos --range 127.0.0.1 --quiet --json --cmd version 

The --range flag can tak as argument:

  • a single ip address --range 127.0.0.1
  • a range like --range 127.0.0.1-127.0.0.5
  • or addresses from a file --range @miners.csv.

Other examples:

# set/unset ATM
luxos --range 127.0.0.1 --quiet --json --cmd atmset --params "enabled=true"

# add a new profile
luxos --range 127.0.0.1 --quiet --json --cmd profilenew --params "myprofile,700,14.8"

luxos-run (cli)

The luxos-run allow to "run" a scriptlet on miners.

A scriptlet is a a python file such as my-script.py looking like this:

from luxos import asyncops
async def main(host: str, port: int):
    res = await asyncops.rexec(host, port, "version")
    return asyncops.validate(host, port, res, "VERSION")[0]

The main entry point is an async function, taking host, ip parameter: they can execute more complex operations on a set of miners specified with the --range flag, in the same way the luxos cli script does.

This will run my-script.py and report the results in json:

luxos-run --range 127.0.0.1 my-script.py

API

luxos provides an easy-to-use API to write complex scripts on miners.

It comes in two different flavours, a sync version for legacy non high performance operations, and an async version allowing operation on a fleet of miners: the API of the main functions is essentially keep identical.

Main functions

The whole of the "kernel" API is rather small-ish and it is based essentially on few functions:

  • luxos.utils.load_ips_from_csv - utility to load miners addresses from a CSV file
  • luxos.utils.rexec - an async function to launch commands on a miner
  • luxos.utils.execute_command - the same as rexec but syncronous
  • luxos.utils.validate - validate a message from a miner
  • luxos.utils.launch - run a command on multiple miners

Full documentation.

Get a miner's version (example)

Get a miner's version data (async version):

import asyncio
from luxos.utils import rexec, validate

async def get_version(host: str, port: int) -> dict:
    res = await rexec(host, port, "version")
    return validate(res, "VERSION", 1, 1)

if __name__ == "__main__":
    print(asyncio.run(get_version("127.0.0.1", 4028)))

There's a syncronous version (better for one-liners), with identical calling conventions:

from luxos.utils import execute_command, validate, load_ips_from_csv

if __name__ == "__main__":
    print(validate(execute_command(
        "127.0.0.1", 4028, 3, "version"), "VERSION", 1, 1))

Run commands (example)

The luxos.utils.launch is an async function to launch a command on a set of miners using asyncio.

This is a simple example (see Full documentation) for more.

import asyncio
from luxos.utils import validate, load_ips_from_csv, rexec, launch

async def get_version(host: str, port: int) -> dict:
    res = await rexec(host, port, "version")
    return validate(res, "VERSION", 1, 1)

if __name__ == "__main__":
    addresses = load_ips_from_csv("miners.csv")
    print(asyncio.run(launch(addresses, get_version)))

LuxOS HealthChecker - health_checker.py

The HealthChecker script is designed to continuously pull miner data from LuxOS, providing valuable insights into the health of your mining machines.

You can customize the HealthChecker params using the config.yaml file provided. To run the HealthChecker you can use health-checker if you installed using pip, or the cli python3 -m luxos.scripts.health_checker.


Feel free to explore and customize these tools to suit your specific needs. If you encounter any issues or have suggestions for improvement, please open an issue or submit a pull request.

You can find LuxOS API documentation here.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

luxos-0.2.4b48.tar.gz (41.9 kB view details)

Uploaded Source

Built Distribution

luxos-0.2.4b48-py3-none-any.whl (38.0 kB view details)

Uploaded Python 3

File details

Details for the file luxos-0.2.4b48.tar.gz.

File metadata

  • Download URL: luxos-0.2.4b48.tar.gz
  • Upload date:
  • Size: 41.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for luxos-0.2.4b48.tar.gz
Algorithm Hash digest
SHA256 efe668b14efde5a176b8fc22b4bc11d923a363be7a3c7acd39e1a020fff83cde
MD5 c843d070f32b2d2342fd69af9bf3b13c
BLAKE2b-256 fcbec1027bf8f745a162748a7be962eb106a3c79a08737e7e506035581877568

See more details on using hashes here.

File details

Details for the file luxos-0.2.4b48-py3-none-any.whl.

File metadata

  • Download URL: luxos-0.2.4b48-py3-none-any.whl
  • Upload date:
  • Size: 38.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for luxos-0.2.4b48-py3-none-any.whl
Algorithm Hash digest
SHA256 3adf42652e3604c299fda385b2d5b48bf534f8bde93856dcea0dc41164a695e6
MD5 a7ea9effd6d4fb8938e099e8e81ab722
BLAKE2b-256 e9cfd5ebc3b078f090a1905f9f1f1bdafa205abffa8752dd9e309cf166dfae5e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page