datasets.py 文件源码

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

项目:kge-server 作者: vfrico 项目源码 文件源码
def on_post(self, req, resp, dataset_id, dataset_dto, entities):
        """Get the embedding given an entity or a list of entities (URI)

        {"entities": ["Q1492", "Q2807", "Q1"]}

        :param integer dataset_id: Unique ID of dataset
        :param integer dataset_dto: Dataset DTO (from hook)
        :param list entities: List of entities to get embeddings (from hook)
        :returns: A list of list with entities and its embeddings
        :rtype: list
        """

        istrained = dataset_dto.is_trained()
        if istrained is None or not istrained:
            raise falcon.HTTPConflict(
                title="Dataset has not a valid state",
                description="Dataset {} has a {} state".format(
                    dataset_id, dataset_dto.status))

        try:
            result = async_tasks.find_embeddings_on_model(dataset_id, entities)
        except OSError as err:
            filerr = err.filename
            raise falcon.HTTPNotFound(
                title="The file on database couldn't be located",
                description=("A file ({}) has been found on database, but it "
                             "does not exist on filesystem").format(filerr))

        textbody = {"embeddings": result}
        resp.body = json.dumps(textbody)
        resp.status = falcon.HTTP_200
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号