中级
实现服务实例健康检查
未完成
中级参考
代码结构已给出,请填写 ____ 处
def solve():
from pyodide.http import open_url
from io import StringIO
import pandas as pd
reg_csv = open_url(____).read()
traffic_csv = open_url(____).read()
reg = pd.read_csv(StringIO(____))
traffic = pd.read_csv(StringIO(____))
def health_score(____):
inst_traffic = traffic[traffic['____']==instance_id]
if inst_traffic.empty: return ____
success_rate = (____).mean()
avg_latency = inst_traffic['____'].mean()
score = success_rate * ____ - avg_latency * ____
return round(____)
print(____)
for _, row in reg.iterrows():
score = health_score(____)
status = row['____']
print(____)
示例
输入
solve()
期望输出
实例健康评分: di-1 (healthy): score=94.7 di-2 (healthy): score=94.3 di-3 (healthy): score=94.9 ae-1 (healthy): score=0.0 ae-2 (unhealthy): score=0.0 cd-1 (healthy): score=0.0
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199