def obtener_progresion_lineal(AnioPrediccion, body):

    #def obtener_progresion_lineal_anio_cantidad(AnioPrediccion, body):
    """
    Obtener la prediccion para un año dado el año a predecir y los datos de varios años anteriores
    Obtener la prediccion para un año dado el año a predecir y los datos de varios años anteriores
    :param AnioPrediccion: Año para predecir la cantidad
    :type AnioPrediccion: str
    :param body: Datos de entrada obtenidos previamente
    :type body: list | bytes

    :rtype: int
    """
    prediccionCantidad = -1
    if connexion.request.is_json:
        body = [Body1.from_dict(d) for d in connexion.request.get_json()]
        lista = list()

        print(body)
        for item in body:
            if (hasattr(item, 'anio') and hasattr(item, 'cantidad')):
                tupla = (item.anio, item.cantidad)
            lista.append(tupla)
        prediccionCantidad = tensorflow.ObtenerProgresionLineal(
            lista, int(AnioPrediccion))

    return int(prediccionCantidad)
Exemplo n.º 2
0
    def test_towdata_put(self):
        """Test case for towdata_put

        Uploads live data to the server for predicition
        """

        update_file = "C:/Users/21ale/Documents/CLASE/TFG/TFG-proyect/TFG-web/server/swagger_server/test/test-files/updateTest.csv"
        test_file = "C:/Users/21ale/Documents/CLASE/TFG/TFG-proyect/TFG-web/server/swagger_server/test/test-files/appendedUpdateTest.csv"
        retrieved_file = "C:/Users/21ale/Documents/CLASE/TFG/TFG-proyect/TFG-web/server/swagger_server/database/savefile.csv"

        with open(update_file, 'r') as myfile:
            data = myfile.read()
            body = Body1(1, data)
        response = self.client.open(
            '/towdata',
            method='PUT',
            data=json.dumps(body),
            content_type='application/json')

        default_controller.towdata_put(body.csv)
        md5hasher = FileHash("md5")

        expected_hash = md5hasher.hash_file(test_file)
        obtained_hash = md5hasher.hash_file(retrieved_file)
        self.assertEqual(expected_hash, obtained_hash)
    def test_add_party(self):
        """Test case for add_party

        Добавить заявку на участие в мероприятие
        """
        body = Body1()
        response = self.client.open('/v2/event',
                                    method='PUT',
                                    data=json.dumps(body),
                                    content_type='application/json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))
Exemplo n.º 4
0
    def test_feedback(self):
        """Test case for feedback

        良いか悪いかをユーザーが判断
        """
        body = Body1()
        response = self.client.open('/api/feedback',
                                    method='POST',
                                    data=json.dumps(body),
                                    content_type='application/json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))
Exemplo n.º 5
0
    def test_towdata_post(self):
        """Test case for towdata_post

        uploads data to train and predict over
        """
        body = Body1()
        response = self.client.open('/towdata',
                                    method='POST',
                                    data=json.dumps(body),
                                    content_type='application/json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))
    def test_get_trainings_search_results(self):
        """Test case for get_trainings_search_results

        Get trainings search results
        """
        body = Body1()
        response = self.client.open('/trainings/search',
                                    method='POST',
                                    data=json.dumps(body),
                                    content_type='application/json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))
Exemplo n.º 7
0
    def test_update_sm_context(self):
        """Test case for update_sm_context

        Update SM Context
        """
        body = Body1()
        response = self.client.open(
            '/nsmf-pdusession/v1/sm-contexts/{smContextRef}/modify'.format(sm_context_ref='sm_context_ref_example'),
            method='POST',
            data=json.dumps(body),
            content_type='application/json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))
Exemplo n.º 8
0
def add_party(body):  # noqa: E501
    """Добавить заявку на участие в мероприятие

     # noqa: E501

    :param body: Подать заявку на участие в мероприятиях от добровольцев России
    :type body: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = Body1.from_dict(connexion.request.get_json())  # noqa: E501
    return 'do some magic!'
    def test_create_station(self):
        """Test case for create_station

        create a new station
        """
        body = Body1()
        response = self.client.open(
            '/ayhanyunt12/MeteorolojiAPI/1.0.0/station',
            method='POST',
            data=json.dumps(body),
            content_type='application/json')
        self.assert200(response,
                       'Response body is : ' + response.data.decode('utf-8'))
Exemplo n.º 10
0
    def test_add_pet(self):
        """
        Test case for add_pet

        Add a new pet to the store
        """
        body = Body1()
        response = self.client.open('/v2/pet',
                                    method='POST',
                                    data=json.dumps(body),
                                    content_type='application/json')
        self.assert200(response,
                       "Response body is : " + response.data.decode('utf-8'))
    def test_catalog_product_website_link_repository_v1_save_put(self):
        """
        Test case for catalog_product_website_link_repository_v1_save_put

        
        """
        body = Body1()
        response = self.client.open(
            '/v2/v1/products/{sku}/websites'.format(sku='sku_example'),
            method='PUT',
            data=json.dumps(body),
            content_type='application/json')
        self.assert200(response,
                       "Response body is : " + response.data.decode('utf-8'))
Exemplo n.º 12
0
def towdata_post(body):  # noqa: E501
    """uploads data to train and predict over

    The body should be in .csv format so the server can read it # noqa: E501

    :param body: 
    :type body: dict | bytes

    :rtype: None
    """

    body = Body1.from_dict(connexion.request.get_json())  # noqa: E501
    SaveData.save(SaveData, body.csv)
    return "Done!"
def catalog_product_website_link_repository_v1_save_put(sku, body=None):
    """
    catalog_product_website_link_repository_v1_save_put
    Assign a product to the website
    :param sku: 
    :type sku: str
    :param body: 
    :type body: dict | bytes

    :rtype: bool
    """
    if connexion.request.is_json:
        body = Body1.from_dict(connexion.request.get_json())
    return 'do some magic!'
def feedback(body):  # noqa: E501
    """良いか悪いかをユーザーが判断

     # noqa: E501

    :param body: 
    :type body: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        body = Body1.from_dict(connexion.request.get_json())  # noqa: E501

    if rslt := redis.get(body.url):
        with open(f"{__main__.DATA_PATH}/feedback.csv", mode="a") as f:
            f.writelines([
                body.url, ", ",
                str(body.user_evaluation), ", ",
                rslt.decode(), "\n"
            ])
def obtener_outliers_inliers_anios_cantidad(AnioInicio, AnioFin, Metodo,
                                            body):  #OK
    """
    Obtener los valores fuera de lo comun dado unos valores iniciales y unos valores a tratar
    Obtener los valores fuera de lo comun dado unos valores iniciales y unos valores a tratar
    :param AnioInicio: Año inicial de la matriz de datos
    :type AnioInicio: str
    :param AnioFin: Año final de la matriz de datos,  Año final de la matriz de datos, año desde el cual obtenemos los datos a probar
    :type AnioFin: str
    :param Metodo: Metodo a usar para obtener los outliers
    :type Metodo: str
    :param body: Datos de entrada obtenidos previamente
    :type body: list | bytes

    :rtype: Dict[str, int]
    """
    if connexion.request.is_json:
        body = [Body1.from_dict(d) for d in connexion.request.get_json()]

        listaLabels = list()
        listaLabels.append('Anio')
        listaLabels.append('Cantidad')
        listaValores, listaValoresAComprobar, listaValoresCentrales = conversor.separarValoresBody(
            body, AnioFin)

        #        print(listaValoresAComprobar)
        matriz, listaColumnas = conversor.ConvertirTuplasToMatriz(
            listaValores, listaLabels)
        #        print(matriz)
        listaValoresOutliers, listaValoresInliers = outliers.ObtenerOutliersDadaMatrizAniosYTipo(
            matriz, AnioInicio, AnioFin, listaValoresAComprobar, listaLabels,
            Metodo)

        outliers.MostrarOutliersMedianteEnvolturaElipticaDadosDatos(
            matriz, AnioInicio, AnioFin, listaValoresAComprobar, listaLabels,
            listaColumnas)

        return conversor.ObtenerJSONDeListasOutliersInliers(
            listaValoresInliers, listaValoresOutliers, listaLabels,
            listaValoresCentrales)
def get_trainings_search_results(body=None):  # noqa: E501
    """Search employee' results

    Get training search results # noqa: E501

    :param body: 
    :type body: dict | bytes

    :rtype: Trainings
    """
    if connexion.request.is_json:
        body = Body1().from_dict(connexion.request.get_json())
        #body = Body1.from_dict(connexion.request.get_json())  # noqa: E501

    #接続情報の作成
    engine = sqlalchemy.create_engine(
        'postgresql://*****:*****@wakupy-db.csw5cdbrfmzu.ap-northeast-1.rds.amazonaws.com/omurice'
    )

    # クエリの作成
    query = "SELECT * FROM public.m_training WHERE 1=1"

    #検索条件にtraining_nameが指定された場合
    if not body.training_name:
        pass
    else:
        query += " AND training_name like '%%{}%%'".format(body.training_name)

    #検索条件にtraining_classが指定された場合(チェックボックス)
    if not body.training_class:
        pass
    else:
        for index, training_class in enumerate(body.training_class):
            if index == 0:
                query += " AND training_class in ('{}'".format(training_class)
            else:
                query += " ,'{}'".format(training_class)

        query += ")"

    #検索条件にskill_classが指定された場合(チェックボックス)
    if not body.skill_class:
        pass
    else:
        for index, skill in enumerate(body.skill_class):
            if index == 0:
                query += " AND skill_class in ('{}'".format(skill)
            else:
                query += " ,'{}'".format(skill)

        query += ")"

    #検索条件にit_levelが指定された場合(チェックボックス)
    if not body.it_level:
        pass
    else:
        for index, it_level in enumerate(body.it_level):
            if index == 0:
                query += " AND it_level in ('{}'".format(it_level)
            else:
                query += " ,'{}'".format(it_level)

        query += ")"

    #検索条件にrecruitment_num_fromが指定された場合
    if not body.recruitment_num_from:
        pass
    else:
        query += " AND recruitment_numbers >= '{}'".format(
            body.recruitment_num_from)

    #検索条件にrecruitment_num_toが指定された場合
    if not body.recruitment_num_to:
        pass
    else:
        query += " AND recruitment_numbers <= '{}'".format(
            body.recruitment_num_to)

    #検索条件にnew_flgが指定された場合(チェックボックス)
    if not body.new_flg:
        pass
    else:
        for index, new_flg in enumerate(body.new_flg):
            if index == 0:
                query += " AND new_training_flg in ('{}'".format(new_flg)
            else:
                query += " ,'{}'".format(new_flg)

        query += ")"

    #検索条件にselection_flgが指定された場合(チェックボックス)
    if not body.selection_flg:
        pass
    else:
        for index, selection_flg in enumerate(body.selection_flg):
            if index == 0:
                query += " AND selection_flg in ('{}'".format(selection_flg)
            else:
                query += " ,'{}'".format(selection_flg)

        query += ")"

    #検索条件にstart_dateが指定された場合
    if not body.start_date:
        pass
    else:
        query += " AND tstart_date = '{}'".format(body.start_date)

    #検索条件にend_dateが指定された場合
    if not body.end_date:
        pass
    else:
        query += " AND end_date = '{}'".format(body.end_date)

    #クエリの実行
    result = engine.execute(query)

    #結果を格納するリストの作成
    trainings = []
    trainings_inner = TrainingsInner()

    for row in result:
        trainings_inner.training_name = row['training_name']
        trainings_inner.training_class = row['training_class']
        trainings_inner.skill_class = row['skill_class']
        trainings_inner.it_level = row['it_level']
        trainings_inner.recruitment_num = row['recruitment_numbers']
        trainings_inner.participation_num = row['participation_numbers']
        trainings_inner.new_flg = row['new_training_flg']
        trainings_inner.selection_flg = row['selection_flg']
        trainings_inner.start_date = row['start_date']
        trainings_inner.end_date = row['end_date']

        trainings.append(copy.copy(trainings_inner))

    #接続クローズ
    result.close()

    return trainings