common_hooks.py 文件源码

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

项目:kge-server 作者: vfrico 项目源码 文件源码
def dataset_trained_status(req, resp, resource, params):
    """Raises an error if dataset is not on an trained state
    Must be executed after check_dataset_exsistence. This will not inform
    about dataset existence, instead will return an undefined error.

    If query param ignore_status is true, it will not raise any error
    """
    status, dataset_dto = _get_dataset_status(params['dataset_id'])
    ignore_status = req.get_param_as_bool("ignore_status")
    # Trained status is 0b0010.
    # The status must be pair for the task to be finished
    if status & 0b0010 != 0 and status & 0b0001 != 0 and not ignore_status:
        raise falcon.HTTPConflict(
            title="The dataset is not in a correct state",
            description=("The dataset {id} has an status {status}, which "
                         "is not valid to generate an index. Required is 1 "
                         ).format(**dataset_dto.to_dict()))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号