Ejemplo n.º 1
0
    def post(self):

        print('GroupAddAPI\n\n')

        parser = reqparse.RequestParser()
        parser.add_argument('config', type=dict, location='json', required=True)
        args = parser.parse_args()
        newGroupName = args.config['groupName']

        myPath = os.path.dirname(os.path.abspath(__file__))
        groupDBRootPath = os.path.join("\\".join(myPath.split('\\')[:-5]), "database\\groupdb")
        newGroupPath = os.path.join(groupDBRootPath, newGroupName+".json")

        Group.create(name=newGroupName, groupPath=newGroupPath).commit()

        defaultGraph=\
        {
            "graph":{
                "nodes":[],
                "edges":[],
            }
        }

        with open(newGroupPath, 'w') as groupJsonFile :
            json.dump(defaultGraph, groupJsonFile)


        return '', status.HTTP_200_OK
Ejemplo n.º 2
0
import json

myPath = os.path.dirname(os.path.abspath(__file__))
modelDBRootPath = os.path.join("\\".join(myPath.split('\\')[:-1]),
                               "database\\modeldb")
modelDBJsonList = os.listdir(modelDBRootPath)
for JsonName in modelDBJsonList:
    Neuron.create(name=JsonName.split('.')[0],
                  modelPath=os.path.join(modelDBRootPath, JsonName))

groupDBRootPath = os.path.join("\\".join(myPath.split('\\')[:-1]),
                               "database\\groupdb")
groupDBJsonList = os.listdir(groupDBRootPath)
for JsonName in groupDBJsonList:
    Group.create(name=JsonName.split('.')[0],
                 groupPath=os.path.join(groupDBRootPath, JsonName))

networkDBRootPath = os.path.join("\\".join(myPath.split('\\')[:-1]),
                                 "database\\networkdb")
networkDBJsonList = os.listdir(networkDBRootPath)
for JsonName in networkDBJsonList:
    Network.create(name=JsonName.split('.')[0],
                   networkPath=os.path.join(networkDBRootPath, JsonName))

initialGraphs = [
    {
        "name": "e^x-1",
        "parameter": {
            0: {
                "id": 0,
                "name": "x^5",