# Python MMPOS API Library and CLI tool
The MMPOS crypto mining platform has a REST API that allows us to make changes without using the GUI.
This python module brings the power of that API to a native python library and command line tool.
## Installation
If you don't use `pipx`, you're missing out.
Here are [installation instructions](https://pypa.github.io/pipx).
Simply run:
`pipx install . (For installing locally in isolated environment with pipx)`
Or
`pip3 install mmpos`
## Requirements
* Python 3.8+
It may work with older python versions, especially 3.x versions, but I am only testing 3.8+.
## Features
* List rig data
* List gpu data
* List farm data
* List mining profiles
* Show data in either table or json formats
* Control a rig (disable, enable, reset, poweroff, ...)
* Control rig one at a time, everything all at once. (Disable everything!)
* Simulate the control action if you are feeling worried.
* Set mining profile
* Use short ids to identify components of MMPOS
* Output json, plain and table format, pipe into other commands
## CLI Usage
To use it:
$ mmpos --help
Each command allows you to list the data in json or table format. The json output usually provides more output while the table is human readable and provides a subset of the total information.
All commands have `--json` and `--table`. Use the `--help` to verify these switches work for that command.
Examples:
```shell
$ mmpos --help
Usage: mmpos [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
farms
rigs
$ mmpos farms --help
Usage: mmpos farms [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
list
$ mmpos rigs --help
Usage: mmpos rigs [OPTIONS] COMMAND [ARGS]...
Options:
--help Show this message and exit.
Commands:
control
gpus
list
$ mmpos rigs control --help
Usage: mmpos rigs control [OPTIONS]
Options:
--rig_id TEXT The rig id, not required when using --all or
--everywhere flags
--farm_id TEXT The farm id, defaults to first farm found,
use '--all' flag for all farms [default:
first]
--all Run action on all rigs across the entire
farm
--everywhere Danger: Run action on all rigs across all
farms
--action [disable|poweroff|reset|enable|restart|reboot]
[required]
--simulate Simulate the action only
--help Show this message and exit.
```
## Output Format
You can adjust the output format from the default table format to json output. Table output will normally be shorter and the json will provide much greater detail.
## API Usage
I have built this with the intention of using the api in other areas of automation like ansible playbooks and such. Usage should be pretty
simple. The API will change in the future as I build out the remaining MMPOS API calls.
```
pip install mmpos
import mmpos.api.farms as farms
import mmpos.api.rigs as rigs
farms.get()
rigs.get()
```
## Notes
This is alpha quality, expect things to change, feature requests welcome as is any code contributions.
* Most data is cached for 5 minutes to speed up future calls. You will notice this when repeating calls. This can be controlled as the underlying mechanism is requests_cache library.
### Using short ids
The MMPOS API uses long uuids as their identifiers. This makes it annoying to work with on the CLI due to 36 character length.
As a result I have created a translation layer that will encode the uuid into 8 characters. You can use this id for all commands. Or you can also use the original uuid as well should you want to supply the 36 character id. Please note that the shorty id is only usable on this tool. Although the formula for calculating can be implemented anywhere.
This shortens the command considerably.
example: `mmpos rigs set-profiles -r a3ea61dd -f cd371105 -p a44551e4`
vs
`./env/bin/mmpos rigs set-profiles --farm_id=ef86da23-0044-4530-b00d-124093cece80 --rig_id=85fbbe8d-6388-4b9e-8e2f-e897a7e7a6c5 --profile_ids=b49b6a13-e4ba-4991-a823-557f23754e80`
## Global switches
Some switches are only available at the global level. You will need to put the switch after `mmpos` to use them.
ie. `mmpos --json rigs list -f dksl39932`
```
Usage: mmpos [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--table Show table output
--json Show json output
--plain Show plain output
--short-ids / --no-short-ids Use short id instead of uuid from mmpos
[default: short-ids]
--help Show this message and exit.
Commands:
farms
profiles
rigs
```
## Examples
```
# mmpos rigs list
+--------------------------------------+--------------+---------------+-----------------------------------+---------------+
| id | name | address | profiles | agent_version |
+--------------------------------------+--------------+---------------+-----------------------------------+---------------+
| 365155f7-0425-4742-9465-7d8208464d51 | machine12345 | 192.168.0.1 | ['etc_eth_ethermine'] | v3.0.18 |
| 0fde950d-f321-4459-badd-9a7529dbe32b | machine22345 | 192.168.0.2 | ['etchash_amd_normal'] | v3.0.20 |
| 3fa0a53b-1bd9-4c09-91af-e134126c4219 | machine32345 | 192.168.0.3 | ['etc_eth_ethermine'] | v3.0.18 |
| 98d40b07-7090-42a8-8282-3e70e404d98c | machine42345 | 192.168.0.4 | ['etc_eth_ethermine'] | v3.0.19 |
| 5b00e155-ea64-414e-86af-2acc4e1ee716 | machine52345 | 192.168.0.5 | ['etchash_amd_normal'] | v3.0.19 |
+--------------------------------------+--------------+---------------+-----------------------------------+---------------+
# mmpos rigs gpus
+--------------+--------------------------+---------------+--------------------------------------+------------+
| rig_name | name | address | gpu_id | pci_id |
+--------------+--------------------------+---------------+--------------------------------------+------------+
| 0291ba94bb74 | Radeon RX 5700 XT | 192.168.0.1 | ef86da23-0044-4530-b00d-124093cece80 | 0000:0d:00 |
| 0291ba94bb74 | AMD Ryzen 7 3700X 8-Core | 192.168.0.1 | b49b6a13-e4ba-4991-a823-557f23754e80 | cpu0:08:10 |
| super12 | Radeon RX 6700 XT | 192.168.0.2 | afa7b6b5-78da-436c-a3d9-c60d9dcdba73 | 0000:04:00 |
| super12 | Radeon RX 6700 XT | 192.168.0.2 | 85fbbe8d-6388-4b9e-8e2f-e897a7e7a6c5 | 0000:07:00 |
+--------------+--------------------------+---------------+--------------------------------------+------------+
# mmpos rigs control --all --farm_id=first --action disable
+--------------+---------+
| rig_name | action |
+--------------+---------+
| machine1 | disable |
| machine2 | disable |
| machine3 | disable |
| machine4 | disable |
+--------------+---------+
# mmpos rigs set-profiles -r xxxxxx -f xxxxxx -p xxxxxx -p xxxxxxxy (multiple -p will set multiple profiles)
```
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/blockops/python-mmpos",
"name": "mmpos",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "mmpos mining gpus crypto blockchain platform rest",
"author": "Opselite",
"author_email": "opselite@blockops.party",
"download_url": "https://files.pythonhosted.org/packages/35/1f/50bcfa0262d8f2bea2a817a3789bcab2072f7518d206909959e00e89d592/mmpos-0.2.3.tar.gz",
"platform": "any",
"description": "# Python MMPOS API Library and CLI tool\nThe MMPOS crypto mining platform has a REST API that allows us to make changes without using the GUI.\nThis python module brings the power of that API to a native python library and command line tool.\n\n## Installation\nIf you don't use `pipx`, you're missing out.\nHere are [installation instructions](https://pypa.github.io/pipx).\n\nSimply run:\n\n`pipx install . (For installing locally in isolated environment with pipx)`\n\nOr\n\n`pip3 install mmpos`\n\n\n## Requirements\n* Python 3.8+\n\nIt may work with older python versions, especially 3.x versions, but I am only testing 3.8+. \n## Features\n* List rig data\n* List gpu data\n* List farm data\n* List mining profiles\n* Show data in either table or json formats\n* Control a rig (disable, enable, reset, poweroff, ...)\n* Control rig one at a time, everything all at once. (Disable everything!)\n* Simulate the control action if you are feeling worried. \n* Set mining profile \n* Use short ids to identify components of MMPOS\n* Output json, plain and table format, pipe into other commands\n\n## CLI Usage\nTo use it:\n\n $ mmpos --help\n\n\nEach command allows you to list the data in json or table format. The json output usually provides more output while the table is human readable and provides a subset of the total information.\n\nAll commands have `--json` and `--table`. Use the `--help` to verify these switches work for that command. \n\nExamples:\n\n```shell\n$ mmpos --help\nUsage: mmpos [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --help Show this message and exit.\n\nCommands:\n farms\n rigs\n\n$ mmpos farms --help \nUsage: mmpos farms [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --help Show this message and exit.\n\nCommands:\n list\n\n$ mmpos rigs --help\nUsage: mmpos rigs [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --help Show this message and exit.\n\nCommands:\n control\n gpus\n list\n\n$ mmpos rigs control --help\nUsage: mmpos rigs control [OPTIONS]\n\nOptions:\n --rig_id TEXT The rig id, not required when using --all or\n --everywhere flags\n --farm_id TEXT The farm id, defaults to first farm found,\n use '--all' flag for all farms [default:\n first]\n --all Run action on all rigs across the entire\n farm\n --everywhere Danger: Run action on all rigs across all\n farms\n --action [disable|poweroff|reset|enable|restart|reboot]\n [required]\n --simulate Simulate the action only\n --help Show this message and exit.\n```\n\n## Output Format\nYou can adjust the output format from the default table format to json output. Table output will normally be shorter and the json will provide much greater detail.\n## API Usage\nI have built this with the intention of using the api in other areas of automation like ansible playbooks and such. Usage should be pretty \nsimple. The API will change in the future as I build out the remaining MMPOS API calls. \n\n```\npip install mmpos\nimport mmpos.api.farms as farms\nimport mmpos.api.rigs as rigs\n\nfarms.get()\nrigs.get()\n\n```\n\n## Notes\nThis is alpha quality, expect things to change, feature requests welcome as is any code contributions. \n\n* Most data is cached for 5 minutes to speed up future calls. You will notice this when repeating calls. This can be controlled as the underlying mechanism is requests_cache library. \n\n\n### Using short ids\nThe MMPOS API uses long uuids as their identifiers. This makes it annoying to work with on the CLI due to 36 character length.\n\nAs a result I have created a translation layer that will encode the uuid into 8 characters. You can use this id for all commands. Or you can also use the original uuid as well should you want to supply the 36 character id. Please note that the shorty id is only usable on this tool. Although the formula for calculating can be implemented anywhere. \n\nThis shortens the command considerably. \n\nexample: `mmpos rigs set-profiles -r a3ea61dd -f cd371105 -p a44551e4`\n\nvs \n\n `./env/bin/mmpos rigs set-profiles --farm_id=ef86da23-0044-4530-b00d-124093cece80 --rig_id=85fbbe8d-6388-4b9e-8e2f-e897a7e7a6c5 --profile_ids=b49b6a13-e4ba-4991-a823-557f23754e80`\n\n## Global switches\nSome switches are only available at the global level. You will need to put the switch after `mmpos` to use them.\n\nie. `mmpos --json rigs list -f dksl39932`\n\n\n```\nUsage: mmpos [OPTIONS] COMMAND [ARGS]...\n\nOptions:\n --version Show the version and exit.\n --table Show table output\n --json Show json output\n --plain Show plain output\n --short-ids / --no-short-ids Use short id instead of uuid from mmpos\n [default: short-ids]\n --help Show this message and exit.\n\nCommands:\n farms\n profiles\n rigs\n``` \n## Examples\n\n```\n# mmpos rigs list \n+--------------------------------------+--------------+---------------+-----------------------------------+---------------+\n| id | name | address | profiles | agent_version |\n+--------------------------------------+--------------+---------------+-----------------------------------+---------------+\n| 365155f7-0425-4742-9465-7d8208464d51 | machine12345 | 192.168.0.1 | ['etc_eth_ethermine'] | v3.0.18 |\n| 0fde950d-f321-4459-badd-9a7529dbe32b | machine22345 | 192.168.0.2 | ['etchash_amd_normal'] | v3.0.20 |\n| 3fa0a53b-1bd9-4c09-91af-e134126c4219 | machine32345 | 192.168.0.3 | ['etc_eth_ethermine'] | v3.0.18 |\n| 98d40b07-7090-42a8-8282-3e70e404d98c | machine42345 | 192.168.0.4 | ['etc_eth_ethermine'] | v3.0.19 |\n| 5b00e155-ea64-414e-86af-2acc4e1ee716 | machine52345 | 192.168.0.5 | ['etchash_amd_normal'] | v3.0.19 |\n+--------------------------------------+--------------+---------------+-----------------------------------+---------------+\n\n# mmpos rigs gpus\n+--------------+--------------------------+---------------+--------------------------------------+------------+\n| rig_name | name | address | gpu_id | pci_id |\n+--------------+--------------------------+---------------+--------------------------------------+------------+\n| 0291ba94bb74 | Radeon RX 5700 XT | 192.168.0.1 | ef86da23-0044-4530-b00d-124093cece80 | 0000:0d:00 |\n| 0291ba94bb74 | AMD Ryzen 7 3700X 8-Core | 192.168.0.1 | b49b6a13-e4ba-4991-a823-557f23754e80 | cpu0:08:10 |\n| super12 | Radeon RX 6700 XT | 192.168.0.2 | afa7b6b5-78da-436c-a3d9-c60d9dcdba73 | 0000:04:00 |\n| super12 | Radeon RX 6700 XT | 192.168.0.2 | 85fbbe8d-6388-4b9e-8e2f-e897a7e7a6c5 | 0000:07:00 |\n+--------------+--------------------------+---------------+--------------------------------------+------------+\n\n\n\n# mmpos rigs control --all --farm_id=first --action disable\n+--------------+---------+\n| rig_name | action |\n+--------------+---------+\n| machine1 | disable |\n| machine2 | disable |\n| machine3 | disable |\n| machine4 | disable |\n+--------------+---------+\n\n# mmpos rigs set-profiles -r xxxxxx -f xxxxxx -p xxxxxx -p xxxxxxxy (multiple -p will set multiple profiles)\n```\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "CLI tool and API for the MMPOS REST API crypto mining platform",
"version": "0.2.3",
"split_keywords": [
"mmpos",
"mining",
"gpus",
"crypto",
"blockchain",
"platform",
"rest"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "36d9bf6537d536bef7f83549dceaf3bcf9c5c33a5a35c200e32134d147862ec2",
"md5": "81e572b9283c416b9975e57746f9f1f4",
"sha256": "8417831de1230e4deacf0dd49151e64534e2b05398948f870c9cf518902e2157"
},
"downloads": -1,
"filename": "mmpos-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "81e572b9283c416b9975e57746f9f1f4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 12446,
"upload_time": "2023-01-16T18:04:01",
"upload_time_iso_8601": "2023-01-16T18:04:01.438020Z",
"url": "https://files.pythonhosted.org/packages/36/d9/bf6537d536bef7f83549dceaf3bcf9c5c33a5a35c200e32134d147862ec2/mmpos-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "351f50bcfa0262d8f2bea2a817a3789bcab2072f7518d206909959e00e89d592",
"md5": "591e771e4b2f8b209db8082372ba8969",
"sha256": "dd680d633719d689ebf697a586443f5d2a94f9a849a4531b69123d87f2092cf7"
},
"downloads": -1,
"filename": "mmpos-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "591e771e4b2f8b209db8082372ba8969",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 13101,
"upload_time": "2023-01-16T18:04:02",
"upload_time_iso_8601": "2023-01-16T18:04:02.624324Z",
"url": "https://files.pythonhosted.org/packages/35/1f/50bcfa0262d8f2bea2a817a3789bcab2072f7518d206909959e00e89d592/mmpos-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-16 18:04:02",
"github": false,
"gitlab": true,
"bitbucket": false,
"gitlab_user": "blockops",
"gitlab_project": "python-mmpos",
"lcname": "mmpos"
}