mcp-souschef 2.0.1__py3-none-any.whl → 2.2.0__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.
- {mcp_souschef-2.0.1.dist-info → mcp_souschef-2.2.0.dist-info}/METADATA +453 -77
- mcp_souschef-2.2.0.dist-info/RECORD +31 -0
- souschef/__init__.py +17 -0
- souschef/assessment.py +1498 -0
- souschef/cli.py +90 -0
- souschef/converters/__init__.py +23 -0
- souschef/converters/habitat.py +674 -0
- souschef/converters/playbook.py +1736 -0
- souschef/converters/resource.py +325 -0
- souschef/core/__init__.py +80 -0
- souschef/core/constants.py +145 -0
- souschef/core/errors.py +275 -0
- souschef/core/path_utils.py +58 -0
- souschef/core/ruby_utils.py +39 -0
- souschef/core/validation.py +555 -0
- souschef/deployment.py +1906 -0
- souschef/filesystem/__init__.py +5 -0
- souschef/filesystem/operations.py +67 -0
- souschef/parsers/__init__.py +36 -0
- souschef/parsers/attributes.py +257 -0
- souschef/parsers/habitat.py +317 -0
- souschef/parsers/inspec.py +809 -0
- souschef/parsers/metadata.py +211 -0
- souschef/parsers/recipe.py +200 -0
- souschef/parsers/resource.py +170 -0
- souschef/parsers/template.py +342 -0
- souschef/profiling.py +568 -0
- souschef/server.py +1854 -7481
- mcp_souschef-2.0.1.dist-info/RECORD +0 -8
- {mcp_souschef-2.0.1.dist-info → mcp_souschef-2.2.0.dist-info}/WHEEL +0 -0
- {mcp_souschef-2.0.1.dist-info → mcp_souschef-2.2.0.dist-info}/entry_points.txt +0 -0
- {mcp_souschef-2.0.1.dist-info → mcp_souschef-2.2.0.dist-info}/licenses/LICENSE +0 -0
souschef/cli.py
CHANGED
|
@@ -11,6 +11,10 @@ from typing import NoReturn
|
|
|
11
11
|
|
|
12
12
|
import click
|
|
13
13
|
|
|
14
|
+
from souschef.profiling import (
|
|
15
|
+
generate_cookbook_performance_report,
|
|
16
|
+
profile_function,
|
|
17
|
+
)
|
|
14
18
|
from souschef.server import (
|
|
15
19
|
convert_inspec_to_test,
|
|
16
20
|
convert_resource_to_task,
|
|
@@ -425,6 +429,92 @@ def _output_result(result: str, output_format: str) -> None:
|
|
|
425
429
|
_output_text_format(result)
|
|
426
430
|
|
|
427
431
|
|
|
432
|
+
@cli.command()
|
|
433
|
+
@click.argument("cookbook_path", type=click.Path(exists=True))
|
|
434
|
+
@click.option(
|
|
435
|
+
"--output",
|
|
436
|
+
"-o",
|
|
437
|
+
type=click.Path(),
|
|
438
|
+
help="Save report to file instead of printing to stdout",
|
|
439
|
+
)
|
|
440
|
+
def profile(cookbook_path: str, output: str | None) -> None:
|
|
441
|
+
"""
|
|
442
|
+
Profile cookbook parsing performance and generate optimization report.
|
|
443
|
+
|
|
444
|
+
COOKBOOK_PATH: Path to the Chef cookbook to profile
|
|
445
|
+
|
|
446
|
+
This command analyzes the performance of parsing all cookbook components
|
|
447
|
+
(recipes, attributes, resources, templates) and provides recommendations
|
|
448
|
+
for optimization.
|
|
449
|
+
"""
|
|
450
|
+
try:
|
|
451
|
+
click.echo(f"Profiling cookbook: {cookbook_path}")
|
|
452
|
+
click.echo("This may take a moment for large cookbooks...")
|
|
453
|
+
|
|
454
|
+
report = generate_cookbook_performance_report(cookbook_path)
|
|
455
|
+
report_text = str(report)
|
|
456
|
+
|
|
457
|
+
if output:
|
|
458
|
+
Path(output).write_text(report_text)
|
|
459
|
+
click.echo(f"✓ Performance report saved to: {output}")
|
|
460
|
+
else:
|
|
461
|
+
click.echo(report_text)
|
|
462
|
+
|
|
463
|
+
except Exception as e:
|
|
464
|
+
click.echo(f"Error profiling cookbook: {e}", err=True)
|
|
465
|
+
sys.exit(1)
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
@cli.command()
|
|
469
|
+
@click.argument(
|
|
470
|
+
"operation",
|
|
471
|
+
type=click.Choice(["recipe", "attributes", "resource", "template"]),
|
|
472
|
+
)
|
|
473
|
+
@click.argument("path", type=click.Path(exists=True))
|
|
474
|
+
@click.option(
|
|
475
|
+
"--detailed",
|
|
476
|
+
is_flag=True,
|
|
477
|
+
help="Show detailed function call statistics",
|
|
478
|
+
)
|
|
479
|
+
def profile_operation(operation: str, path: str, detailed: bool) -> None:
|
|
480
|
+
"""
|
|
481
|
+
Profile a single parsing operation in detail.
|
|
482
|
+
|
|
483
|
+
OPERATION: Type of operation to profile
|
|
484
|
+
PATH: Path to the file to parse
|
|
485
|
+
|
|
486
|
+
This command profiles a single parsing operation and shows
|
|
487
|
+
execution time, memory usage, and optionally detailed function statistics.
|
|
488
|
+
"""
|
|
489
|
+
operation_map = {
|
|
490
|
+
"recipe": parse_recipe,
|
|
491
|
+
"attributes": parse_attributes,
|
|
492
|
+
"resource": parse_custom_resource,
|
|
493
|
+
"template": parse_template,
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
func = operation_map[operation]
|
|
497
|
+
|
|
498
|
+
try:
|
|
499
|
+
click.echo(f"Profiling {operation} parsing: {path}")
|
|
500
|
+
|
|
501
|
+
if detailed:
|
|
502
|
+
from souschef.profiling import detailed_profile_function
|
|
503
|
+
|
|
504
|
+
_, profile_result = detailed_profile_function(func, path)
|
|
505
|
+
click.echo(str(profile_result))
|
|
506
|
+
if profile_result.function_stats.get("top_functions"):
|
|
507
|
+
click.echo("\nDetailed Function Statistics:")
|
|
508
|
+
click.echo(profile_result.function_stats["top_functions"])
|
|
509
|
+
else:
|
|
510
|
+
_, profile_result = profile_function(func, path)
|
|
511
|
+
click.echo(str(profile_result))
|
|
512
|
+
|
|
513
|
+
except Exception as e:
|
|
514
|
+
click.echo(f"Error profiling operation: {e}", err=True)
|
|
515
|
+
sys.exit(1)
|
|
516
|
+
|
|
517
|
+
|
|
428
518
|
def main() -> NoReturn:
|
|
429
519
|
"""Run the CLI."""
|
|
430
520
|
cli()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Chef to Ansible converters."""
|
|
2
|
+
|
|
3
|
+
from souschef.converters.habitat import (
|
|
4
|
+
convert_habitat_to_dockerfile,
|
|
5
|
+
generate_compose_from_habitat,
|
|
6
|
+
)
|
|
7
|
+
from souschef.converters.playbook import (
|
|
8
|
+
analyze_chef_search_patterns,
|
|
9
|
+
convert_chef_search_to_inventory,
|
|
10
|
+
generate_dynamic_inventory_script,
|
|
11
|
+
generate_playbook_from_recipe,
|
|
12
|
+
)
|
|
13
|
+
from souschef.converters.resource import convert_resource_to_task
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"convert_resource_to_task",
|
|
17
|
+
"generate_playbook_from_recipe",
|
|
18
|
+
"convert_chef_search_to_inventory",
|
|
19
|
+
"generate_dynamic_inventory_script",
|
|
20
|
+
"analyze_chef_search_patterns",
|
|
21
|
+
"convert_habitat_to_dockerfile",
|
|
22
|
+
"generate_compose_from_habitat",
|
|
23
|
+
]
|