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()))
评论列表
文章目录