ants
Allow you to create you own custom decentralize job management system.
install
pip install pyants
How it works?
The library provides you with interface to add assign and do jobs in an decentralized environment. For example to create your own node just override some methods:
node
from typing import List
from ants import BaseNode, Job
class MyNode(BaseNode):
def add_jobs(self) -> List[Job]:
return [] # List of jobs to run (the nodes can create duplicate jobs and the lib will manage that)
def assign_to_jobs(self, pending_jobs: List[Job]) -> List[Job]:
# You can choose which jobs to assign your self to
return [] # List of jobs to assign your self to
def do_jobs(self, my_assigned_jobs: List[Job]):
# this list do not have to match the list you returned from the assign_to_jobs method,
# the library will manage the job distribution to the nodes.
# loop over your assigned jobs and complete them
for assigned_job in my_assigned_jobs:
# do your job
# after you complete a job, report it with job.set_result({'status': 'OK'})
pass
def completed_jobs(self, done_jobs: List[Job]):
# Here you can be updated about the jobs that has done by all the nodes
# you can store it and use it in your business logic
# For example do not create a operational check for some server if it bin checked recently
pass
communication
The communication class expose tow methods:
- pull
- broadcast
The 'pull' method should return list of state objects from other nodes
The 'broadcast' method should transfer your state to other nodes
The library implemented for you a simple p2p socket server communication for decentralized networking
from ants.communications.socketserver import SocketCommunication
communication = SocketCommunication(host=..., port=..., pull_interval=..., bootstrap_nodes=...)
Example
Decentralized monitor example.
$> git clone https://github.com/hvuhsg/ants.git
$> cd ants/examples/monitor
$> python3 -m venv venv
$> . venv/bin/activate
$> pip install -r requirements.txt
$> pip install ../../.
$> python run.py
Release files for pyants 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyants-0.3.0.tar.gz | 20.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyants-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.2 kB
Release files / pyants-0.3.0.tar.gz
| Download URL | pyants-0.3.0.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cdaf12e302b73536071242754f401158774f87c530b7cbe690692771219082d6
|
|
BLAKE2b-256 checksum How to use checksums |
341bd9921ce47f99a190e94a5febb6cfbc97529d05ec269b50e684a328c5652b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|
Release files / pyants-0.3.0-py3-none-any.whl
| Download URL | pyants-0.3.0-py3-none-any.whl |
|---|---|
| Size | 21.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e84de48fe6f6ad018cf1ca45352903d79d8ebf43776d0bcdb456317f96771bfd
|
|
BLAKE2b-256 checksum How to use checksums |
c33662347a2a9460a016e231606ad2b3de6bfb16c8e83814cb1c655d8ef9e103
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
|