runbooks 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.1
2
+ Name: runbooks
3
+ Version: 0.1.1
4
+ Summary: CloudOps Automation for DevOps and SRE teams.
5
+ Author-email: runbooks maintainers <nnthanh101@gmail.com>
6
+ Classifier: Development Status :: 4 - Beta
7
+ Classifier: Environment :: Console
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Topic :: Documentation
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: Topic :: Utilities
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests>=2.32.3
19
+ Requires-Dist: loguru>=0.7.3
20
+ Requires-Dist: typer>=0.15.1
21
+ Requires-Dist: tqdm>=4.67.1
22
+ Requires-Dist: boto3>=1.35.90
23
+ Requires-Dist: moto>=5.0.25
24
+
25
+ # ๐Ÿ”ฅ CloudOps Automation at Scale ๐Ÿฆ…
26
+
27
+ ๐ŸŒŸ You can use [CloudOps Automation Runbooks](https://cloudops.oceansoft.io), built on Jupyter Notebooks, to quickly create SRE RunBooks for Runbook Automation and Cloud Infrastructure Management! ๐ŸŒ
28
+
29
+ > [!IMPORTANT]
30
+ > **๐Ÿ† Mission**: Our mission is to simplify CloudOps Automation for DevOps and SRE teams by providing an extensive, community-driven repository of actions and runbooks that streamline day-to-day operations.
31
+
32
+ > [!NOTE]
33
+ > **๐Ÿ‘๏ธ Vision**: Our vision is to be the ๐Ÿฅ‡ One-Stop Multi-Cloud Platform Engineering & Best Practices Solution for all CloudOps Automation needs, allowing DevOps and SRE teams to automate their workflows with ease, improve efficiency, and minimize toil.
34
+
35
+ [![๐Ÿ CloudOps PyPI version](https://img.shields.io/pypi/v/cloudops)](https://pypi.org/project/cloudops/)
36
+
37
+ <div align="left">
38
+ <a href="https://www.linkedin.com/in/nnthanh" target="blank"><img align="center" src="https://img.shields.io/badge/-nnthanh-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/nnthanh/" alt="Nhat-Thanh Nguyen" height="25" width="100" /></a>
39
+ <a href="https://github.com/nnthanh101/" target="blank"><img align="center" src="https://img.shields.io/github/followers/nnthanh101?label=Follow&style=social&link=https://github.com/nnthanh101/" alt="Thanh Nguyen" height="25" width="100" /></a>
40
+ <a href="https://www.facebook.com/groups/platformengineering" target="blank"><img align="center" src="https://img.shields.io/badge/Facebook-blue?style=flat-square&logo=facebook&logoColor=white&link=[https://www.linkedin.com/in/nnthanh/](https://www.facebook.com/groups/platformengineering)" alt="Nhat-Thanh Nguyen" height="25" width="100" /></a>
41
+ </div>
42
+
43
+ ---
44
+
45
+ ## ๐Ÿ› ๏ธ Features
46
+
47
+ * ๐Ÿฅ‰ โœ…**Lightning-Fast Toolchain**: Powered by ๐Ÿ“ฆ `uv` - Next-generation Python dependency and build management, ๐Ÿ’… `ruff` - Linting and formatting at blazing speed, and ๐Ÿงช pytest - Robust testing framework with coverage reports.
48
+ * ๐Ÿฅˆ โœ…**Effortless CI/CD Pipelines**: ๐Ÿ› ๏ธ Taskfile Automation - Say goodbye to manual SDLC repetitive tasks, ๐Ÿณ Containerized Workflows โ€“ ๐Ÿ›ก๏ธ Security-first practices and Multi-stage Wolfi-based Docker builds for scalable production-ready environments, and โš™๏ธ Auto-publish to `PyPI` and GitHub Container Registry (`GHCR`) with GitHub Actions.
49
+ * ๐Ÿฅ‡ โ˜‘๏ธ**CloudOps Automation and FinOps Toolkit** โ€“ Pre-configured hybrid-cloud workflows and seamlessly integrations (jupyterlab, mkdocs, boto3, moto) for managing cloud infrastructure ๐ŸŒ.
50
+
51
+ | **Feature** | **Toolchain** | **Purpose** |
52
+ |--------------------------|-------------------------------------|----------------------------------------------------|
53
+ | ๐Ÿ› ๏ธ Configuration | `pyproject.toml` | Centralized configuration for dependencies, testing, and linting. |
54
+ | ๐Ÿงน Task Automation | [`Taskfile`](https://taskfile.dev/) | Automates repetitive tasks like linting, testing, and publishing. |
55
+ | ๐Ÿ“ฆ Python Dependencies | [`uv`](https://docs.astral.sh/uv/) | Lightning-fast dependency resolution, caching, and builds. |
56
+ | ๐Ÿ’… Linting & Formatting | [`ruff`](https://docs.astral.sh/ruff/) | Enforces code quality standards, auto-formatting, and import sorting. |
57
+ | ๐Ÿงช Testing Framework | [`pytest`](https://docs.pytest.org/) | Comprehensive unit tests, integration tests with coverage reporting. |
58
+ | ๐Ÿณ Docker Integration | Dockerfile + [`DevContainer`](https://containers.dev/) | Optimized wolfi-based multi-stage builds for CI/CD and local development environments. |
59
+ | ๐Ÿฆพ CI/CD Pipelines | [`GitHub Actions`](https://github.com/features/actions) | Automated builds, tests, and deployments to PyPI and GHCR. |
60
+ | ๐Ÿ“ Security Compliance | [`chainguard/wolfi-base`](https://hub.docker.com/r/chainguard/wolfi-base) + SBOM + Attestations | Ensures compliance, vulnerability scanning, and security transparency. |
61
+
62
+ ---
63
+
64
+ ### WIP
65
+
66
+ - [ ] ๐Ÿ“š auto doc generation
67
+ - [ ] **CLI Tools** โ€“ Typer simplifies automation for AWS resources.
68
+ - [ ] **Logging** โ€“ Loguru ensures structured logs for debugging.
69
+ - [x] ๐Ÿณ CI/CD Optimized Docker Image runs when a new *release* is created pushing to gh registry
70
+ - [x] ๐Ÿฆพ GitHub actions:
71
+ - [x] auto publish to [`pypi`](https://pypi.org/) on push on `main`
72
+ - [ ] auto creating a new tag on push on `main`, sync versions
73
+ - [x] run `tests` and `lint` on `dev` and `main` when a PR is open
74
+
75
+ ## ๐Ÿš€ Quick Start
76
+
77
+ ### 1. Clone the Repository
78
+
79
+ ```bash
80
+ git clone https://github.com/nnthanh101/CloudOps.git
81
+ cd CloudOps
82
+ ```
83
+
84
+ ### 2. Install Dependencies and Run CI/CD Pipelines
85
+
86
+ ```bash
87
+ echo "Install Python dependencies using UV"
88
+ task install
89
+
90
+ echo "Run CI/CD pipeline tasks: clean, lint, format, test, and build"
91
+ task ci
92
+
93
+ echo "Publish the project package to PyPI"
94
+ task publish
95
+ ```
96
+
97
+ ### 3. Run in DevContainer ๐Ÿณ
98
+
99
+ 1. Open the project in **VSCode**.
100
+ 2. Install the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension.
101
+ 3. **Reopen in Container**:
102
+ **Command Palette `Ctrl+Shift+P` โ†’ Reopen in Container**.
103
+
104
+ ---
105
+
106
+ ## Project Structure
107
+
108
+ > ๐Ÿ›  End-to-end Production-grade project structure for successful ๐Ÿ’Ž CloudOps Automation and Visual Analytics FinOps projects ๐Ÿš€
109
+
110
+ ```
111
+ cloudops-automation/
112
+ โ”œโ”€โ”€ .devcontainer/ ## Dev Container configurations
113
+ โ”‚ โ””โ”€โ”€ Dockerfile ## Container image build file
114
+ โ”œโ”€โ”€ .github/ ## CI/CD workflows
115
+ โ”‚ โ”œโ”€โ”€ workflows/ ## GitHub Actions workflows
116
+ โ”‚ โ””โ”€โ”€ templates/ ## Workflow templates
117
+ โ”œโ”€โ”€ .vscode/ ## IDE-specific configurations
118
+ โ”œโ”€โ”€ config/ ## Configuration files (YAML, JSON)
119
+ โ”œโ”€โ”€ data ๐Ÿ” Where all your raw and processed data files are stored.
120
+ โ”‚ โ”œโ”€โ”€ external <- Data from third-party sources.
121
+ โ”‚ โ”œโ”€โ”€ interim <- Intermediate data that has been transformed.
122
+ โ”‚ โ”œโ”€โ”€ processed <- The final, canonical data sets for modeling.
123
+ โ”‚ โ””โ”€โ”€ raw <- The original, unprocessed, immutable data dump.
124
+ โ”‚
125
+ โ”œโ”€โ”€ docs ๐Ÿ““ A default mkdocs project; see mkdocs.org for details
126
+ โ”‚ โ”œโ”€โ”€ api/ ## API documentation
127
+ โ”‚ โ”œโ”€โ”€ architecture/ ## Architecture diagrams
128
+ โ”‚ โ”œโ”€โ”€ tutorials/ ## Tutorials and guides
129
+ โ”‚ โ”œโ”€โ”€ getting-started.md ## Quickstart guide
130
+ โ”‚ โ””โ”€โ”€ index.md ## Overview documentation
131
+ โ”‚
132
+ โ”œโ”€โ”€ logs/ ## Log files for debugging
133
+ |
134
+ โ”œโ”€โ”€ models ๐Ÿง  Store your trained and serialized models for easy access and versioning.
135
+ โ”‚
136
+ โ”œโ”€โ”€ notebooks ๐Ÿ’ป Jupyter notebooks for experiments and visualization.
137
+ โ”‚ โ”œโ”€โ”€ data_exploration.ipynb
138
+ โ”‚ โ”œโ”€โ”€ data_preprocessing.ipynb
139
+ โ”‚ โ”œโ”€โ”€ model_training.ipynb
140
+ โ”‚ โ””โ”€โ”€ model_evaluation.ipynb
141
+ โ”‚
142
+ โ”œโ”€โ”€ pyproject.toml <- Project configuration file with package metadata for
143
+ โ”‚ cloudops and configuration for tools like black
144
+ โ”‚
145
+ โ”œโ”€โ”€ src/ ## ๐Ÿงฉ Source code for use in this project.
146
+ โ”‚ โ”œโ”€โ”€ cloudops/ ## Main module for CloudOps automation
147
+ โ”‚ โ”‚ โ”œโ”€โ”€ __init__.py ## Package initializer
148
+ โ”‚ โ”‚ โ”œโ”€โ”€ s3.py ## S3 utility functions
149
+ โ”‚ โ”‚ โ”œโ”€โ”€ ec2.py ## EC2 automation
150
+ โ”‚ โ”‚ โ”œโ”€โ”€ rds.py ## RDS management
151
+ โ”‚ โ”‚ โ”œโ”€โ”€ runbooks/ ## Automation runbooks
152
+ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ backup.py ## Automated backup runbook
153
+ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ scale-out.py ## Scale-out automation runbook
154
+ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ cleanup.py ## Cleanup automation runbook
155
+ โ”‚ โ”œโ”€โ”€ utils/ ## Utility scripts (logging, configs)
156
+ โ”‚ โ”œโ”€โ”€ cli/ ## Command-line interface
157
+ โ”‚ โ”‚ โ”œโ”€โ”€ __init__.py ## CLI module initializer
158
+ โ”‚ โ”‚ โ”œโ”€โ”€ main.py ## CLI entry point
159
+ โ”‚ โ”‚ โ””โ”€โ”€ commands.py ## CLI commands
160
+ โ”‚ โ””โ”€โ”€ tests/ ## Unit and integration tests
161
+ โ”‚ โ”œโ”€โ”€ test_s3.py ## Test cases for S3 module
162
+ โ”‚ โ”œโ”€โ”€ test_ec2.py ## Test cases for EC2 module
163
+ โ”‚ โ””โ”€โ”€ test_runbooks.py ## Test cases for runbooks
164
+ โ”œโ”€โ”€ templates/ ## Terraform and CloudFormation templates
165
+ โ”œโ”€โ”€ tools/ ## Developer tools and scripts
166
+ โ”œโ”€โ”€ .dockerignore ## Docker ignore file
167
+ โ”œโ”€โ”€ .env ## Environment variables
168
+ โ”œโ”€โ”€ .gitignore ## Git ignore file
169
+ โ”œโ”€โ”€ .python-version ## Python version management
170
+ โ”œโ”€โ”€ .gitignore
171
+ โ”œโ”€โ”€ mkdocs.yml # Documentation generator configuration
172
+ โ”œโ”€โ”€ README.md ๐Ÿค Explain your project and its structure for better collaboration.
173
+ โ”œโ”€โ”€ references <- Data dictionaries, manuals, and all other explanatory materials.
174
+ โ”‚
175
+ โ”œโ”€โ”€ reports ๐Ÿ“Š Generated analysis (reports, charts, and plots) as HTML, PDF, LaTeX.
176
+ โ”‚ โ””โ”€โ”€ figures <- Generated graphics and figures to be used in reporting
177
+ โ”‚
178
+ โ”œโ”€โ”€ requirements.txt ๐Ÿ›  The requirements file for reproducing the analysis environment, for easy environment setup.
179
+ โ””โ”€โ”€ Taskfile <- Taskfile with convenience commands like `task data` or `task train`
180
+
181
+ ```
@@ -0,0 +1,157 @@
1
+ # ๐Ÿ”ฅ CloudOps Automation at Scale ๐Ÿฆ…
2
+
3
+ ๐ŸŒŸ You can use [CloudOps Automation Runbooks](https://cloudops.oceansoft.io), built on Jupyter Notebooks, to quickly create SRE RunBooks for Runbook Automation and Cloud Infrastructure Management! ๐ŸŒ
4
+
5
+ > [!IMPORTANT]
6
+ > **๐Ÿ† Mission**: Our mission is to simplify CloudOps Automation for DevOps and SRE teams by providing an extensive, community-driven repository of actions and runbooks that streamline day-to-day operations.
7
+
8
+ > [!NOTE]
9
+ > **๐Ÿ‘๏ธ Vision**: Our vision is to be the ๐Ÿฅ‡ One-Stop Multi-Cloud Platform Engineering & Best Practices Solution for all CloudOps Automation needs, allowing DevOps and SRE teams to automate their workflows with ease, improve efficiency, and minimize toil.
10
+
11
+ [![๐Ÿ CloudOps PyPI version](https://img.shields.io/pypi/v/cloudops)](https://pypi.org/project/cloudops/)
12
+
13
+ <div align="left">
14
+ <a href="https://www.linkedin.com/in/nnthanh" target="blank"><img align="center" src="https://img.shields.io/badge/-nnthanh-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/nnthanh/" alt="Nhat-Thanh Nguyen" height="25" width="100" /></a>
15
+ <a href="https://github.com/nnthanh101/" target="blank"><img align="center" src="https://img.shields.io/github/followers/nnthanh101?label=Follow&style=social&link=https://github.com/nnthanh101/" alt="Thanh Nguyen" height="25" width="100" /></a>
16
+ <a href="https://www.facebook.com/groups/platformengineering" target="blank"><img align="center" src="https://img.shields.io/badge/Facebook-blue?style=flat-square&logo=facebook&logoColor=white&link=[https://www.linkedin.com/in/nnthanh/](https://www.facebook.com/groups/platformengineering)" alt="Nhat-Thanh Nguyen" height="25" width="100" /></a>
17
+ </div>
18
+
19
+ ---
20
+
21
+ ## ๐Ÿ› ๏ธ Features
22
+
23
+ * ๐Ÿฅ‰ โœ…**Lightning-Fast Toolchain**: Powered by ๐Ÿ“ฆ `uv` - Next-generation Python dependency and build management, ๐Ÿ’… `ruff` - Linting and formatting at blazing speed, and ๐Ÿงช pytest - Robust testing framework with coverage reports.
24
+ * ๐Ÿฅˆ โœ…**Effortless CI/CD Pipelines**: ๐Ÿ› ๏ธ Taskfile Automation - Say goodbye to manual SDLC repetitive tasks, ๐Ÿณ Containerized Workflows โ€“ ๐Ÿ›ก๏ธ Security-first practices and Multi-stage Wolfi-based Docker builds for scalable production-ready environments, and โš™๏ธ Auto-publish to `PyPI` and GitHub Container Registry (`GHCR`) with GitHub Actions.
25
+ * ๐Ÿฅ‡ โ˜‘๏ธ**CloudOps Automation and FinOps Toolkit** โ€“ Pre-configured hybrid-cloud workflows and seamlessly integrations (jupyterlab, mkdocs, boto3, moto) for managing cloud infrastructure ๐ŸŒ.
26
+
27
+ | **Feature** | **Toolchain** | **Purpose** |
28
+ |--------------------------|-------------------------------------|----------------------------------------------------|
29
+ | ๐Ÿ› ๏ธ Configuration | `pyproject.toml` | Centralized configuration for dependencies, testing, and linting. |
30
+ | ๐Ÿงน Task Automation | [`Taskfile`](https://taskfile.dev/) | Automates repetitive tasks like linting, testing, and publishing. |
31
+ | ๐Ÿ“ฆ Python Dependencies | [`uv`](https://docs.astral.sh/uv/) | Lightning-fast dependency resolution, caching, and builds. |
32
+ | ๐Ÿ’… Linting & Formatting | [`ruff`](https://docs.astral.sh/ruff/) | Enforces code quality standards, auto-formatting, and import sorting. |
33
+ | ๐Ÿงช Testing Framework | [`pytest`](https://docs.pytest.org/) | Comprehensive unit tests, integration tests with coverage reporting. |
34
+ | ๐Ÿณ Docker Integration | Dockerfile + [`DevContainer`](https://containers.dev/) | Optimized wolfi-based multi-stage builds for CI/CD and local development environments. |
35
+ | ๐Ÿฆพ CI/CD Pipelines | [`GitHub Actions`](https://github.com/features/actions) | Automated builds, tests, and deployments to PyPI and GHCR. |
36
+ | ๐Ÿ“ Security Compliance | [`chainguard/wolfi-base`](https://hub.docker.com/r/chainguard/wolfi-base) + SBOM + Attestations | Ensures compliance, vulnerability scanning, and security transparency. |
37
+
38
+ ---
39
+
40
+ ### WIP
41
+
42
+ - [ ] ๐Ÿ“š auto doc generation
43
+ - [ ] **CLI Tools** โ€“ Typer simplifies automation for AWS resources.
44
+ - [ ] **Logging** โ€“ Loguru ensures structured logs for debugging.
45
+ - [x] ๐Ÿณ CI/CD Optimized Docker Image runs when a new *release* is created pushing to gh registry
46
+ - [x] ๐Ÿฆพ GitHub actions:
47
+ - [x] auto publish to [`pypi`](https://pypi.org/) on push on `main`
48
+ - [ ] auto creating a new tag on push on `main`, sync versions
49
+ - [x] run `tests` and `lint` on `dev` and `main` when a PR is open
50
+
51
+ ## ๐Ÿš€ Quick Start
52
+
53
+ ### 1. Clone the Repository
54
+
55
+ ```bash
56
+ git clone https://github.com/nnthanh101/CloudOps.git
57
+ cd CloudOps
58
+ ```
59
+
60
+ ### 2. Install Dependencies and Run CI/CD Pipelines
61
+
62
+ ```bash
63
+ echo "Install Python dependencies using UV"
64
+ task install
65
+
66
+ echo "Run CI/CD pipeline tasks: clean, lint, format, test, and build"
67
+ task ci
68
+
69
+ echo "Publish the project package to PyPI"
70
+ task publish
71
+ ```
72
+
73
+ ### 3. Run in DevContainer ๐Ÿณ
74
+
75
+ 1. Open the project in **VSCode**.
76
+ 2. Install the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension.
77
+ 3. **Reopen in Container**:
78
+ **Command Palette `Ctrl+Shift+P` โ†’ Reopen in Container**.
79
+
80
+ ---
81
+
82
+ ## Project Structure
83
+
84
+ > ๐Ÿ›  End-to-end Production-grade project structure for successful ๐Ÿ’Ž CloudOps Automation and Visual Analytics FinOps projects ๐Ÿš€
85
+
86
+ ```
87
+ cloudops-automation/
88
+ โ”œโ”€โ”€ .devcontainer/ ## Dev Container configurations
89
+ โ”‚ โ””โ”€โ”€ Dockerfile ## Container image build file
90
+ โ”œโ”€โ”€ .github/ ## CI/CD workflows
91
+ โ”‚ โ”œโ”€โ”€ workflows/ ## GitHub Actions workflows
92
+ โ”‚ โ””โ”€โ”€ templates/ ## Workflow templates
93
+ โ”œโ”€โ”€ .vscode/ ## IDE-specific configurations
94
+ โ”œโ”€โ”€ config/ ## Configuration files (YAML, JSON)
95
+ โ”œโ”€โ”€ data ๐Ÿ” Where all your raw and processed data files are stored.
96
+ โ”‚ โ”œโ”€โ”€ external <- Data from third-party sources.
97
+ โ”‚ โ”œโ”€โ”€ interim <- Intermediate data that has been transformed.
98
+ โ”‚ โ”œโ”€โ”€ processed <- The final, canonical data sets for modeling.
99
+ โ”‚ โ””โ”€โ”€ raw <- The original, unprocessed, immutable data dump.
100
+ โ”‚
101
+ โ”œโ”€โ”€ docs ๐Ÿ““ A default mkdocs project; see mkdocs.org for details
102
+ โ”‚ โ”œโ”€โ”€ api/ ## API documentation
103
+ โ”‚ โ”œโ”€โ”€ architecture/ ## Architecture diagrams
104
+ โ”‚ โ”œโ”€โ”€ tutorials/ ## Tutorials and guides
105
+ โ”‚ โ”œโ”€โ”€ getting-started.md ## Quickstart guide
106
+ โ”‚ โ””โ”€โ”€ index.md ## Overview documentation
107
+ โ”‚
108
+ โ”œโ”€โ”€ logs/ ## Log files for debugging
109
+ |
110
+ โ”œโ”€โ”€ models ๐Ÿง  Store your trained and serialized models for easy access and versioning.
111
+ โ”‚
112
+ โ”œโ”€โ”€ notebooks ๐Ÿ’ป Jupyter notebooks for experiments and visualization.
113
+ โ”‚ โ”œโ”€โ”€ data_exploration.ipynb
114
+ โ”‚ โ”œโ”€โ”€ data_preprocessing.ipynb
115
+ โ”‚ โ”œโ”€โ”€ model_training.ipynb
116
+ โ”‚ โ””โ”€โ”€ model_evaluation.ipynb
117
+ โ”‚
118
+ โ”œโ”€โ”€ pyproject.toml <- Project configuration file with package metadata for
119
+ โ”‚ cloudops and configuration for tools like black
120
+ โ”‚
121
+ โ”œโ”€โ”€ src/ ## ๐Ÿงฉ Source code for use in this project.
122
+ โ”‚ โ”œโ”€โ”€ cloudops/ ## Main module for CloudOps automation
123
+ โ”‚ โ”‚ โ”œโ”€โ”€ __init__.py ## Package initializer
124
+ โ”‚ โ”‚ โ”œโ”€โ”€ s3.py ## S3 utility functions
125
+ โ”‚ โ”‚ โ”œโ”€โ”€ ec2.py ## EC2 automation
126
+ โ”‚ โ”‚ โ”œโ”€โ”€ rds.py ## RDS management
127
+ โ”‚ โ”‚ โ”œโ”€โ”€ runbooks/ ## Automation runbooks
128
+ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ backup.py ## Automated backup runbook
129
+ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ scale-out.py ## Scale-out automation runbook
130
+ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ cleanup.py ## Cleanup automation runbook
131
+ โ”‚ โ”œโ”€โ”€ utils/ ## Utility scripts (logging, configs)
132
+ โ”‚ โ”œโ”€โ”€ cli/ ## Command-line interface
133
+ โ”‚ โ”‚ โ”œโ”€โ”€ __init__.py ## CLI module initializer
134
+ โ”‚ โ”‚ โ”œโ”€โ”€ main.py ## CLI entry point
135
+ โ”‚ โ”‚ โ””โ”€โ”€ commands.py ## CLI commands
136
+ โ”‚ โ””โ”€โ”€ tests/ ## Unit and integration tests
137
+ โ”‚ โ”œโ”€โ”€ test_s3.py ## Test cases for S3 module
138
+ โ”‚ โ”œโ”€โ”€ test_ec2.py ## Test cases for EC2 module
139
+ โ”‚ โ””โ”€โ”€ test_runbooks.py ## Test cases for runbooks
140
+ โ”œโ”€โ”€ templates/ ## Terraform and CloudFormation templates
141
+ โ”œโ”€โ”€ tools/ ## Developer tools and scripts
142
+ โ”œโ”€โ”€ .dockerignore ## Docker ignore file
143
+ โ”œโ”€โ”€ .env ## Environment variables
144
+ โ”œโ”€โ”€ .gitignore ## Git ignore file
145
+ โ”œโ”€โ”€ .python-version ## Python version management
146
+ โ”œโ”€โ”€ .gitignore
147
+ โ”œโ”€โ”€ mkdocs.yml # Documentation generator configuration
148
+ โ”œโ”€โ”€ README.md ๐Ÿค Explain your project and its structure for better collaboration.
149
+ โ”œโ”€โ”€ references <- Data dictionaries, manuals, and all other explanatory materials.
150
+ โ”‚
151
+ โ”œโ”€โ”€ reports ๐Ÿ“Š Generated analysis (reports, charts, and plots) as HTML, PDF, LaTeX.
152
+ โ”‚ โ””โ”€โ”€ figures <- Generated graphics and figures to be used in reporting
153
+ โ”‚
154
+ โ”œโ”€โ”€ requirements.txt ๐Ÿ›  The requirements file for reproducing the analysis environment, for easy environment setup.
155
+ โ””โ”€โ”€ Taskfile <- Taskfile with convenience commands like `task data` or `task train`
156
+
157
+ ```
@@ -0,0 +1,82 @@
1
+ [project]
2
+ ## https://docs.astral.sh/uv/concepts/projects/config/
3
+ name = "runbooks"
4
+ authors = [
5
+ {name = "runbooks maintainers", email = "nnthanh101@gmail.com"},
6
+ ]
7
+ version = "0.1.1"
8
+ description = "CloudOps Automation for DevOps and SRE teams."
9
+ readme = "README.md"
10
+ license = {file = "LICENSE.txt"}
11
+ requires-python = ">=3.11"
12
+
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Environment :: Console",
16
+ "License :: OSI Approved :: Apache Software License",
17
+ "Operating System :: OS Independent",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Topic :: Documentation",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ "Topic :: Utilities",
24
+ ]
25
+
26
+ # [project.urls]
27
+ # Homepage = "https://cloudops.oceansoft.io"
28
+ # Changelog = "https://github.com/nnthanh101/CloudOps/blob/master/CHANGELOG.md"
29
+ # Releases = "https://github.com/nnthanh101/CloudOps/releases"
30
+ # Source = "https://github.com/nnthanh101/CloudOps"
31
+ # bug_reports = "https://github.com/nnthanh101/CloudOps/issues"
32
+
33
+ dependencies = [
34
+ "requests>=2.32.3",
35
+ "loguru>=0.7.3",
36
+ "typer>=0.15.1",
37
+ "tqdm>=4.67.1",
38
+ "boto3>=1.35.90",
39
+ "moto>=5.0.25"
40
+ ]
41
+
42
+ [dependency-groups]
43
+ dev = [
44
+ "pytest>=8.3.4",
45
+ "ruff>=0.8.4",
46
+ "pytest-cov>=6.0.0"
47
+ ]
48
+
49
+ [build-system]
50
+ requires = ["setuptools"]
51
+ build-backend = "setuptools.build_meta"
52
+
53
+ [tool.setuptools]
54
+ license-files = []
55
+
56
+ [tool.ruff]
57
+ ## Linting and Formatting Configurations
58
+ ## https://docs.astral.sh/ruff/configuration/
59
+ target-version = "py312"
60
+ line-length = 120
61
+
62
+ [tool.ruff.lint]
63
+ select = ["E", "W", "F", "I"]
64
+ ignore = ["F401", "E501", "F811"]
65
+ fixable = ["I"]
66
+ unfixable = []
67
+
68
+ [tool.ruff.format]
69
+ line-ending = "lf"
70
+
71
+ [tool.pytest.ini_options]
72
+ ## Test Configuration
73
+ pythonpath = ["src"]
74
+ testpaths = ["tests"]
75
+ addopts = "--cov=src/cloudops --cov-report=term-missing"
76
+
77
+ [project.scripts]
78
+ ## Will run the function by just typing `sync-down` and `sync-up` in the CLI
79
+ # sync-down = "cloudops.cli:sync_down"
80
+ # sync-up = "cloudops.cli:sync_up"
81
+ # cloudops = "cloudops.runbooks:main"
82
+ # check-code-quality = "cloudops.toolkit:check_code_quality"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,10 @@
1
+ """
2
+ CloudOps: CloudOps Toolkit
3
+
4
+ Provides utility functions for math operations, AWS S3 interactions, and data management.
5
+ """
6
+
7
+ __version__ = "0.1.1"
8
+
9
+ from .toolkit import add, divide, multiply, subtract
10
+ # from .s3 import S3Client
@@ -0,0 +1,147 @@
1
+ from typing import Tuple, Union
2
+
3
+ from loguru import logger
4
+
5
+ ## Define a type alias for supported numeric types
6
+ Number = Union[float, int]
7
+
8
+
9
+ def add(a: Number, b: Number) -> float:
10
+ """Compute and return the sum of two numbers.
11
+
12
+ Examples:
13
+ >>> add(4.0, 2.0)
14
+ 6.0
15
+ >>> add(4, 2)
16
+ 6.0
17
+
18
+ Args:
19
+ a: The first number in the addition.
20
+ b: The second number in the addition.
21
+
22
+ Returns:
23
+ float: The arithmetic sum of `a` and `b`.
24
+
25
+ Raises:
26
+ TypeError: If inputs are not numbers.
27
+ """
28
+ if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
29
+ raise TypeError("Both inputs must be integers or floats.")
30
+
31
+ logger.debug(f"Adding {a} + {b}")
32
+ return float(a + b)
33
+
34
+
35
+ def subtract(a: Number, b: Number) -> float:
36
+ """Compute and return the subtraction of two numbers.
37
+
38
+ Examples:
39
+ >>> subtract(4.0, 2.0)
40
+ 2.0
41
+ >>> subtract(4, 2)
42
+ 2.0
43
+
44
+ Args:
45
+ a: The first number in the subtraction.
46
+ b: The second number in the subtraction.
47
+
48
+ Returns:
49
+ float: The arithmetic subtraction of `a` and `b`.
50
+
51
+ Raises:
52
+ TypeError: If inputs are not numbers.
53
+ """
54
+ if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
55
+ raise TypeError("Both inputs must be integers or floats.")
56
+
57
+ logger.debug(f"Subtracting {a} - {b}")
58
+ return float(a - b)
59
+
60
+
61
+ def multiply(a: Number, b: Number) -> float:
62
+ """Compute and return the multiplication of two numbers.
63
+
64
+ Examples:
65
+ >>> multiply(4.0, 2.0)
66
+ 8.0
67
+ >>> multiply(4, 2)
68
+ 8.0
69
+
70
+ Args:
71
+ a: The first number in the multiplication.
72
+ b: The second number in the multiplication.
73
+
74
+ Returns:
75
+ float: The arithmetic multiplication of `a` and `b`.
76
+
77
+ Raises:
78
+ TypeError: If inputs are not numbers.
79
+ """
80
+ if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
81
+ raise TypeError("Both inputs must be integers or floats.")
82
+
83
+ logger.debug(f"Multiplying {a} * {b}")
84
+ return float(a * b)
85
+
86
+
87
+ def divide(a: Number, b: Number) -> float:
88
+ """Compute and return the division of two numbers.
89
+
90
+ Examples:
91
+ >>> divide(4.0, 2.0)
92
+ 2.0
93
+ >>> divide(4, 2)
94
+ 2.0
95
+
96
+ Args:
97
+ a: The numerator.
98
+ b: The denominator.
99
+
100
+ Returns:
101
+ float: The result of dividing `a` by `b`.
102
+
103
+ Raises:
104
+ TypeError: If inputs are not numbers.
105
+ ZeroDivisionError: If the denominator is zero.
106
+ """
107
+ if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
108
+ raise TypeError("Both inputs must be integers or floats.")
109
+ if b == 0:
110
+ logger.error("Attempted division by zero.")
111
+ raise ZeroDivisionError("division by zero")
112
+
113
+ logger.debug(f"Dividing {a} / {b}")
114
+ return float(a / b)
115
+
116
+
117
+ def divide(a: Number, b: Number) -> float:
118
+ """Compute and return the division of two numbers.
119
+
120
+ Examples:
121
+ >>> divide(4.0, 2.0)
122
+ 2.0
123
+ >>> divide(4, 2)
124
+ 2.0
125
+
126
+ Args:
127
+ a: The numerator.
128
+ b: The denominator.
129
+
130
+ Returns:
131
+ float: The result of dividing `a` by `b`.
132
+
133
+ Raises:
134
+ TypeError: If inputs are not numbers.
135
+ ZeroDivisionError: If the denominator is zero.
136
+ """
137
+ # Input validation
138
+ if not isinstance(a, (int, float)) or not isinstance(b, (int, float)):
139
+ raise TypeError("Both inputs must be integers or floats.")
140
+
141
+ # Handle division by zero
142
+ if b == 0:
143
+ raise ZeroDivisionError("division by zero")
144
+
145
+ # Perform division
146
+ logger.debug(f"Dividing {a} / {b}")
147
+ return float(a / b)
@@ -0,0 +1,181 @@
1
+ Metadata-Version: 2.1
2
+ Name: runbooks
3
+ Version: 0.1.1
4
+ Summary: CloudOps Automation for DevOps and SRE teams.
5
+ Author-email: runbooks maintainers <nnthanh101@gmail.com>
6
+ Classifier: Development Status :: 4 - Beta
7
+ Classifier: Environment :: Console
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Topic :: Documentation
14
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
15
+ Classifier: Topic :: Utilities
16
+ Requires-Python: >=3.11
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests>=2.32.3
19
+ Requires-Dist: loguru>=0.7.3
20
+ Requires-Dist: typer>=0.15.1
21
+ Requires-Dist: tqdm>=4.67.1
22
+ Requires-Dist: boto3>=1.35.90
23
+ Requires-Dist: moto>=5.0.25
24
+
25
+ # ๐Ÿ”ฅ CloudOps Automation at Scale ๐Ÿฆ…
26
+
27
+ ๐ŸŒŸ You can use [CloudOps Automation Runbooks](https://cloudops.oceansoft.io), built on Jupyter Notebooks, to quickly create SRE RunBooks for Runbook Automation and Cloud Infrastructure Management! ๐ŸŒ
28
+
29
+ > [!IMPORTANT]
30
+ > **๐Ÿ† Mission**: Our mission is to simplify CloudOps Automation for DevOps and SRE teams by providing an extensive, community-driven repository of actions and runbooks that streamline day-to-day operations.
31
+
32
+ > [!NOTE]
33
+ > **๐Ÿ‘๏ธ Vision**: Our vision is to be the ๐Ÿฅ‡ One-Stop Multi-Cloud Platform Engineering & Best Practices Solution for all CloudOps Automation needs, allowing DevOps and SRE teams to automate their workflows with ease, improve efficiency, and minimize toil.
34
+
35
+ [![๐Ÿ CloudOps PyPI version](https://img.shields.io/pypi/v/cloudops)](https://pypi.org/project/cloudops/)
36
+
37
+ <div align="left">
38
+ <a href="https://www.linkedin.com/in/nnthanh" target="blank"><img align="center" src="https://img.shields.io/badge/-nnthanh-blue?style=flat-square&logo=Linkedin&logoColor=white&link=https://www.linkedin.com/in/nnthanh/" alt="Nhat-Thanh Nguyen" height="25" width="100" /></a>
39
+ <a href="https://github.com/nnthanh101/" target="blank"><img align="center" src="https://img.shields.io/github/followers/nnthanh101?label=Follow&style=social&link=https://github.com/nnthanh101/" alt="Thanh Nguyen" height="25" width="100" /></a>
40
+ <a href="https://www.facebook.com/groups/platformengineering" target="blank"><img align="center" src="https://img.shields.io/badge/Facebook-blue?style=flat-square&logo=facebook&logoColor=white&link=[https://www.linkedin.com/in/nnthanh/](https://www.facebook.com/groups/platformengineering)" alt="Nhat-Thanh Nguyen" height="25" width="100" /></a>
41
+ </div>
42
+
43
+ ---
44
+
45
+ ## ๐Ÿ› ๏ธ Features
46
+
47
+ * ๐Ÿฅ‰ โœ…**Lightning-Fast Toolchain**: Powered by ๐Ÿ“ฆ `uv` - Next-generation Python dependency and build management, ๐Ÿ’… `ruff` - Linting and formatting at blazing speed, and ๐Ÿงช pytest - Robust testing framework with coverage reports.
48
+ * ๐Ÿฅˆ โœ…**Effortless CI/CD Pipelines**: ๐Ÿ› ๏ธ Taskfile Automation - Say goodbye to manual SDLC repetitive tasks, ๐Ÿณ Containerized Workflows โ€“ ๐Ÿ›ก๏ธ Security-first practices and Multi-stage Wolfi-based Docker builds for scalable production-ready environments, and โš™๏ธ Auto-publish to `PyPI` and GitHub Container Registry (`GHCR`) with GitHub Actions.
49
+ * ๐Ÿฅ‡ โ˜‘๏ธ**CloudOps Automation and FinOps Toolkit** โ€“ Pre-configured hybrid-cloud workflows and seamlessly integrations (jupyterlab, mkdocs, boto3, moto) for managing cloud infrastructure ๐ŸŒ.
50
+
51
+ | **Feature** | **Toolchain** | **Purpose** |
52
+ |--------------------------|-------------------------------------|----------------------------------------------------|
53
+ | ๐Ÿ› ๏ธ Configuration | `pyproject.toml` | Centralized configuration for dependencies, testing, and linting. |
54
+ | ๐Ÿงน Task Automation | [`Taskfile`](https://taskfile.dev/) | Automates repetitive tasks like linting, testing, and publishing. |
55
+ | ๐Ÿ“ฆ Python Dependencies | [`uv`](https://docs.astral.sh/uv/) | Lightning-fast dependency resolution, caching, and builds. |
56
+ | ๐Ÿ’… Linting & Formatting | [`ruff`](https://docs.astral.sh/ruff/) | Enforces code quality standards, auto-formatting, and import sorting. |
57
+ | ๐Ÿงช Testing Framework | [`pytest`](https://docs.pytest.org/) | Comprehensive unit tests, integration tests with coverage reporting. |
58
+ | ๐Ÿณ Docker Integration | Dockerfile + [`DevContainer`](https://containers.dev/) | Optimized wolfi-based multi-stage builds for CI/CD and local development environments. |
59
+ | ๐Ÿฆพ CI/CD Pipelines | [`GitHub Actions`](https://github.com/features/actions) | Automated builds, tests, and deployments to PyPI and GHCR. |
60
+ | ๐Ÿ“ Security Compliance | [`chainguard/wolfi-base`](https://hub.docker.com/r/chainguard/wolfi-base) + SBOM + Attestations | Ensures compliance, vulnerability scanning, and security transparency. |
61
+
62
+ ---
63
+
64
+ ### WIP
65
+
66
+ - [ ] ๐Ÿ“š auto doc generation
67
+ - [ ] **CLI Tools** โ€“ Typer simplifies automation for AWS resources.
68
+ - [ ] **Logging** โ€“ Loguru ensures structured logs for debugging.
69
+ - [x] ๐Ÿณ CI/CD Optimized Docker Image runs when a new *release* is created pushing to gh registry
70
+ - [x] ๐Ÿฆพ GitHub actions:
71
+ - [x] auto publish to [`pypi`](https://pypi.org/) on push on `main`
72
+ - [ ] auto creating a new tag on push on `main`, sync versions
73
+ - [x] run `tests` and `lint` on `dev` and `main` when a PR is open
74
+
75
+ ## ๐Ÿš€ Quick Start
76
+
77
+ ### 1. Clone the Repository
78
+
79
+ ```bash
80
+ git clone https://github.com/nnthanh101/CloudOps.git
81
+ cd CloudOps
82
+ ```
83
+
84
+ ### 2. Install Dependencies and Run CI/CD Pipelines
85
+
86
+ ```bash
87
+ echo "Install Python dependencies using UV"
88
+ task install
89
+
90
+ echo "Run CI/CD pipeline tasks: clean, lint, format, test, and build"
91
+ task ci
92
+
93
+ echo "Publish the project package to PyPI"
94
+ task publish
95
+ ```
96
+
97
+ ### 3. Run in DevContainer ๐Ÿณ
98
+
99
+ 1. Open the project in **VSCode**.
100
+ 2. Install the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension.
101
+ 3. **Reopen in Container**:
102
+ **Command Palette `Ctrl+Shift+P` โ†’ Reopen in Container**.
103
+
104
+ ---
105
+
106
+ ## Project Structure
107
+
108
+ > ๐Ÿ›  End-to-end Production-grade project structure for successful ๐Ÿ’Ž CloudOps Automation and Visual Analytics FinOps projects ๐Ÿš€
109
+
110
+ ```
111
+ cloudops-automation/
112
+ โ”œโ”€โ”€ .devcontainer/ ## Dev Container configurations
113
+ โ”‚ โ””โ”€โ”€ Dockerfile ## Container image build file
114
+ โ”œโ”€โ”€ .github/ ## CI/CD workflows
115
+ โ”‚ โ”œโ”€โ”€ workflows/ ## GitHub Actions workflows
116
+ โ”‚ โ””โ”€โ”€ templates/ ## Workflow templates
117
+ โ”œโ”€โ”€ .vscode/ ## IDE-specific configurations
118
+ โ”œโ”€โ”€ config/ ## Configuration files (YAML, JSON)
119
+ โ”œโ”€โ”€ data ๐Ÿ” Where all your raw and processed data files are stored.
120
+ โ”‚ โ”œโ”€โ”€ external <- Data from third-party sources.
121
+ โ”‚ โ”œโ”€โ”€ interim <- Intermediate data that has been transformed.
122
+ โ”‚ โ”œโ”€โ”€ processed <- The final, canonical data sets for modeling.
123
+ โ”‚ โ””โ”€โ”€ raw <- The original, unprocessed, immutable data dump.
124
+ โ”‚
125
+ โ”œโ”€โ”€ docs ๐Ÿ““ A default mkdocs project; see mkdocs.org for details
126
+ โ”‚ โ”œโ”€โ”€ api/ ## API documentation
127
+ โ”‚ โ”œโ”€โ”€ architecture/ ## Architecture diagrams
128
+ โ”‚ โ”œโ”€โ”€ tutorials/ ## Tutorials and guides
129
+ โ”‚ โ”œโ”€โ”€ getting-started.md ## Quickstart guide
130
+ โ”‚ โ””โ”€โ”€ index.md ## Overview documentation
131
+ โ”‚
132
+ โ”œโ”€โ”€ logs/ ## Log files for debugging
133
+ |
134
+ โ”œโ”€โ”€ models ๐Ÿง  Store your trained and serialized models for easy access and versioning.
135
+ โ”‚
136
+ โ”œโ”€โ”€ notebooks ๐Ÿ’ป Jupyter notebooks for experiments and visualization.
137
+ โ”‚ โ”œโ”€โ”€ data_exploration.ipynb
138
+ โ”‚ โ”œโ”€โ”€ data_preprocessing.ipynb
139
+ โ”‚ โ”œโ”€โ”€ model_training.ipynb
140
+ โ”‚ โ””โ”€โ”€ model_evaluation.ipynb
141
+ โ”‚
142
+ โ”œโ”€โ”€ pyproject.toml <- Project configuration file with package metadata for
143
+ โ”‚ cloudops and configuration for tools like black
144
+ โ”‚
145
+ โ”œโ”€โ”€ src/ ## ๐Ÿงฉ Source code for use in this project.
146
+ โ”‚ โ”œโ”€โ”€ cloudops/ ## Main module for CloudOps automation
147
+ โ”‚ โ”‚ โ”œโ”€โ”€ __init__.py ## Package initializer
148
+ โ”‚ โ”‚ โ”œโ”€โ”€ s3.py ## S3 utility functions
149
+ โ”‚ โ”‚ โ”œโ”€โ”€ ec2.py ## EC2 automation
150
+ โ”‚ โ”‚ โ”œโ”€โ”€ rds.py ## RDS management
151
+ โ”‚ โ”‚ โ”œโ”€โ”€ runbooks/ ## Automation runbooks
152
+ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ backup.py ## Automated backup runbook
153
+ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ scale-out.py ## Scale-out automation runbook
154
+ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ cleanup.py ## Cleanup automation runbook
155
+ โ”‚ โ”œโ”€โ”€ utils/ ## Utility scripts (logging, configs)
156
+ โ”‚ โ”œโ”€โ”€ cli/ ## Command-line interface
157
+ โ”‚ โ”‚ โ”œโ”€โ”€ __init__.py ## CLI module initializer
158
+ โ”‚ โ”‚ โ”œโ”€โ”€ main.py ## CLI entry point
159
+ โ”‚ โ”‚ โ””โ”€โ”€ commands.py ## CLI commands
160
+ โ”‚ โ””โ”€โ”€ tests/ ## Unit and integration tests
161
+ โ”‚ โ”œโ”€โ”€ test_s3.py ## Test cases for S3 module
162
+ โ”‚ โ”œโ”€โ”€ test_ec2.py ## Test cases for EC2 module
163
+ โ”‚ โ””โ”€โ”€ test_runbooks.py ## Test cases for runbooks
164
+ โ”œโ”€โ”€ templates/ ## Terraform and CloudFormation templates
165
+ โ”œโ”€โ”€ tools/ ## Developer tools and scripts
166
+ โ”œโ”€โ”€ .dockerignore ## Docker ignore file
167
+ โ”œโ”€โ”€ .env ## Environment variables
168
+ โ”œโ”€โ”€ .gitignore ## Git ignore file
169
+ โ”œโ”€โ”€ .python-version ## Python version management
170
+ โ”œโ”€โ”€ .gitignore
171
+ โ”œโ”€โ”€ mkdocs.yml # Documentation generator configuration
172
+ โ”œโ”€โ”€ README.md ๐Ÿค Explain your project and its structure for better collaboration.
173
+ โ”œโ”€โ”€ references <- Data dictionaries, manuals, and all other explanatory materials.
174
+ โ”‚
175
+ โ”œโ”€โ”€ reports ๐Ÿ“Š Generated analysis (reports, charts, and plots) as HTML, PDF, LaTeX.
176
+ โ”‚ โ””โ”€โ”€ figures <- Generated graphics and figures to be used in reporting
177
+ โ”‚
178
+ โ”œโ”€โ”€ requirements.txt ๐Ÿ›  The requirements file for reproducing the analysis environment, for easy environment setup.
179
+ โ””โ”€โ”€ Taskfile <- Taskfile with convenience commands like `task data` or `task train`
180
+
181
+ ```
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/cloudops/__init__.py
4
+ src/cloudops/toolkit.py
5
+ src/runbooks.egg-info/PKG-INFO
6
+ src/runbooks.egg-info/SOURCES.txt
7
+ src/runbooks.egg-info/dependency_links.txt
8
+ src/runbooks.egg-info/requires.txt
9
+ src/runbooks.egg-info/top_level.txt
10
+ tests/test_toolkit.py
@@ -0,0 +1,6 @@
1
+ requests>=2.32.3
2
+ loguru>=0.7.3
3
+ typer>=0.15.1
4
+ tqdm>=4.67.1
5
+ boto3>=1.35.90
6
+ moto>=5.0.25
@@ -0,0 +1 @@
1
+ cloudops
@@ -0,0 +1,151 @@
1
+ import sys
2
+ from pathlib import Path
3
+
4
+ # Add the src directory to the Python path
5
+ sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "src"))
6
+
7
+ import pytest
8
+
9
+ from cloudops.toolkit import add, divide, multiply, subtract
10
+
11
+ #################################################################################
12
+ # TEST CASES: ADDITION #
13
+ #################################################################################
14
+
15
+
16
+ @pytest.mark.parametrize(
17
+ "a, b, expected",
18
+ [
19
+ (2, 3, 5.0), # Integer addition
20
+ (2.5, 3.5, 6.0), # Float addition
21
+ (-1, 1, 0.0), # Negative and positive numbers
22
+ (0, 0, 0.0), # Zero addition
23
+ (1e10, 1e10, 2e10), # Large numbers
24
+ ],
25
+ )
26
+ def test_add(a, b, expected):
27
+ """Test add function with various inputs."""
28
+ assert add(a, b) == expected
29
+
30
+
31
+ #################################################################################
32
+ # TEST CASES: SUBTRACTION #
33
+ #################################################################################
34
+
35
+
36
+ @pytest.mark.parametrize(
37
+ "a, b, expected",
38
+ [
39
+ (5, 3, 2.0), # Integer subtraction
40
+ (2.5, 1.5, 1.0), # Float subtraction
41
+ (-1, -1, 0.0), # Negative numbers
42
+ (0, 0, 0.0), # Zero subtraction
43
+ (1e10, 1e5, 9.9999e9), # Large numbers
44
+ ],
45
+ )
46
+ def test_subtract(a, b, expected):
47
+ """Test subtract function with various inputs."""
48
+ assert subtract(a, b) == expected
49
+
50
+
51
+ #################################################################################
52
+ # TEST CASES: MULTIPLICATION #
53
+ #################################################################################
54
+
55
+
56
+ @pytest.mark.parametrize(
57
+ "a, b, expected",
58
+ [
59
+ (2, 3, 6.0), # Integer multiplication
60
+ (2.5, 4, 10.0), # Float multiplication
61
+ (-2, 3, -6.0), # Negative numbers
62
+ (0, 5, 0.0), # Zero multiplication
63
+ (1e5, 1e5, 1e10), # Large numbers
64
+ ],
65
+ )
66
+ def test_multiply(a, b, expected):
67
+ """Test multiply function with various inputs."""
68
+ assert multiply(a, b) == expected
69
+
70
+
71
+ #################################################################################
72
+ # TEST CASES: DIVISION #
73
+ #################################################################################
74
+
75
+
76
+ @pytest.mark.parametrize(
77
+ "a, b, expected",
78
+ [
79
+ (6, 3, 2.0), # Integer division
80
+ (2.5, 0.5, 5.0), # Float division
81
+ (-6, 3, -2.0), # Negative numbers
82
+ (1e10, 1e5, 1e5), # Large numbers
83
+ ],
84
+ )
85
+ def test_divide(a, b, expected):
86
+ """Test divide function with valid inputs."""
87
+ assert divide(a, b) == expected
88
+
89
+
90
+ #################################################################################
91
+ # EDGE CASES: DIVISION BY ZERO #
92
+ #################################################################################
93
+
94
+
95
+ def test_divide_by_zero():
96
+ """Test divide function raises ZeroDivisionError on zero divisor."""
97
+ with pytest.raises(ZeroDivisionError, match="division by zero"):
98
+ divide(10, 0)
99
+
100
+
101
+ #################################################################################
102
+ # EDGE CASES: INVALID INPUTS #
103
+ #################################################################################
104
+
105
+
106
+ @pytest.mark.parametrize(
107
+ "func, a, b",
108
+ [
109
+ (add, "a", 1), # Non-numeric input
110
+ (subtract, 1, "b"), # Non-numeric input
111
+ (multiply, "a", "b"), # Non-numeric inputs
112
+ (divide, None, 1), # None as input
113
+ ],
114
+ )
115
+ def test_invalid_inputs(func, a, b):
116
+ """Test functions with invalid inputs."""
117
+ with pytest.raises(TypeError):
118
+ func(a, b)
119
+
120
+
121
+ #################################################################################
122
+ # PERFORMANCE TEST CASES #
123
+ #################################################################################
124
+
125
+
126
+ def test_large_operations():
127
+ """Test functions with extremely large numbers."""
128
+ big_num = 1e100
129
+ assert add(big_num, big_num) == 2e100
130
+ assert subtract(big_num, big_num) == 0.0
131
+ assert multiply(big_num, 2) == 2e100
132
+ assert divide(big_num, 1) == big_num
133
+
134
+
135
+ #################################################################################
136
+ # FINAL TEST FOR FUNCTION RETURN TYPES #
137
+ #################################################################################
138
+
139
+
140
+ @pytest.mark.parametrize(
141
+ "func, a, b",
142
+ [
143
+ (add, 1, 2),
144
+ (subtract, 5, 3),
145
+ (multiply, 2, 3),
146
+ (divide, 6, 2),
147
+ ],
148
+ )
149
+ def test_return_type(func, a, b):
150
+ """Test if the return type of all functions is float."""
151
+ assert isinstance(func(a, b), float)