Skip to main content

Allow you to create you own custom decentralize job management system.

Project description

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

Project details


Download files

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

Source Distribution

pyants-0.2.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyants-0.2.0-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file pyants-0.2.0.tar.gz.

File metadata

  • Download URL: pyants-0.2.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pyants-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d0664f201f9585622868da15b51295535e8b298e36ddb96fe854148cef0dea02
MD5 5e10b8dd21a5e3ee6ba0c6de65c6d7e5
BLAKE2b-256 89d388c48872b5b75c6d5efd2ba117c779268c32926f2a978e7a3ca8bd6eb15e

See more details on using hashes here.

File details

Details for the file pyants-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyants-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for pyants-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 adb9556acd9524a69220c9ed3dbbcb49a72f9f8fdd0bc620e0d1e9c205a5f27f
MD5 3d79fe82ab7dbe1855dc2fdd585819b0
BLAKE2b-256 f1eb1b2b2dd6f40335632757325abe5bac7f8e799a60e2df318bdbefef8abbbe

See more details on using hashes here.

Supported by

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