Skip to content

Commit bfd98b4

Browse files
author
facu.r
committed
remove variable
1 parent f83fef6 commit bfd98b4

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def importModel(self, modelParameters):
110110

111111
import netpyne_geppetto
112112

113-
if modelParameters['jsonModelFolder']=='':
113+
if modelParameters['importFormat']=='py':
114114
# NetParams
115115
netParamsPath = str(modelParameters["netParamsPath"])
116116
sys.path.append(netParamsPath)
@@ -120,13 +120,11 @@ def importModel(self, modelParameters):
120120
# Import Model attributes
121121
netpyne_geppetto.netParams = getattr(netParamsModuleName, str(modelParameters["netParamsVariable"]))
122122

123-
# netpyne.specs.Dict class MUST NOT be allowed for cellParams in the GUI
124-
# if anybody know how to convert in a better way, go ahead...
125-
# take a look at 145-149 and 175 to see different opcions
126-
with open('_.txt', 'w') as file:
127-
file.write(json.dumps(netpyne_geppetto.netParams.cellParams))
128-
with open('_.txt', 'r') as file:
129-
netpyne_geppetto.netParams.cellParams = json.load(file)
123+
for key, value in netpyne_geppetto.netParams.cellParams.iteritems():
124+
if hasattr(value, 'todict'):
125+
print('it has')
126+
sys.stdout.flush()
127+
netpyne_geppetto.netParams.cellParams[key] = value.todict()
130128

131129
# SimConfig
132130
simConfigPath = str(modelParameters["simConfigPath"])
@@ -136,22 +134,22 @@ def importModel(self, modelParameters):
136134
simConfigModuleName = importlib.import_module(str(modelParameters["simConfigModuleName"]))
137135
# Import Model attributes
138136
netpyne_geppetto.simConfig = getattr(simConfigModuleName, str(modelParameters["simConfigVariable"]))
139-
else:
137+
138+
elif modelParameters['importFormat']=='json':
140139
with open(modelParameters['jsonModelFolder'], 'r') as file:
141140
jsonData = json.load(file)
142141

143142
if 'net' in jsonData:
144143
if 'params' in jsonData['net'] and 'simConfig' in jsonData:
145144
netpyne_geppetto.netParams = specs.NetParams(jsonData['net']['params'])
146145
netpyne_geppetto.simConfig = specs.SimConfig(jsonData['simConfig'])
147-
# in cellParams.conds --> cellModel, cellType and pop get value {} if this is type specs.Dict
148-
# so, by converting from specs.Dict to python regular dict solves the problem. I tried to solve it In the GUI but I couldn't
149146
netpyne_geppetto.netParams.cellParams = jsonData['net']['params']['cellParams']
150147
else:
151148
return self.getJSONError("Assertion error while importing the NetPyNE model", "The json file does not contain the following keys: [params, simConfig]")
152149
else:
153150
return self.getJSONError("Assertion error while importing the NetPyNE model", "The json file does not contain the following keys: [net]")
154-
151+
else:
152+
return self.getJSONError("Assertion error while importing the NetPyNE model", "frontend sent a wrong option for 'importFormat'. allowed values are py and json")
155153
return self.getJSONReply()
156154
except:
157155
return self.getJSONError("Error while importing the NetPyNE model",traceback.format_exc())
@@ -441,7 +439,6 @@ def deleteParam(self, paramToDel):
441439
def validateFunction(self, functionString):
442440
return utils.ValidateFunction(functionString, netParams.__dict__)
443441

444-
445442
class LoopTimer(threading.Thread):
446443
"""
447444
a Timer that calls f every interval

0 commit comments

Comments
 (0)