26Y02x1

Young-Kyoo Kim·7일 전
# 1. 기존 데이터 Parquet 로드
        df_pod      = pd.read_parquet(p1)
        df_ns       = pd.read_parquet(p2)
        df_daily_ns = pd.read_parquet(p3)

        # ─── 🎯 [최종 통합 완결 패치] 모든 하방 시트의 KeyError를 여기서 종결 ───
        
        # [공통] cluster 컬럼 누락 방어 주입
        if 'cluster' not in df_pod.columns:
            df_pod['cluster'] = infra_tag
        if 'cluster' not in df_daily_ns.columns:
            df_daily_ns['cluster'] = infra_tag

        # 💡 [3번 탭 패치 흡수] pv_used_p95 명명 규칙 보정 및 기본값 방어
        if "pv_used_p95" not in df_pod.columns:
            if "pv_usage_p95" in df_pod.columns:
                df_pod["pv_used_p95"] = df_pod["pv_usage_p95"]
            else:
                df_pod["pv_used_p95"] = 0.0  # PV 메트릭이 없는 노드 환경 대비
        if "pv_capacity_max" not in df_pod.columns:
            df_pod["pv_capacity_max"] = 0.0

        # [5번 탭 대응] minutes_running 실행 시간 컬럼명 변형 방어
        if "minutes_running" not in df_pod.columns:
            for alt_col in ["duration_minutes", "running_minutes", "duration"]:
                if alt_col in df_pod.columns:
                    df_pod["minutes_running"] = df_pod[alt_col]
                    break
            else:
                df_pod["minutes_running"] = 0
                
        # [6번 탭 대응] mem_allocated_gb_hours 변형 방어
        if "mem_allocated_gb_hours" not in df_pod.columns:
            for alt_col in ["mem_alloc_gb_hours", "mem_alloc_gh", "memory_allocated_gb_hours"]:
                if alt_col in df_pod.columns:
                    df_pod["mem_allocated_gb_hours"] = df_pod[alt_col]
                    break
                    
        # [6번 탭 대응] pv_allocated_gb_hours 변형 방어
        if "pv_allocated_gb_hours" not in df_pod.columns:
            for alt_col in ["pv_alloc_gb_hours", "pv_alloc_gh", "pv_capacity_gb_hours", "pv_capacity_max"]:
                if alt_col in df_pod.columns:
                    df_pod["pv_allocated_gb_hours"] = df_pod[alt_col]
                    break

        # ─── 🏁 방어 레이어 마감 후 엑셀 컴파일 및 시트 빌드 로직 정상 진행 ───
        excel_name = f"res_usage_report_{infra_tag.lower()}_{date_tag}.xlsx"
        # ... (이하 동일) ...

0개의 댓글