Exemplo n.º 1
0
    def getDetectServicePageList(self, pageItem):

        totalCount = detectServiceBean.objects(
            userId=session.get("userId"),
            state=ConstantUtils.DATA_STATUS_ACTIVE).count()
        #select_related()

        collection = detectServiceBean._get_collection()

        resultList = collection.aggregate([{
            '$lookup': {
                "from": "detect_model_bean",
                "localField": "dmBean",
                "foreignField": "_id",
                "as": "model"
            },
        }, {
            '$lookup': {
                "from": "detect_model_train_version",
                "localField": "dmtvBean",
                "foreignField": "_id",
                "as": "modelVersion"
            },
        }, {
            '$match': {
                "userId": session.get("userId"),
                "state": ConstantUtils.DATA_STATUS_ACTIVE
            }
        }, {
            '$project': {
                'dtsName': 1,
                'dtsSwitch': 1,
                "dtsSecretKey": 1,
                "create_date": 1,
                'model.dmName': 1,
                'model.dmType': 1,
                'modelVersion.dmtvName': 1,
                'dmId': 1,
                'dmtvId': 1,
                "dtsServiceKey": 1,
                "dtsSecret": 1
            },
        }, {
            "$sort": {
                "create_date": -1
            }
        }, {
            "$skip": pageItem.skipIndex
        }, {
            "$limit": pageItem.pageSize
        }])

        pageItem.set_totalCount(totalCount)

        print(type(resultList))

        pageItem.set_numpy_dataList(list(resultList))

        return resultPackerUtils.packPageResult(pageItem)
Exemplo n.º 2
0
    def getDetectServiceDetail(self, jsonData):

        detectService = detectServiceBean.objects(
            dtsid=jsonData['dtsid'],
            state=ConstantUtils.DATA_STATUS_ACTIVE).exclude(
                "create_date", "state")

        return resultPackerUtils.packDataItemResults(detectService.to_json(),
                                                     "dtsid")
Exemplo n.º 3
0
    def delDetectService(self, jsonData):

        detectServiceIns = detectServiceBean.objects(dtsid=jsonData['dtsid'])

        #释放模型资源
        yoloDetectServiceImpl.releaseYoloDetectService(
            detectServiceIns["dtsServiceKey"])

        detectServiceIns.update(state=ConstantUtils.DATA_STATUS_DELETED)

        return resultPackerUtils.update_success()
Exemplo n.º 4
0
    def batchInitYoloModel(self):

        loggerUtils.info("init detect model start...")

        detectServiceList = detectServiceBean.objects(
            dtsSwitch=ConstantUtils.SERVICE_SWITCH_ON,
            state=ConstantUtils.DATA_STATUS_ACTIVE)

        for item in detectServiceList:
            if item['dmtvId'] != None:
                yoloDetectServiceImpl.launchYoloDetectService(
                    sessionId=item['dtsServiceKey'], dmtvid=item['dmtvId'])

        loggerUtils.info("init detect model finish***")
Exemplo n.º 5
0
    def changeDtsSwitch(self, jsonData):

        detectServiceIns = detectServiceBean.objects(
            dtsid=jsonData['dtsid'], state=ConstantUtils.DATA_STATUS_ACTIVE)[0]

        if jsonData['dtsSwitch'] == ConstantUtils.SERVICE_SWITCH_ON:
            yoloDetectServiceImpl.launchYoloDetectService(
                sessionId=detectServiceIns["dtsServiceKey"],
                dmtvid=detectServiceIns["dmtvId"])
        else:
            yoloDetectServiceImpl.releaseYoloDetectThread(
                detectServiceIns["dtsServiceKey"])
        #更改数据库状态
        detectServiceIns.update(dtsSwitch=jsonData['dtsSwitch'])

        return resultPackerUtils.update_success()
Exemplo n.º 6
0
    def updateDetectService(self, jsonData):

        detectServiceIns = detectServiceBean.objects(
            dtsid=jsonData['dtsid'], state=ConstantUtils.DATA_STATUS_ACTIVE)
        updateMap = jsonData['updateClolumn']

        updateMap["dmBean"] = detectModelBean.objects(
            dmId=jsonData["updateClolumn"]['dmId'],
            state=ConstantUtils.DATA_STATUS_ACTIVE)[0]

        updateMap['dmtvBean'] = detectModelTrainVersion.objects(
            dmtvid=jsonData["updateClolumn"]["dmtvId"],
            state=ConstantUtils.DATA_STATUS_ACTIVE)[0]

        detectServiceIns.update(**jsonData['updateClolumn'])

        #加载或关闭模型
        self.changeDtsSwitch(jsonData)

        return resultPackerUtils.update_success()