中级
构建服务依赖调用图
未完成
中级参考
代码结构已给出,请填写 ____ 处
def solve():
from pyodide.http import open_url
from io import StringIO
trace_logs_csv = open_url(____).read()
routing_rules_csv = open_url(____).read()
import pandas as pd
from io import StringIO
traces = pd.read_csv(StringIO(____))
rules = pd.read_csv(StringIO(____))
dep_graph = {}
for tid, grp in traces.groupby(____):
span_svc = dict(zip(____))
for _, row in grp.iterrows():
if pd.notna(____) and row['____'] != '____':
parent_svc = span_svc.get(____)
child_svc = row['____']
if parent_svc and parent_svc != child_svc:
dep_graph.setdefault(parent_svc, set()).add(____)
print(____)
for caller, callees in sorted(dep_graph.items()):
print(____)
print(____)
for _, r in rules.iterrows():
print(____)
示例
输入
solve()
期望输出
服务依赖图 (caller -> callees): api-gateway -> ['order-service', 'payment-service', 'user-service'] 路由规则中的依赖: gateway --[/api/v1/users]--> user-service gateway --[/api/v1/products]--> product-service gateway --[/api/v1/orders]--> order-service gateway --[/api/v1/payments]--> payment-service gateway --[/api/v1/search]--> search-service gateway --[/api/v2/users]--> user-service
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199