Exemplo n.º 1
0
    def get(self, request, nnid, type):
        """
        - desc : return network data format information
        """
        #get_network_config
        try:
            result_temp = netconf.get_network_config(nnid)

            datadesc = netconf.load_ori_format(nnid)
            result_datadesc_source = json.loads(datadesc)
            result = dict()

            if type == "cell_feature":
                result = result_datadesc_source["cell_feature"]
            elif type == "label":
                result = result_datadesc_source["label"]
            elif type == "all":
                result = result_datadesc_source["cell_feature"]
                result.update(result_datadesc_source["label"])
            elif type == "labels":
                result = data.ImageManager().get_label_list(nnid)
            return_data = {"status": "200", "result": result}
            return Response(json.dumps(return_data))
        except Exception as e:
            return_data = {"status": "400", "result": str(e)}
            return Response(json.dumps(return_data))
Exemplo n.º 2
0
    def put(self, request, baseid):
        """
        - desc : rename table
        - Request json data example \n
        <texfield>
            <font size = 1>

                {"origin" : "A" ,
                 "modify" : "B"}
            </font>
        </textfield>
            ---
            parameters:
            - name: body
              paramType: body
              pytype: json
        """
        try:
            json_data = json.loads(request.body)
            result = data.ImageManager().rename_table(baseid,
                                                      json_data['origin'],
                                                      json_data['modify'])
            return_data = {"status": "200", "result": result}
            return Response(json.dumps(return_data))
        except Exception as e:
            return_data = {"status": "400", "result": str(e)}
            return Response(json.dumps(return_data))
Exemplo n.º 3
0
    def post(self, request, baseid, table, label, nnid):
        """
        - desc : insert data into table
        - Request json data example \n
            <texfied>
            <font size = 1>

               <form action="/api/v1/type/dataframe/base/scm/table/tb_test_incomedata_wdnn3/data/CSV/"
                     method="post"
                     enctype="multipart/form-data">
            </font>
            </textfield>
            ---
            parameters:
            - name: body
              paramType: body
              pytype: json
        """
        try:
            logger.tfmsa_logger("start uploading image on hdfs")
            if len(request.FILES.keys()) > 0:
                data_count = data.ImageManager().put_data(
                    baseid, table, label, request.FILES, nnid)
            netconf.set_on_data(nnid)
            return_data = {"status": "200", "result": data_count}
            return Response(json.dumps(return_data))
        except Exception as e:
            return_data = {"status": "404", "result": str(e)}
            return Response(json.dumps(return_data))
Exemplo n.º 4
0
 def get(self, request):
     """
     - desc : return all database names
     """
     try:
         result = data.ImageManager().search_all_database()
         return_data = {"status": "200", "result": result}
         return Response(json.dumps(return_data))
     except Exception as e:
         return_data = {"status": "400", "result": str(e)}
         return Response(json.dumps(return_data))
Exemplo n.º 5
0
 def post(self, request, baseid):
     """
     - desc : create data base with given name
     """
     try:
         result = data.ImageManager().create_database(baseid)
         return_data = {"status": "200", "result": result}
         return Response(json.dumps(return_data))
     except Exception as e:
         return_data = {"status": "400", "result": str(e)}
         return Response(json.dumps(return_data))
Exemplo n.º 6
0
 def delete(self, request, baseid, table):
     """
     -desc : delete table
     """
     try:
         result = data.ImageManager().delete_table(baseid, table)
         return_data = {"status": "200", "result": result}
         return Response(json.dumps(return_data))
     except Exception as e:
         return_data = {"status": "400", "result": str(e)}
         return Response(json.dumps(return_data))
Exemplo n.º 7
0
 def get(self, request, baseid, table, label):
     """
     - desc : get image file list \n
     """
     try:
         result = data.ImageManager().search_database(baseid)
         return_data = {"status": "200", "result": result}
         return Response(json.dumps(return_data))
     except Exception as e:
         return_data = {"status": "404", "result": str(e)}
         return Response(json.dumps(return_data))
Exemplo n.º 8
0
 def get(self, request, nnid):
     """
     - desc : get image file list \n
     """
     try:
         result = data.ImageManager().get_preview_list(nnid)
         return_data = {"status": "200", "result": result}
         print(json.dumps(return_data))
         return Response(json.dumps(return_data))
     except Exception as e:
         return_data = {"status": "404", "result": str(e)}
         return Response(json.dumps(return_data))
Exemplo n.º 9
0
 def delete(self, request, nnid, label):
     """
     - desc : delete label info \n
     """
     try:
         result = data.ImageManager().delete_label_list(nnid, label)
         return_data = {"status": "200", "result": result}
         print(json.dumps(return_data))
         return Response(json.dumps(return_data))
     except Exception as e:
         return_data = {"status": "404", "result": str(e)}
         return Response(json.dumps(return_data))
Exemplo n.º 10
0
    def put(self, request, baseid, table, label):
        """
        - load image byte array \n
        <textfield>
        <font size = 1>

            [<from>, <to>]
        </font>
        </textfield>
        ---
        parameters:
        - name: body
          paramType: body
          pytype: json
        """
        try:
            pointer = json.loads(str(request.body, 'utf-8'))
            result = data.ImageManager().load_data(baseid, table, pointer[0],
                                                   pointer[1])
            return_data = {"status": "200", "result": result}
            return Response(result)
        except Exception as e:
            return_data = {"status": "404", "result": str(e)}
            return Response(json.dumps(return_data))