staged-script


Namestaged-script JSON
Version 2.0.1 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-12-17 17:42:13
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 reverse-argparse rich tenacity
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.9|3.10|3.11|3.12|3.13-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 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 & Copyright

See [LICENSE.md](LICENSE.md) and [COPYRIGHT.md](COPYRIGHT.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/9a/a1/65f0f3e8f3f40f781db7d60dfaa84ea541edbd8c1d4f583556681374571a/staged_script-2.0.1.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.9|3.10|3.11|3.12|3.13-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\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 & Copyright\n\nSee [LICENSE.md](LICENSE.md) and [COPYRIGHT.md](COPYRIGHT.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": "2.0.1",
    "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": "809edb4f18a3e7fe530860d5a7b95cd804b7cfa67d5f427ce76820a422daee16",
                "md5": "c128a4f3ea88ce659520176efb2f103f",
                "sha256": "7975f101a0ec21ce806c12f286654034831ad0a5e46d667874bad3c5ef9d30fc"
            },
            "downloads": -1,
            "filename": "staged_script-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c128a4f3ea88ce659520176efb2f103f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 14596,
            "upload_time": "2024-12-17T17:42:09",
            "upload_time_iso_8601": "2024-12-17T17:42:09.781726Z",
            "url": "https://files.pythonhosted.org/packages/80/9e/db4f18a3e7fe530860d5a7b95cd804b7cfa67d5f427ce76820a422daee16/staged_script-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9aa165f0f3e8f3f40f781db7d60dfaa84ea541edbd8c1d4f583556681374571a",
                "md5": "d9a03e9091ec9ce9452abd0121fd0291",
                "sha256": "62f52fa2337d9ec2c21c072fcca9cbe80fca8591adbec480bc5fc48b80c73a0a"
            },
            "downloads": -1,
            "filename": "staged_script-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d9a03e9091ec9ce9452abd0121fd0291",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16213,
            "upload_time": "2024-12-17T17:42:13",
            "upload_time_iso_8601": "2024-12-17T17:42:13.025645Z",
            "url": "https://files.pythonhosted.org/packages/9a/a1/65f0f3e8f3f40f781db7d60dfaa84ea541edbd8c1d4f583556681374571a/staged_script-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 17:42:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sandialabs",
    "github_project": "staged-script",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "reverse-argparse",
            "specs": []
        },
        {
            "name": "rich",
            "specs": []
        },
        {
            "name": "tenacity",
            "specs": []
        }
    ],
    "lcname": "staged-script"
}
        
Elapsed time: 0.65942s