Beispiel #1
0
class Jobs(Resource):
    parser = api.parser()
    parser.add_argument('page_size',
                        required=False,
                        type=str,
                        help="Job Listing Pagination Size")
    parser.add_argument('offset',
                        required=False,
                        type=str,
                        help="Job Listing Pagination Offset")

    def get(self, username):
        """
        This will return run a list of jobs for a specified user
        :return:
        """
        # request_xml = request.data
        # job_id = ogc.parse_status_request(request_xml)
        try:
            logging.info("Finding jobs for user: {}".format(username))
            size = request.form.get('page_size',
                                    request.args.get('page_size', 100))
            offset = request.form.get('offset', request.args.get('offset', 0))
            response = hysds.get_mozart_jobs(username=username,
                                             page_size=size,
                                             offset=offset)
            job_list = response.get("result")
            logging.info("Found Jobs: {}".format(job_list))
            response_body = dict()
            response_body["code"] = 200
            response_body["jobs"] = job_list
            response_body["message"] = "success"
            """
                        <?xml version="1.0" encoding="UTF-8"?>
                        <Jobs>
                        <Job>
                            <JobID></JobID>
                            <JobStatus></JobStatus>
                            <JobType></JobType>
                            <JobParams></JobParams>
                        </Job>
                        <Job>...</Job>
                        <Job>...</Job>
                        ...
                        <Jobs>
            """
            return response_body
        except Exception as ex:
            return Response(ogc.get_exception(type="FailedGetJobs", origin_process="GetJobs",
                                              ex_message="Failed to get jobs for user {}. " \
                                              " please contact administrator " \
                                              "of DPS".format(username)), mimetype='text/xml', status=500)
from flask_restplus import Resource
from werkzeug.datastructures import FileStorage
from flask import current_app as app
from ..models import timeplan_item

from api.restplus import api

ns = api.namespace(
    'timeplan',
    description='Operations related to the injection timeplan of the host')

timeplan_parser = api.parser()
timeplan_parser.add_argument('timeplan',
                             location='files',
                             type=FileStorage,
                             required=True)


@ns.route('/')
class HostTimePlan(Resource):
    @api.doc(responses={
        200: 'Timeplan has been returned.',
        400: 'No Timeplan exists.'
    })
    @api.marshal_with(timeplan_item)
    def get(self):
        """
        Returns the currently injected timeplan as JSON Object.
        """
        AnomalyEngine = app.config['AnomalyEngine']
        timeplan = AnomalyEngine.timeplan
Beispiel #3
0
from flask_restplus import Resource, fields
from api.restplus import api
from api.ende.logic.tf_client import make_prediction
from werkzeug.datastructures import FileStorage
from nltk import sent_tokenize

# create dedicated namespace for ENDE client
ns = api.namespace(
    'ende_client',
    description=
    'Operations for Translating the ende model using the sentence piece model')

# Flask-RestPlus specific parser for file uploading
UPLOAD_KEY = 'file'
UPLOAD_LOCATION = 'files'
upload_parser = api.parser()
upload_parser.add_argument(UPLOAD_KEY,
                           location=UPLOAD_LOCATION,
                           type=FileStorage,
                           required=True)
text_parser = api.parser()
text_parser.add_argument('text', required=True, help='enter sentences')


@ns.route('/prediction/file')
class EndePredictionFile(Resource):
    @ns.doc(description='input is text file, output json',
            responses={
                200: "Success",
                400: "Bad request",
                500: "Internal server error"
Beispiel #4
0
import logging

from flask import request
from flask_restplus import Resource
from api.restplus import api
from api.gan.logic.tf_serving_client import make_prediction
from werkzeug.datastructures import FileStorage

log = logging.getLogger(__name__)
# create dedicated namespace for GAN client
ns = api.namespace('gan_client', description='Operations for GAN client')

# Flask-RestPlus specific parser for image uploading
UPLOAD_KEY = 'inputs'
UPLOAD_LOCATION = 'files'
upload_parser = api.parser()
upload_parser.add_argument(UPLOAD_KEY,
                           location=UPLOAD_LOCATION,
                           type=FileStorage,
                           required=True)


@ns.route('/prediction')
class GanPrediction(Resource):
    @ns.doc(
        description='Predict the house number on the image using GAN model. ' +
        'Return 3 most probable digits with their probabilities',
        responses={
            200: "Success",
            400: "Bad request",
            500: "Internal server error"
import json

from flask import request
from flask_restplus import Resource
from api.restplus import api
from api.gan.logic.tf_serving_client import make_prediction
from werkzeug.datastructures import FileStorage


# create dedicated namespace for GAN client
ns = api.namespace('gan_client', description='Operations for GAN client')

# Flask-RestPlus specific parser for image uploading
UPLOAD_KEY = 'image'
UPLOAD_LOCATION = 'files'
upload_parser = api.parser()
upload_parser.add_argument(UPLOAD_KEY,
                           location=UPLOAD_LOCATION,
                           type=FileStorage,
                           required=True)


@ns.route('/prediction')
class GanPrediction(Resource):
    @ns.doc(description='Predict the house number on the image using GAN model. ' +
            'Return 3 most probable digits with their probabilities',
            responses={
                200: "Success",
                400: "Bad request",
                500: "Internal server error"
                })
from flask_restplus import Resource, reqparse
from flask import current_app as app
from api.restplus import api
from ..models import wan_simulation
import logging
import json

ns = api.namespace('wan_simulation',
                   description='Simulate a Wide Area Network')

simulation_parser = api.parser()
simulation_parser.add_argument('rate',
                               type=str,
                               required=False,
                               help="Network bandwidth rate")
simulation_parser.add_argument('delay',
                               type=str,
                               required=False,
                               help="Round trip network delay in ms")
simulation_parser.add_argument('delay-distro',
                               type=str,
                               required=False,
                               help="Distribution of network latency")
simulation_parser.add_argument('loss',
                               type=str,
                               required=False,
                               help="Round trip packet loss rate")
simulation_parser.add_argument('duplicate',
                               type=str,
                               required=False,
                               help="Round trip packet duplicate rat")