experiment.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:Dallinger 作者: Dallinger 项目源码 文件源码
def choice(node_id, choice):
    from models import Agent
    try:
        exp = MCMCP(db.session)
        node = Agent.query.get(node_id)
        infos = node.infos()

        if choice == 0:
            info = max(infos, key=attrgetter("id"))
        elif choice == 1:
            info = min(infos, key=attrgetter("id"))
        else:
            raise ValueError("Choice must be 1 or 0")

        info.chosen = True
        exp.save()

        return Response(
            status=200,
            mimetype='application/json')
    except Exception:
        return Response(
            status=403,
            mimetype='application/json')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号