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 repository contains scripts we built to operate and troubleshoot miners running LuxOS.

For an example how to use the luxos command line tool 👉 here.

For a quick example how to control miners using the luxos api 👉 here.

If you're developing a script, you might want to leverage the luxos cli package 👉 here.

Quick scripting examples

launch a single command

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

luxos --range 127.0.0.1 --cmd version

You can pass a "range" of ips:

luxos --range 127.0.0.1:127.0.0.4 --cmd version

Or you can save them in a csv file:

luxos --range @miners.csv --cmd version

launch a script on multiple miner

The luxos-run allow to "run" a script on miners:

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

(note the syntax is similar to luxos)

The my-script.py file look like:

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]

Installation

To install the latest and greatest version:

   $> pip install -U luxos

To install a beta (see here for the complete list):

   $> pip install -U luxos==0.0.5b18

Finally you can install the latest bleeding edge code as:

   $> pip install git+https://github.com/LuxorLabs/luxos-tooling.git

If you're new to a python venv, there are generic instructions venv.

Verify

Once installed you can verify the version and the commit the code is from using:

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

Help

See files under the docs/folder.

Examples

This is a curated list of examples.

Usage (api)

You can use the python api to perform the commands instead the CLI.

This is way to get version data from a miner (async version):

   >>> from luxos.asyncops import rexec, validate
   >>> res = await rexec("127.0.0.1", 4028, "version")
   {'STATUS': [{'Code': 22, 'Description': 'LUXminer ...
   >>> validate(res, "VERSION")
   {'API': '3.7', ...

There's a syncronous version, with identical calling conventions:

   >>> from luxos.syncops import rexec, validate
   >>> res = rexec("127.0.0.1", 4028, "version")
   {'STATUS': [{'Code': 22, 'Description': 'LUXminer ...
   >>> validate(res, "VERSION")
   {'API': '3.7', ...

Alternatively, you can use the module utils, where there are support functions for one-shot command execution:

   >>> import asyncio
   >>> from luxos import utils
   >>> asyncio.run(utils.rexec("127.0.0.1", 4028, "vesion"))
   {'STATUS': [{'Code': 22, 'Description': 'LUXminer ...

rexec has a nicer api and it takes care of formatting the parameters, the full signature is:

rexec(host="127.0.0.1", port=4028, cmd="version", parameters="", timeout=2., retry=1, retry_delay=3.)

Where 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.

The luxos.utils.lauch allows to rexec commands to a list of miners stored in a file:

   >>> import asyncio
   >>> from luxos import utils
   >>> async def task(host: str, port: int):                   # task must be a callable 
   ...   return await utils.rexec(host, port, "version")
   >>> addresses = utils.load_ips_from_csv("miners.csv")       # miners.csv contains a list of ip addresses, one per line
   >>> asyncio.run(utils.launch(addresses, task, batch=None))  # batched is a keyword argument to limit execution rate (if set to a positive int)
   [{'STATUS': [{'Code': 22, 'Description': 'LUXmin ....

   OR in one line:
   >>> asyncio.run(utils.launch(addresses, utils.rexec, "version", batch=None))

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.0b41.tar.gz (38.1 kB view hashes)

Uploaded Source

Built Distribution

luxos-0.2.0b41-py3-none-any.whl (35.2 kB view hashes)

Uploaded Python 3

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