Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Task distribution with Slurm and multi-processing for Python

License

Notifications You must be signed in to change notification settings

scalableminds/cluster_tools

Repository files navigation

Note: This package was moved to wk-libs.

Cluster Tools

CircleCI

This package provides python Executor classes for distributing tasks on a slurm cluster or via multi processing.

Example

import cluster_tools

def square(n):
  return n * n

if __name__ == '__main__':
  strategy = "slurm"  # other valid values are "multiprocessing" and "sequential"
  with cluster_tools.get_executor(strategy) as executor:
    result = list(executor.map(square, [2, 3, 4]))
    assert result == [4, 9, 16]

Dev Setup

cd dockered-slurm
docker build -t slurm-docker-cluster:latest .
docker-compose up -d
docker exec -it slurmctld bash
docker exec -it c1 bash

Tests can be executed with python3 -m pytest -s test.py after entering the container. Linting can be ran with python3 -m pylint cluster_tools/. Code formatting (black) can be ran with python3 -m black cluster_tools *.py.

Credits

Thanks to sampsyo/clusterfutures for providing the slurm core abstraction and giovtorres/slurm-docker-cluster for providing the slurm docker environment which we use for CI based testing.