Automatic management of numerous tasks is easier with Taskman

SONM
5 min readNov 19, 2018

--

The Sonm team continues to improve the usability of the platform. For customers of resources, a new Sonm component has been released for automating the management of deals and tasks! Sonm Task manager — Taskman, is a bot for customers whose primary goal is to automate deals and task managing, making both as simple as possible.

Until now, management of deals and tasks have only been available in manual mode. To launch tasks in Sonm (for this, Sonm CLI is used), the following steps are required :

  • create an order with a specification for the rental of each hardware instance;
  • track the appearance of each deal;
  • run the required task on each instance manually;
  • track task status and task logs;
  • close each deal upon completion of the task.

Taskman allows customers to prepare a single configuration for launching several tasks and renting the multiple instances of hardware for each of them. The bot performs all subsequent actions to rent resources on the Sonm marketplace and launch tasks on it automatically! The customers are provided with an interface to view the concluded deals and running tasks. Relax and watch how the bot will take deals, start your tasks and perform task tracking!

Bot features:

  • one configuration step for task and hardware needed, including preferred price and number of instances;
  • automatic rental ;
  • automatically launch the task on the multiple instances;
  • change task and hardware configs without stop;
  • work without interruption;
  • online monitoring of deals and tasks.

Taskman is written with Python 3.7., open-source and available for changes with no limitations.

Installation

To run tasks automatically, we recommend using a permanently powered stationary PC or a low-cost VPS with Debian-based Linux OS, preferably Ubuntu.

After launch, the automation module will work continuously:

  • open new deals,
  • run the tasks you have prepared,
  • track deals and tasks status.

Installation steps:

  1. Install Sonm (if you haven’t) (see how to install SONM for customer).
  2. Install Python 3.7 and pip 3.7.
  3. Clone GitHub repository or download the source code and unzip to preferred folder.
  4. Run pip3.7 install -r requirements.txt to install dependencies.

Description of tasks and hardware

After installing, it’s necessary to describe the tasks and hardware needed.

  1. Describe hardware requirements for every task in the task configuration file. All task configuration files must have different names. Location: ./conf/<any_name>.yaml. For example, ‘cs16_config.yaml’:
  • # cluster size numberofnodes: 1 #cluster name, bid’s and tasks will use it tag: “CS16” # final price = predicted price * (1 + price_coefficient/100) price_coefficient: 10 # $ per hour max_price: “0.002” # Estimated time of successful start of task (blacklist worker if task failed before ets) ets: 180 task_start_timeout: 600 # Template for task yaml template_file: “cs16_task.yaml” # duration (“0h” for spot deals; “4h” (for example) for forward deals) duration: 24h # optional, sets counterparty for orders to take, must be HEX(40) string. Will be removed automatically in case of error/not set counterparty: “” # Identity level of the counterparty. Can be “anonymous”, “registered”, “identified” and “professional”. identity: “anonymous” # MB, integers only ramsize: 512 # GB, integers only storagesize: 1 #number of cores, integers only cpucores: 1 sysbenchsingle: 500 sysbenchmulti: 1000 # Mbits, integers only netdownload: 10 # Mbits, integers only netupload: 10 #network settings # Indicates whether overlay networking is required, boolean only overlay: false # Indicates whether inbound connections are required and public IP should be present on worker, boolean only incoming: true #gpu config (optional). If not required, set gpucount: “0” #number of units gpucount: 0 # GPU unit RAM,MB, integers only gpumem: 0 # MH/s, integers only ethhashrate: 0
  1. Describe specification of each task you want to run in Sonm (specify the link to the Docker image with your task). Location: `./conf/.yaml`. For example, ‘cs16_task.yaml”:
  • container: image: cs16ds/server:latest ssh_key: “ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAA — censored — “ env: START_MAP: de_aztec SERVER_NAME: “CS 1.6 on SONM” SERVER_PASSWORD: sonmsonm ADMIN_STEAM: “STEAM_0: — censored — “ restart_policy: name: always expose: — 26900:26900/udp — 27020:27020/udp — 27015:27015/udp — 27015:27015
  1. Edit the main configuration file. Location: ./conf/config.yaml. Set Sonm node API endpoint and keystore settings, web-server settings and the list of task configs you want to run. For example:
  • # HTTP Server preferences # statistics page available on http://localhost:8081 when bot is running. http_server: run: true port: 8081 user: “sonm” password: “sonm” #SONM Node preferences # default endpoint for SONM Node REST API is ‘http://127.0.0.1:15031' node_address: ‘http://127.0.0.1:15031' # keystore location and password (default keystore location in Linux is “/etc/sonm/sonm-keystore/”) ethereum: key_path: “/etc/sonm/sonm-keystore/” password: “changeMe” #default timeout for all requests to Node API is 60 seconds, you may customize this (optional). #timeout: 60 #time since last heartbeat (in seconds) — drops the deal and restart particular node if its status stuck restart_timeout: 600 # LIST OF TASKS to run tasks: — claymore_config.yaml — cs16_config.yaml

Usage of the bot

You may use Taskman to manage multiple different tasks. You may change configs and you won’t need to interrupt the bot for adding/removing tasks, increasing or reducing the number of instances for each task. Configs are reloaded once per minute.

To run the bot execute:

  • ./taskman.py — to run in user session;
  • nohup ./taskman.py & — to run in background.

After launching, the bot will continuously create orders and wait for deals. When the deal appears, it will start the task and track it. If the task has failed to start, the module will automatically close the deal.

To see module stats go to http://localhost:8081. Example:

To see bot logs open ./out/logs/monitor.log file.

To edit the task list (remove or add tasks), reduce or increase the cluster of nodes for each task, change task configuration file. Bot reloads configs once per minute and implements changes.

Changes of hardware requirements (CPU, GPU, RAM, storage, network) will apply when a new order has to be created. If you change hardware requirements (CPU, GPU, RAM, storage, network) for active orders (when you don’t have the deal for the order yet), you may run command ‘sonmcli order purge’ This will cancel all active orders, and the bot will recreate orders with new hardware requirements.

To stop the bot:

  • If all tasks have finished successfully, the bot will stop automatically.
  • If you run the bot in the user session, you may press Crtl-C to stop it.
  • If you run the bot in the background: kill -15 $(ps ax | grep “taskman.py” | grep -v “grep” | awk ‘{print $1}’).

Attention! Stopping the bot does not affect active orders or deals. Please check active deals and orders after stopping the bot.

You may:

See Sonm CLI Guide for additional information.

Need help?

Read the full Taskman guide on our documentation portal.

If you any questions about our product, you can get support via:

We are online 24/7 for you!

Originally published at sonm.com on November 19, 2018.

--

--

SONM
SONM

Written by SONM

Global Fog Computing Platform

No responses yet