Skip to content

Commit 91d4b9b

Browse files
committed
Installation simulation mode fix #103
1 parent 32a52bc commit 91d4b9b

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

cortex/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ def progress_callback(current, total, step):
196196
def _run_simulation(self, software: str) -> int:
197197
"""Run preflight simulation check for installation"""
198198
try:
199-
# Get API key for LLM-powered package info (optional)
200-
api_key = self._get_api_key()
199+
# Get API key for LLM-powered package info (optional).
200+
api_key = os.environ.get('OPENAI_API_KEY') or os.environ.get('ANTHROPIC_API_KEY')
201201
provider = self._get_provider() if api_key else 'openai'
202202

203203
# Create checker with optional API key for enhanced accuracy

cortex/preflight_checker.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ def _get_package_info_from_llm(self, software: str, os_info: Dict[str, str]) ->
318318

319319
try:
320320
# Create a specific prompt for package information
321-
distro = os_info.get('distro', 'Ubuntu')
322321
distro_id = os_info.get('distro_id', 'ubuntu')
323322

324323
prompt = f"""Get {software} package information for Linux {distro_id}.
@@ -466,7 +465,6 @@ def check_software(self, software_name: str) -> PackageInfo:
466465

467466
def calculate_requirements(self, software: str) -> None:
468467
"""Calculate installation requirements based on software to install"""
469-
software_lower = software.lower()
470468

471469
# Calculate total download and disk requirements
472470
total_download = 0
@@ -526,7 +524,7 @@ def run_all_checks(self, software: str = "docker") -> PreflightReport:
526524
def format_report(report: PreflightReport, software: str) -> str:
527525
"""Format the preflight report for display"""
528526
lines = []
529-
lines.append(f"\n🔍 Simulation mode: No changes will be made\n")
527+
lines.append("\n🔍 Simulation mode: No changes will be made\n")
530528

531529
# Check if using estimates
532530
using_estimates = any('estimate' in str(pkg.get('size_mb', '')) for pkg in report.packages_to_install)
@@ -541,7 +539,7 @@ def format_report(report: PreflightReport, software: str) -> str:
541539

542540
# What would be installed
543541
if report.packages_to_install:
544-
lines.append(f"\nWould install:")
542+
lines.append("\nWould install:")
545543
for pkg in report.packages_to_install:
546544
lines.append(f" - {pkg['name']} {pkg.get('version', '')} ({pkg.get('size_mb', '?')} MB)")
547545

@@ -595,11 +593,8 @@ def export_report(report: PreflightReport, filepath: str) -> None:
595593

596594
# Convert dataclass to dict
597595
report_dict = asdict(report)
598-
599-
# Convert DiskInfo, PackageInfo, ServiceInfo to dicts
600-
report_dict['disk_usage'] = [asdict(d) for d in report.disk_usage]
601-
report_dict['package_status'] = [asdict(p) for p in report.package_status]
602-
report_dict['service_status'] = [asdict(s) for s in report.service_status]
603-
596+
597+
# `asdict` already converts nested dataclasses recursively, so we can
598+
# directly write the result to JSON.
604599
with open(filepath, 'w') as f:
605600
json.dump(report_dict, f, indent=2)

0 commit comments

Comments
 (0)