distrunner


Namedistrunner JSON
Version 1.4.1 PyPI version JSON
download
home_pagehttps://gitlab.com/crossref/labs/distrunner
SummaryThis library allows for the easy construction and management of Dask clusters.
upload_time2023-10-27 08:53:18
maintainer
docs_urlNone
authorMartin Paul Eve
requires_python>=3.8
licenseCopyright © 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.
keywords distributed computing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Distributed Runner
This library allows for the easy construction and management of ephemeral Dask clusters on AWS via a simple context manager. This allows you to perform distributed and parallelized computations with ease.

![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).

## Running in Managed Workflows for Apache Airflow (MWAA)
Running inside an AWS MWAA environment requires a _little_ more setup than running locally. This is because of the way that requirements are handled in Airflow. You also need to ensure that any called functions are nested underneath the task in question. The above examples, refactored for Airflow, could read:

    REQUIREMENTS = [
        "distrunner>=1.3.0",
        "whatismyip,
        "coiled",
        "dask[complete]",
    ]

    @dag(
        default_args=DEFAULT_ARGS,
        schedule_interval="@daily",
        catchup=False,
        dagrun_timeout=timedelta(hours=16),
        start_date=datetime(2023, 4, 16),
        tags=["api"],
    )
    def main_task():
        @task.virtualenv(
            task_id="main_task",
            requirements=REQUIREMENTS,
            system_site_packages=True,
        )
        def entry_point(requirements):
            
            def print_ip(x):
                return f"My IP address is {whatismyip.whatismyip()}"

            from distrunner.distrunner import DistRunner

            with DistRunner(
                workers=1,
                requirements=requirements,
                application_name="test_application",
            ) as cldr:
                results = cldr.client.map(snapshot_routes_body, range(1))
                cldr.client.gather(results)
    
        entry_point(REQUIREMENTS)

    main_task()


## 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 

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitlab.com/crossref/labs/distrunner",
    "name": "distrunner",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Martin Paul Eve <meve@crossref.org>",
    "keywords": "distributed computing",
    "author": "Martin Paul Eve",
    "author_email": "meve@crossref.org",
    "download_url": "https://files.pythonhosted.org/packages/a4/9e/6c2ee4fc2f2a346bef29bb9b84e22ebf0e6e6faa7143ff5097ba30fdd386/distrunner-1.4.1.tar.gz",
    "platform": null,
    "description": "# Distributed Runner\nThis library allows for the easy construction and management of ephemeral Dask clusters on AWS via a simple context manager. This allows you to perform distributed and parallelized computations with ease.\n\n![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>\n\n![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)\n\n## Installation\n\n    pip install distrunner\n\n## Usage\n\nIn your scheduler (Airfow etc.) use something like this:\n\n    from distrunner import DistRunner\n    import whatismyip\n\n    def main():\n        with DistRunner(workers=10) as cldr:\n            results = cldr.client.map(print_ip, range(10))\n            outcome = cldr.client.gather(results)\n    \n            print(outcome)\n\n    def print_ip(x):\n        return f\"My IP address is {whatismyip.whatismyip()}\"\n\nThe \"local\" flag will determine whether a remote cluster is created. For example, the following will all run locally instead of spinning up infrastructure:\n\n    from distrunner import DistRunner\n    import whatismyip\n\n    def main():\n        with DistRunner(workers=10, local=True) as cldr:\n            results = cldr.client.map(print_ip, range(10))\n            outcome = cldr.client.gather(results)\n    \n            print(outcome)\n\n    def print_ip(x):\n        return f\"My IP address is {whatismyip.whatismyip()}\"\n\nYou 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).\n\n## Running in Managed Workflows for Apache Airflow (MWAA)\nRunning inside an AWS MWAA environment requires a _little_ more setup than running locally. This is because of the way that requirements are handled in Airflow. You also need to ensure that any called functions are nested underneath the task in question. The above examples, refactored for Airflow, could read:\n\n    REQUIREMENTS = [\n        \"distrunner>=1.3.0\",\n        \"whatismyip,\n        \"coiled\",\n        \"dask[complete]\",\n    ]\n\n    @dag(\n        default_args=DEFAULT_ARGS,\n        schedule_interval=\"@daily\",\n        catchup=False,\n        dagrun_timeout=timedelta(hours=16),\n        start_date=datetime(2023, 4, 16),\n        tags=[\"api\"],\n    )\n    def main_task():\n        @task.virtualenv(\n            task_id=\"main_task\",\n            requirements=REQUIREMENTS,\n            system_site_packages=True,\n        )\n        def entry_point(requirements):\n            \n            def print_ip(x):\n                return f\"My IP address is {whatismyip.whatismyip()}\"\n\n            from distrunner.distrunner import DistRunner\n\n            with DistRunner(\n                workers=1,\n                requirements=requirements,\n                application_name=\"test_application\",\n            ) as cldr:\n                results = cldr.client.map(snapshot_routes_body, range(1))\n                cldr.client.gather(results)\n    \n        entry_point(REQUIREMENTS)\n\n    main_task()\n\n\n## Features\n* Context manager handling of Dask Fargate clusters with scale-to-zero on complete\n* Easy ability to switch between local and distributed/remote development\n\n## What it Does\nThis library allows you to easily run functions across a Dask cluster.\n\n## Credits\n\n* [AWS/Boto](https://github.com/boto/botocore)\n* [Coiled](https://coiled.io)\n* [Dask](https://www.dask.org/)\n* [Git](https://git-scm.com/)\n* [GitPython](https://github.com/gitpython-developers/GitPython)\n\nCopyright &copy; Crossref 2023 \n",
    "bugtrack_url": null,
    "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.",
    "summary": "This library allows for the easy construction and management of Dask clusters.",
    "version": "1.4.1",
    "project_urls": {
        "Homepage": "https://gitlab.com/crossref/labs/distrunner",
        "changelog": "https://gitlab.com/crossref/labs/distrunner/-/blob/main/CHANGELOG.md",
        "documentation": "https://labs.crossref.org",
        "homepage": "https://labs.crossref.org",
        "repository": "https://gitlab.com/crossref/labs/distrunner"
    },
    "split_keywords": [
        "distributed",
        "computing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "386774cdc3e78895a77ecfc2dfb168e198ae9cbf99dd67bd7279d3c55f8f330a",
                "md5": "a59a24c14c0a835d30c65c512978c3fc",
                "sha256": "144a6d6cd8a22e5fd0f491d7e7376af5e2b055e3da899dffd4951d8bb6dbc234"
            },
            "downloads": -1,
            "filename": "distrunner-1.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a59a24c14c0a835d30c65c512978c3fc",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7036,
            "upload_time": "2023-10-27T08:53:16",
            "upload_time_iso_8601": "2023-10-27T08:53:16.424057Z",
            "url": "https://files.pythonhosted.org/packages/38/67/74cdc3e78895a77ecfc2dfb168e198ae9cbf99dd67bd7279d3c55f8f330a/distrunner-1.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a49e6c2ee4fc2f2a346bef29bb9b84e22ebf0e6e6faa7143ff5097ba30fdd386",
                "md5": "bd753ae753b6a5a3735157440883638c",
                "sha256": "330b5566a6fb870f3c5f2d3722f0a48bba6a4aa9741d46bab5d72c5efbf529bc"
            },
            "downloads": -1,
            "filename": "distrunner-1.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "bd753ae753b6a5a3735157440883638c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7609,
            "upload_time": "2023-10-27T08:53:18",
            "upload_time_iso_8601": "2023-10-27T08:53:18.380938Z",
            "url": "https://files.pythonhosted.org/packages/a4/9e/6c2ee4fc2f2a346bef29bb9b84e22ebf0e6e6faa7143ff5097ba30fdd386/distrunner-1.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-27 08:53:18",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "crossref",
    "gitlab_project": "labs",
    "lcname": "distrunner"
}
        
Elapsed time: 0.13777s