staged-script


Namestaged-script JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/sandialabs/staged-script
SummaryA Python package enabling the development of robust automation scripts that are subdivided into stages.
upload_time2024-07-02 15:28:17
maintainerNone
docs_urlNone
authorJason M. Gates
requires_python>=3.8
licenseLICENSE.md
keywords automation command execution repeatability replicability reproducibility pipeline retry scripting shell stages
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            ![Lines of code](https://sloc.xyz/github/sandialabs/staged-script/?category=code)
[![codecov](https://codecov.io/gh/sandialabs/staged-script/branch/master/graph/badge.svg?token=FmDStZ6FVR)](https://codecov.io/gh/sandialabs/staged-script)
[![CodeFactor](https://www.codefactor.io/repository/github/sandialabs/staged-script/badge/master)](https://www.codefactor.io/repository/github/sandialabs/staged-script/overview/master)
[![CodeQL](https://github.com/sandialabs/staged-script/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/sandialabs/staged-script/actions/workflows/github-code-scanning/codeql)
[![Conda Version](https://img.shields.io/conda/v/conda-forge/staged-script?label=conda-forge)](https://anaconda.org/conda-forge/staged-script)
![Conda Downloads](https://img.shields.io/conda/d/conda-forge/staged-script?label=conda-forge%20downloads)
[![Continuous Integration](https://github.com/sandialabs/staged-script/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/sandialabs/staged-script/actions/workflows/continuous-integration.yml)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
[![GitHub contributors](https://img.shields.io/github/contributors/sandialabs/staged-script.svg)](https://github.com/sandialabs/staged-script/graphs/contributors)
[![Documentation Status](https://readthedocs.org/projects/staged-script/badge/?version=latest)](https://staged-script.readthedocs.io/en/latest/?badge=latest)
[![License](https://anaconda.org/conda-forge/staged-script/badges/license.svg)](LICENSE.md)
[![Merged PRs](https://img.shields.io/github/issues-pr-closed-raw/sandialabs/staged-script.svg?label=merged+PRs)](https://github.com/sandialabs/staged-script/pulls?q=is:pr+is:merged)
[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/8864/badge)](https://bestpractices.coreinfrastructure.org/projects/8864)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/sandialabs/staged-script/badge)](https://securityscorecards.dev/viewer/?uri=github.com/sandialabs/staged-script)
![Platforms](https://anaconda.org/conda-forge/staged-script/badges/platforms.svg)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![pre-commit.ci Status](https://results.pre-commit.ci/badge/github/sandialabs/staged-script/master.svg)](https://results.pre-commit.ci/latest/github/sandialabs/staged-script/master)
[![PyPI - Version](https://img.shields.io/pypi/v/staged-script?label=PyPI)](https://pypi.org/project/staged-script/)
![PyPI - Downloads](https://img.shields.io/pypi/dm/staged-script?label=PyPI%20downloads)
![Python Version](https://img.shields.io/badge/Python-3.8|3.9|3.10|3.11|3.12-blue.svg)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

# staged-script

Python is an ideal language for certain types of infrastructure automation.
Automating what a user does manually often involves walking through a series of
stages.  A user may wish to run all the stages in series, or perhaps only a
subset, and depending on how things go, certain stages may need to be retried.
Once the script finishes running, it'd be ideal if it could tell the user
exactly what was run, for the sake of easing replicability.  `staged-script`
aims to ease the development such automation scripts.  It's easy to get started
with, but also provides significant power-user functionality for those who need
it.

## Installation

To get up and running with `staged-script`, simply:
```bash
python3 -m pip install staged-script
```

## Usage

Once installed, you can simply
```python
import sys
from typing import List

from staged_script import StagedScript


class MyScript(StagedScript):

    @StagedScript.stage("hello", "Greeting the user")
    def say_hello(self) -> None:
        self.run("echo 'Hello World'", shell=True)

    @StagedScript.stage("goodbye", "Bidding farewell")
    def say_goodbye(self) -> None:
        self.run("echo 'Goodbye World'", shell=True)

    def main(self, argv: List[str]) -> None:
        self.parse_args(argv)
        try:
            self.say_hello()
            self.say_goodbye()
        finally:
            self.print_script_execution_summary()


if __name__ == "__main__":
    my_script = MyScript({"hello", "goodbye"})
    my_script.main(sys.argv[1:])
```

For more detailed usage and API information, please see
[our documentation][docs].

[docs]: https://staged-script.readthedocs.io

## Where to Get Help

If you're having trouble with `staged-script`, or just want to ask a question,
head on over to [our issue board][issues].  If a quick search doesn't yield
what you're looking for, feel free to file an issue.

[issues]: https://github.com/sandialabs/staged-script/issues

## Contributing

If you're interested in contributing to the development of `staged-script`,
we'd love to have your help :grinning:  Check out our
[contributing guidelines](CONTRIBUTING.md) for how to get started.
[Past contributors][contributors] include:
* [@jmgate](https://github.com/jmgate)

[contributors]: https://github.com/sandialabs/staged-script/graphs/contributors

## License

See [LICENSE.md](LICENSE.md).

## Credits

Special thanks to [the GMS project][gms] for investing in the development of
this package.  Aspects of this functionality were inspired by the
[SPiFI][spifi] Jenkins Pipeline plugin and the [ShellLogger][shelllogger]
Python package.

[gms]: https://github.com/SNL-GMS/GMS-PI25
[spifi]: https://github.com/sandialabs/SPiFI
[shelllogger]: https://github.com/sandialabs/shell-logger


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sandialabs/staged-script",
    "name": "staged-script",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "automation, command, execution, repeatability, replicability, reproducibility, pipeline, retry, scripting, shell, stages",
    "author": "Jason M. Gates",
    "author_email": "jmgate@sandia.gov",
    "download_url": "https://files.pythonhosted.org/packages/2d/3a/6dfb408a379b0c66b830520cb48fa3bceae2d483fa3cf7a145a034976676/staged_script-1.0.2.tar.gz",
    "platform": null,
    "description": "![Lines of code](https://sloc.xyz/github/sandialabs/staged-script/?category=code)\n[![codecov](https://codecov.io/gh/sandialabs/staged-script/branch/master/graph/badge.svg?token=FmDStZ6FVR)](https://codecov.io/gh/sandialabs/staged-script)\n[![CodeFactor](https://www.codefactor.io/repository/github/sandialabs/staged-script/badge/master)](https://www.codefactor.io/repository/github/sandialabs/staged-script/overview/master)\n[![CodeQL](https://github.com/sandialabs/staged-script/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/sandialabs/staged-script/actions/workflows/github-code-scanning/codeql)\n[![Conda Version](https://img.shields.io/conda/v/conda-forge/staged-script?label=conda-forge)](https://anaconda.org/conda-forge/staged-script)\n![Conda Downloads](https://img.shields.io/conda/d/conda-forge/staged-script?label=conda-forge%20downloads)\n[![Continuous Integration](https://github.com/sandialabs/staged-script/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/sandialabs/staged-script/actions/workflows/continuous-integration.yml)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)\n[![GitHub contributors](https://img.shields.io/github/contributors/sandialabs/staged-script.svg)](https://github.com/sandialabs/staged-script/graphs/contributors)\n[![Documentation Status](https://readthedocs.org/projects/staged-script/badge/?version=latest)](https://staged-script.readthedocs.io/en/latest/?badge=latest)\n[![License](https://anaconda.org/conda-forge/staged-script/badges/license.svg)](LICENSE.md)\n[![Merged PRs](https://img.shields.io/github/issues-pr-closed-raw/sandialabs/staged-script.svg?label=merged+PRs)](https://github.com/sandialabs/staged-script/pulls?q=is:pr+is:merged)\n[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/8864/badge)](https://bestpractices.coreinfrastructure.org/projects/8864)\n[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/sandialabs/staged-script/badge)](https://securityscorecards.dev/viewer/?uri=github.com/sandialabs/staged-script)\n![Platforms](https://anaconda.org/conda-forge/staged-script/badges/platforms.svg)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)\n[![pre-commit.ci Status](https://results.pre-commit.ci/badge/github/sandialabs/staged-script/master.svg)](https://results.pre-commit.ci/latest/github/sandialabs/staged-script/master)\n[![PyPI - Version](https://img.shields.io/pypi/v/staged-script?label=PyPI)](https://pypi.org/project/staged-script/)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/staged-script?label=PyPI%20downloads)\n![Python Version](https://img.shields.io/badge/Python-3.8|3.9|3.10|3.11|3.12-blue.svg)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n# staged-script\n\nPython is an ideal language for certain types of infrastructure automation.\nAutomating what a user does manually often involves walking through a series of\nstages.  A user may wish to run all the stages in series, or perhaps only a\nsubset, and depending on how things go, certain stages may need to be retried.\nOnce the script finishes running, it'd be ideal if it could tell the user\nexactly what was run, for the sake of easing replicability.  `staged-script`\naims to ease the development such automation scripts.  It's easy to get started\nwith, but also provides significant power-user functionality for those who need\nit.\n\n## Installation\n\nTo get up and running with `staged-script`, simply:\n```bash\npython3 -m pip install staged-script\n```\n\n## Usage\n\nOnce installed, you can simply\n```python\nimport sys\nfrom typing import List\n\nfrom staged_script import StagedScript\n\n\nclass MyScript(StagedScript):\n\n    @StagedScript.stage(\"hello\", \"Greeting the user\")\n    def say_hello(self) -> None:\n        self.run(\"echo 'Hello World'\", shell=True)\n\n    @StagedScript.stage(\"goodbye\", \"Bidding farewell\")\n    def say_goodbye(self) -> None:\n        self.run(\"echo 'Goodbye World'\", shell=True)\n\n    def main(self, argv: List[str]) -> None:\n        self.parse_args(argv)\n        try:\n            self.say_hello()\n            self.say_goodbye()\n        finally:\n            self.print_script_execution_summary()\n\n\nif __name__ == \"__main__\":\n    my_script = MyScript({\"hello\", \"goodbye\"})\n    my_script.main(sys.argv[1:])\n```\n\nFor more detailed usage and API information, please see\n[our documentation][docs].\n\n[docs]: https://staged-script.readthedocs.io\n\n## Where to Get Help\n\nIf you're having trouble with `staged-script`, or just want to ask a question,\nhead on over to [our issue board][issues].  If a quick search doesn't yield\nwhat you're looking for, feel free to file an issue.\n\n[issues]: https://github.com/sandialabs/staged-script/issues\n\n## Contributing\n\nIf you're interested in contributing to the development of `staged-script`,\nwe'd love to have your help :grinning:  Check out our\n[contributing guidelines](CONTRIBUTING.md) for how to get started.\n[Past contributors][contributors] include:\n* [@jmgate](https://github.com/jmgate)\n\n[contributors]: https://github.com/sandialabs/staged-script/graphs/contributors\n\n## License\n\nSee [LICENSE.md](LICENSE.md).\n\n## Credits\n\nSpecial thanks to [the GMS project][gms] for investing in the development of\nthis package.  Aspects of this functionality were inspired by the\n[SPiFI][spifi] Jenkins Pipeline plugin and the [ShellLogger][shelllogger]\nPython package.\n\n[gms]: https://github.com/SNL-GMS/GMS-PI25\n[spifi]: https://github.com/sandialabs/SPiFI\n[shelllogger]: https://github.com/sandialabs/shell-logger\n\n",
    "bugtrack_url": null,
    "license": "LICENSE.md",
    "summary": "A Python package enabling the development of robust automation scripts that are subdivided into stages.",
    "version": "1.0.2",
    "project_urls": {
        "CI": "https://github.com/sandialabs/staged-script/actions",
        "Documentation": "https://staged-script.readthedocs.io",
        "Homepage": "https://github.com/sandialabs/staged-script",
        "Issues": "https://github.com/sandialabs/staged-script/issues",
        "Repository": "https://github.com/sandialabs/staged-script"
    },
    "split_keywords": [
        "automation",
        " command",
        " execution",
        " repeatability",
        " replicability",
        " reproducibility",
        " pipeline",
        " retry",
        " scripting",
        " shell",
        " stages"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8b40c033b2c41dc17e377249d00923df2b89927c493ac55e994825af1d5379fe",
                "md5": "be6b1e3f4149fe9a9c68ecb38a8eb595",
                "sha256": "b2530b217da288ce4bbb46930e53361bf2cb7e4ddeb3ba7e90f7116fb3e41f5a"
            },
            "downloads": -1,
            "filename": "staged_script-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "be6b1e3f4149fe9a9c68ecb38a8eb595",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 14710,
            "upload_time": "2024-07-02T15:28:16",
            "upload_time_iso_8601": "2024-07-02T15:28:16.189450Z",
            "url": "https://files.pythonhosted.org/packages/8b/40/c033b2c41dc17e377249d00923df2b89927c493ac55e994825af1d5379fe/staged_script-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2d3a6dfb408a379b0c66b830520cb48fa3bceae2d483fa3cf7a145a034976676",
                "md5": "a675b362dd36d74019ea9a8fdd4d9f9e",
                "sha256": "15c10d8191ce68af712ebec91ea388a8032e3753b8f189891b640c27868d05f7"
            },
            "downloads": -1,
            "filename": "staged_script-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a675b362dd36d74019ea9a8fdd4d9f9e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16229,
            "upload_time": "2024-07-02T15:28:17",
            "upload_time_iso_8601": "2024-07-02T15:28:17.598228Z",
            "url": "https://files.pythonhosted.org/packages/2d/3a/6dfb408a379b0c66b830520cb48fa3bceae2d483fa3cf7a145a034976676/staged_script-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-02 15:28:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sandialabs",
    "github_project": "staged-script",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "staged-script"
}
        
Elapsed time: 0.46343s