Added files field to model info
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		@@ -57,13 +57,13 @@ class CNNView(FlaskView):
 | 
			
		||||
 | 
			
		||||
        return jsonify(self.aimodel_schema.dump(m)), 200
 | 
			
		||||
 | 
			
		||||
    def delete(self, _id: str):
 | 
			
		||||
    def delete(self, id_: str):
 | 
			
		||||
 | 
			
		||||
        if _id == "$default":
 | 
			
		||||
        if id_ == "$default":
 | 
			
		||||
            default = Default.query.filter_by(type=AIModelType.cnn).first_or_404()
 | 
			
		||||
            m = default.aimodel
 | 
			
		||||
        else:
 | 
			
		||||
            m = AIModel.query.filter_by(type=AIModelType.cnn, id=_id).first_or_404()
 | 
			
		||||
            m = AIModel.query.filter_by(type=AIModelType.cnn, id=id_).first_or_404()
 | 
			
		||||
 | 
			
		||||
        storage.connection.remove_object(current_app.config['MINIO_CNN_BUCKET_NAME'], "weights/" + str(m.id))
 | 
			
		||||
        storage.connection.remove_object(current_app.config['MINIO_CNN_BUCKET_NAME'], "model/" + str(m.id))
 | 
			
		||||
@@ -73,14 +73,14 @@ class CNNView(FlaskView):
 | 
			
		||||
 | 
			
		||||
        return '', 204
 | 
			
		||||
 | 
			
		||||
    @route('<_id>/file')
 | 
			
		||||
    def get_file(self, _id: str):
 | 
			
		||||
    @route('<id_>/file')
 | 
			
		||||
    def get_file(self, id_: str):
 | 
			
		||||
 | 
			
		||||
        if _id == "$default":
 | 
			
		||||
        if id_ == "$default":
 | 
			
		||||
            default = Default.query.filter_by(type=AIModelType.cnn).first_or_404()
 | 
			
		||||
            m = default.aimodel
 | 
			
		||||
        else:
 | 
			
		||||
            m = AIModel.query.filter_by(type=AIModelType.cnn, id=_id).first_or_404()
 | 
			
		||||
            m = AIModel.query.filter_by(type=AIModelType.cnn, id=id_).first_or_404()
 | 
			
		||||
 | 
			
		||||
        if "weights" in request.args:
 | 
			
		||||
            path = "weights/" + str(m.id)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
#!/usr/bin/env python3
 | 
			
		||||
from flask import jsonify, abort, request
 | 
			
		||||
from flask import jsonify, abort, request, url_for
 | 
			
		||||
from flask_classful import FlaskView, route
 | 
			
		||||
from marshmallow import ValidationError
 | 
			
		||||
 | 
			
		||||
@@ -47,7 +47,26 @@ class RootView(FlaskView):
 | 
			
		||||
        else:
 | 
			
		||||
            m = AIModel.query.filter_by(type=aimodel_type, id=id_).first_or_404()
 | 
			
		||||
 | 
			
		||||
        return jsonify(self.aimodel_schema.dump(m))
 | 
			
		||||
        # Append download links
 | 
			
		||||
        details = self.aimodel_schema.dump(m)
 | 
			
		||||
 | 
			
		||||
        # Vagy ez, vagy visszateszem a saját view-jébe és duplikálva lesz az egész
 | 
			
		||||
        if aimodel_type == AIModelType.cnn:
 | 
			
		||||
            details.update({
 | 
			
		||||
                "files": {
 | 
			
		||||
                    "model": url_for("CNNView:get_file", id_=m.id),
 | 
			
		||||
                    "weights": url_for("CNNView:get_file", id_=m.id, weights=''),
 | 
			
		||||
                }
 | 
			
		||||
            })
 | 
			
		||||
        elif aimodel_type == AIModelType.svm:
 | 
			
		||||
            details.update({
 | 
			
		||||
                "files": {
 | 
			
		||||
                    "model": url_for("SVMView:get_file", id_=m.id),
 | 
			
		||||
                    "means": url_for("SVMView:get_file", id_=m.id, means=''),
 | 
			
		||||
                }
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
        return jsonify(details)
 | 
			
		||||
 | 
			
		||||
    @json_required
 | 
			
		||||
    @route('/<type_>/$default', methods=['PUT'])
 | 
			
		||||
 
 | 
			
		||||
@@ -96,13 +96,13 @@ class SVMView(FlaskView):
 | 
			
		||||
 | 
			
		||||
        return jsonify(self.aimodel_schema.dump(m)), 200
 | 
			
		||||
 | 
			
		||||
    def delete(self, _id: str):
 | 
			
		||||
    def delete(self, id_: str):
 | 
			
		||||
 | 
			
		||||
        if _id == "$default":
 | 
			
		||||
        if id_ == "$default":
 | 
			
		||||
            default = Default.query.filter_by(type=AIModelType.svm).first_or_404()
 | 
			
		||||
            m = default.aimodel
 | 
			
		||||
        else:
 | 
			
		||||
            m = AIModel.query.filter_by(type=AIModelType.svm, id=_id).first_or_404()
 | 
			
		||||
            m = AIModel.query.filter_by(type=AIModelType.svm, id=id_).first_or_404()
 | 
			
		||||
 | 
			
		||||
        storage.connection.remove_object(current_app.config['MINIO_SVM_BUCKET_NAME'], "means/" + str(m.id))
 | 
			
		||||
        storage.connection.remove_object(current_app.config['MINIO_SVM_BUCKET_NAME'], "model/" + str(m.id))
 | 
			
		||||
@@ -113,14 +113,14 @@ class SVMView(FlaskView):
 | 
			
		||||
        return '', 204
 | 
			
		||||
 | 
			
		||||
    # builtin file proxy
 | 
			
		||||
    @route('<_id>/file')
 | 
			
		||||
    def get_file(self, _id: str):
 | 
			
		||||
    @route('<id_>/file')
 | 
			
		||||
    def get_file(self, id_: str):
 | 
			
		||||
 | 
			
		||||
        if _id == "$default":
 | 
			
		||||
        if id_ == "$default":
 | 
			
		||||
            default = Default.query.filter_by(type=AIModelType.svm).first_or_404()
 | 
			
		||||
            m = default.aimodel
 | 
			
		||||
        else:
 | 
			
		||||
            m = AIModel.query.filter_by(type=AIModelType.svm, id=_id).first_or_404()
 | 
			
		||||
            m = AIModel.query.filter_by(type=AIModelType.svm, id=id_).first_or_404()
 | 
			
		||||
 | 
			
		||||
        if "means" in request.args:
 | 
			
		||||
            path = "means/" + str(m.id)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user