runbooks 0.7.6__py3-none-any.whl → 0.7.7__py3-none-any.whl

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.
runbooks/finops/cli.py CHANGED
@@ -128,6 +128,22 @@ def main() -> int:
128
128
  action="store_true",
129
129
  help="Display an audit report with cost anomalies, stopped EC2 instances, unused EBS columes, budget alerts, and more",
130
130
  )
131
+ parser.add_argument(
132
+ "--pdca",
133
+ action="store_true",
134
+ help="Run autonomous PDCA (Plan-Do-Check-Act) cycles for continuous improvement",
135
+ )
136
+ parser.add_argument(
137
+ "--pdca-cycles",
138
+ help="Number of PDCA cycles to run (default: 3, 0 for continuous mode)",
139
+ type=int,
140
+ default=3,
141
+ )
142
+ parser.add_argument(
143
+ "--pdca-continuous",
144
+ action="store_true",
145
+ help="Run PDCA in continuous mode (until manually stopped)",
146
+ )
131
147
 
132
148
  args = parser.parse_args()
133
149
 
@@ -143,6 +159,52 @@ def main() -> int:
143
159
  if hasattr(args, key) and getattr(args, key) == parser.get_default(key):
144
160
  setattr(args, key, value)
145
161
 
162
+ # Handle PDCA mode
163
+ if args.pdca or args.pdca_continuous:
164
+ import asyncio
165
+ from runbooks.finops.pdca_engine import AutonomousPDCAEngine, PDCAThresholds
166
+
167
+ console.print("[bold bright_cyan]🤖 Launching Autonomous PDCA Engine...[/]")
168
+
169
+ # Configure PDCA thresholds
170
+ thresholds = PDCAThresholds(
171
+ max_risk_score=25,
172
+ max_cost_increase=10.0,
173
+ max_untagged_resources=50,
174
+ max_unused_eips=5,
175
+ max_budget_overruns=1
176
+ )
177
+
178
+ # Initialize PDCA engine
179
+ artifacts_dir = args.dir or "artifacts"
180
+ engine = AutonomousPDCAEngine(thresholds=thresholds, artifacts_dir=artifacts_dir)
181
+
182
+ try:
183
+ # Determine execution mode
184
+ continuous_mode = args.pdca_continuous
185
+ max_cycles = 0 if continuous_mode else args.pdca_cycles
186
+
187
+ # Run PDCA cycles
188
+ metrics_history = asyncio.run(engine.run_autonomous_cycles(max_cycles, continuous_mode))
189
+
190
+ # Generate summary report
191
+ engine.generate_cycle_summary_report()
192
+
193
+ console.print(f"\n[bold bright_green]🎉 PDCA Engine completed successfully![/]")
194
+ console.print(f"[cyan]Generated {len(metrics_history)} cycle reports in: {engine.pdca_dir}[/]")
195
+
196
+ return 0
197
+
198
+ except KeyboardInterrupt:
199
+ console.print(f"\n[yellow]⏸️ PDCA Engine stopped by user[/]")
200
+ if engine.cycle_history:
201
+ engine.generate_cycle_summary_report()
202
+ return 0
203
+ except Exception as e:
204
+ console.print(f"\n[red]❌ PDCA Engine failed: {str(e)}[/]")
205
+ return 1
206
+
207
+ # Default dashboard mode
146
208
  result = run_dashboard(args)
147
209
  return 0 if result == 0 else 1
148
210