Metadata-Version: 2.1
Name: distrunner
Version: 1.3.0
Summary: This library allows for the easy construction and management of Dask clusters.
Home-page: https://gitlab.com/crossref/labs/distrunner
Author: Martin Paul Eve
Author-email: meve@crossref.org
Maintainer-email: Martin Paul Eve <meve@crossref.org>
License: Copyright &copy; 2023 Crossref
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Project-URL: homepage, https://labs.crossref.org
Project-URL: documentation, https://labs.crossref.org
Project-URL: repository, https://gitlab.com/crossref/labs/distrunner
Project-URL: changelog, https://gitlab.com/crossref/labs/distrunner/-/blob/main/CHANGELOG.md
Keywords: distributed computing
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: dask-cloudprovider[aws] (==2022.10.0)
Requires-Dist: pandas
Requires-Dist: numpy
Requires-Dist: cryptography
Requires-Dist: botocore (~=1.27.59)
Requires-Dist: distributed (~=2023.3.0)
Requires-Dist: dask (~=2023.3.0)
Requires-Dist: GitPython
Requires-Dist: requests

# Distributed Runner
This library allows for the easy construction and management of Dask clusters via a simple context manager.

![license](https://img.shields.io/gitlab/license/crossref/labs/distrunner) ![activity](https://img.shields.io/gitlab/last-commit/crossref/labs/distrunner) <a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>

![Dask](https://img.shields.io/badge/dask-%23092E20.svg?style=for-the-badge&logo=dask&logoColor=white) ![Git](https://img.shields.io/badge/git-%23F05033.svg?style=for-the-badge&logo=git&logoColor=white) ![GitLab](https://img.shields.io/badge/gitlab-%23121011.svg?style=for-the-badge&logo=gitlab&logoColor=white) ![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge&logo=linux&logoColor=black) ![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)

## Installation

    pip install distrunner

## Usage

In your scheduler (Airfow etc.) use something like this:

    from distrunner import DistRunner
    import whatismyip

    def main():
        with DistRunner(workers=10) as cldr:
            results = cldr.client.map(print_ip, range(10))
            outcome = cldr.client.gather(results)
    
            print(outcome)

    def print_ip(x):
        return f"My IP address is {whatismyip.whatismyip()}"

The "local" flag will determine whether a remote cluster is created. For example, the following will all run locally instead of spinning up infrastructure:

    from distrunner import DistRunner
    import whatismyip

    def main():
        with DistRunner(workers=10, local=True) as cldr:
            results = cldr.client.map(print_ip, range(10))
            outcome = cldr.client.gather(results)
    
            print(outcome)

    def print_ip(x):
        return f"My IP address is {whatismyip.whatismyip()}"

You will need to set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables to use the Fargate clusters (or run from an environment with an authorised IAM role).

## Features
* Context manager handling of Dask Fargate clusters with scale-to-zero on complete
* Easy ability to switch between local and distributed/remote development

## What it Does
This library allows you to easily run functions across a Dask cluster.

## Credits

* [AWS/Boto](https://github.com/boto/botocore)
* [Coiled](https://coiled.io)
* [Dask](https://www.dask.org/)
* [Git](https://git-scm.com/)
* [GitPython](https://github.com/gitpython-developers/GitPython)

Copyright &copy; Crossref 2023 
