Skip to content

sandialabs/staged-script

Repository files navigation

WARNING: This package is still in the process of being open sourced. Until that work is done and this banner is removed, don't expect anything documented here to be accurate.

Lines of code codecov CodeFactor CodeQL Conda Version Conda Downloads Continuous Integration Contributor Covenant GitHub contributors Documentation Status License Merged PRs OpenSSF Best Practices OpenSSF Scorecard Platforms pre-commit pre-commit.ci Status PyPI - Version PyPI - Downloads Python Version 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:

python3 -m pip install staged-script

Usage

Once installed, you can simply

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.

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. If a quick search doesn't yield what you're looking for, feel free to file an issue.

Contributing

If you're interested in contributing to the development of staged-script, we'd love to have your help 😀 Check out our contributing guidelines for how to get started. Past contributors include:

License

See LICENSE.md.

Credits

Special thanks to the GMS project for investing in the development of this package.

About

A Python package enabling the development of robust automation scripts that are subdivided into stages.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages