Skip to main content

A package to schedule different tasks in parallel with cluster support.

Project description

Slurmer

This package is designed to run heavy loads in a computer cluster. Supported task schedulers are:

- Running on a single node
- [SLURM](https://slurm.schedmd.com/documentation.html)

PRs to add more schedulers are welcome.

Features

  • Run multiple tasks in parallel.
  • Run tasks in randomised order but consistently in multiple computing nodes.
  • Consistent pipeline to work with heavy tasks (directory creation, handling errors, postprocessing...)

Example

You can find the documentation here.

The package can be used as follows:

from dataclasses import dataclass
from pathlib import Path
from typing import Iterator

import slurmer


@dataclass
class MyTaskParameters(slurmer.TaskParameters):
    processing_id: int


@dataclass
class MyTaskResult(slurmer.TaskResult):
    good_result: bool


class MyTask(slurmer.Task):

    def __init__(self, min_job: int, max_job: int):
        super().__init__()
        self.min_job = min_job
        self.max_job = max_job

    def generate_parameters(self) -> Iterator[MyTaskParameters]:
        for i in range(self.min_job, self.max_job):
            yield MyTaskParameters(processing_id=i)

    def make_dirs(self):
        # Dirs are created before the task is run
        for i in range(self.min_job, self.max_job):
            Path(f"out/result_{i}").mkdir(parents=True, exist_ok=True)

    def process_function(self, parameters: MyTaskParameters) -> MyTaskResult:
        # Run your heavy code here
        for i in range(parameters.processing_id, parameters.processing_id + 10):
            print(f"Processing {i}")

        return MyTaskResult(good_result=True)

    def process_output(self, result: MyTaskResult) -> bool:
        # Postprocess output, this is NOT run in parallel and only handles the tasks run 
        # in the current node. If you want to postprocess everything wait for all the nodes
        # to finsish computing.
        #
        # This function should check whether the output is the "expected" one and return True 
        # if something went wrong.
        return not result.good_result

Then in your main script:

>>> task = MyTask(min_job=1, max_job=10)
>>> task.execute_tasks()

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

slurmer-1.0.4.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

slurmer-1.0.4-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file slurmer-1.0.4.tar.gz.

File metadata

  • Download URL: slurmer-1.0.4.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.7.12 Linux/5.11.0-1020-azure

File hashes

Hashes for slurmer-1.0.4.tar.gz
Algorithm Hash digest
SHA256 81b5a109845deabd5dac798748d180691bfe35c86342080d934135195c9f7f02
MD5 925e185f0a821ada2c9d70e5d1a3a959
BLAKE2b-256 140ddb9a14b428d8f6e37cd1a5a5bb13e6c656fa80cde4c13db169d009dfc3b8

See more details on using hashes here.

File details

Details for the file slurmer-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: slurmer-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.7.12 Linux/5.11.0-1020-azure

File hashes

Hashes for slurmer-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b8a58e23a11e4ca15e3c44ade144cdf68f4216d83b69ebab99977505408f62fd
MD5 fafcaa6545537608f632942b374664d3
BLAKE2b-256 04027bdeb41d8234d1f6abefcd02a887d6d86bebd55ad797e1f3adf5df8082b7

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