コード例 #1
0
    def export(prediction_id: int):
        prediction = Prediction.get(prediction_id)

        if (prediction):
            stream = prediction.export()

            return stream
        else:
            raise NotFound('Prediction does not exist')
コード例 #2
0
ファイル: project_service.py プロジェクト: rustyb/ml-enabler
 def delete_ml_model(model_id: int):
     """
     Deletes ML model and associated predictions
     :params model_id
     """
     ml_model = Project.get(model_id)
     if ml_model:
         ml_model.delete()
     else:
         raise NotFound("Model does not exist")
コード例 #3
0
    def get_ml_model_by_id(model_id: int):
        """
        Get an ML Model for a given ID
        :params model_id

        :raises NotFound
        :returns ML Model
        """

        ml_model = MLModel.get(model_id)
        if ml_model:
            return ml_model.as_dto()
        else:
            raise NotFound('Model does not exist')
コード例 #4
0
ファイル: token_service.py プロジェクト: rustyb/ml-enabler
    def delete(uid: int, token_id: int):
        """
        Delete an token

        :params token
        """

        token = Token.get(uid, token_id)
        if token:
            token.delete()

            return {"status": "deleted"}
        else:
            raise NotFound("Token Not Found")
コード例 #5
0
    def update_ml_model(updated_ml_model_dto: MLModelDTO) -> int:
        """
        Update an existing ML Model
        :params model_id

        :raises NotFound
        :returns model_id
        """

        ml_model = MLModel.get(updated_ml_model_dto.model_id)
        if (ml_model):
            ml_model.update(updated_ml_model_dto)
            return updated_ml_model_dto.model_id
        else:
            raise NotFound('Model does not exist')
コード例 #6
0
ファイル: token_service.py プロジェクト: rustyb/ml-enabler
    def get(uid: int, token_id: int):
        """
        Fetch information about a given token
        :params token

        :raises NotFound
        :returns imagery
        """

        token = Token.get(uid, token_id).as_dto().to_primitive()

        if token:
            return token.to_primitive()
        else:
            raise NotFound("Token Not Found")
コード例 #7
0
ファイル: project_service.py プロジェクト: rustyb/ml-enabler
    def get_all(uid: int, model_filter: str, model_archived: bool):
        """
        Get all ML Models

        :raises NotFound
        :returns array of ML Models
        """

        ml_models = Project.get_all(uid, model_filter, model_archived)
        if ml_models:
            model_collection = []
            for model in ml_models:
                model_collection.append(model.as_dto().to_primitive())
            return model_collection
        else:
            raise NotFound("No models exist")
コード例 #8
0
    def patch(prediction_id: int, update: dict) -> int:
        """
        Patch a prediction by ID
        :params prediction_id
        :params update
        :returns prediction
        """

        prediction = Prediction.get(prediction_id)

        if (prediction):
            prediction.link(update)

            return prediction_id
        else:
            raise NotFound('Prediction does not exist')
コード例 #9
0
    def get_all():
        """
        Get all ML Models

        :raises NotFound
        :returns array of ML Models
        """

        ml_models = MLModel.get_all()
        if (ml_models):
            model_collection = []
            for model in ml_models:
                model_collection.append(model.as_dto().to_primitive())
            return model_collection
        else:
            raise NotFound('No models exist')
コード例 #10
0
ファイル: project_service.py プロジェクト: rustyb/ml-enabler
    def get_ml_model_by_id(model_id: int):
        """
        Get an ML Model for a given ID
        :params model_id

        :raises NotFound
        :returns ML Model
        """

        ml_model = Project.get(model_id)
        users = ProjectAccess.list(model_id)

        if ml_model:
            model = ml_model.as_dto(users=users)
            return model
        else:
            raise NotFound("Model does not exist")
コード例 #11
0
ファイル: project_service.py プロジェクト: rustyb/ml-enabler
    def update_ml_model(dto: ProjectDTO) -> int:
        """
        Update an existing ML Model
        :params model_id

        :raises NotFound
        :returns model_id
        """

        ml_model = Project.get(dto.model_id)

        if ml_model:
            ml_model.update(dto)

            if dto.users:
                users = ProjectAccess.list(dto.model_id)
                ProjectAccess.list_update(dto.model_id, users, dto.users)

            return dto.model_id
        else:
            raise NotFound("Model does not exist")