Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 39 additions & 18 deletions netpyne_ui/netpyne_geppetto.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,45 @@ def importModel(self, modelParameters):
self.compileModMechFiles(modelParameters['compileMod'], modelParameters['modFolder'])

import netpyne_geppetto
# NetParams
netParamsPath = str(modelParameters["netParamsPath"])
sys.path.append(netParamsPath)
os.chdir(netParamsPath)
# Import Module
netParamsModuleName = importlib.import_module(str(modelParameters["netParamsModuleName"]))
# Import Model attributes
netpyne_geppetto.netParams = getattr(netParamsModuleName, str(modelParameters["netParamsVariable"]))

# SimConfig
simConfigPath = str(modelParameters["simConfigPath"])
sys.path.append(simConfigPath)
os.chdir(simConfigPath)
# Import Module
simConfigModuleName = importlib.import_module(str(modelParameters["simConfigModuleName"]))
# Import Model attributes
netpyne_geppetto.simConfig = getattr(simConfigModuleName, str(modelParameters["simConfigVariable"]))

if modelParameters['importFormat']=='py':
# NetParams
netParamsPath = str(modelParameters["netParamsPath"])
sys.path.append(netParamsPath)
os.chdir(netParamsPath)
# Import Module
netParamsModuleName = importlib.import_module(str(modelParameters["netParamsModuleName"]))
# Import Model attributes
netpyne_geppetto.netParams = getattr(netParamsModuleName, str(modelParameters["netParamsVariable"]))

for key, value in netpyne_geppetto.netParams.cellParams.iteritems():
if hasattr(value, 'todict'):
netpyne_geppetto.netParams.cellParams[key] = value.todict()

# SimConfig
simConfigPath = str(modelParameters["simConfigPath"])
sys.path.append(simConfigPath)
os.chdir(simConfigPath)
# Import Module
simConfigModuleName = importlib.import_module(str(modelParameters["simConfigModuleName"]))
# Import Model attributes
netpyne_geppetto.simConfig = getattr(simConfigModuleName, str(modelParameters["simConfigVariable"]))

elif modelParameters['importFormat']=='json':
with open(modelParameters['jsonModelFolder'], 'r') as file:
jsonData = json.load(file)

if 'net' in jsonData:
if 'params' in jsonData['net'] and 'simConfig' in jsonData:
netpyne_geppetto.netParams = specs.NetParams(jsonData['net']['params'])
netpyne_geppetto.simConfig = specs.SimConfig(jsonData['simConfig'])
netpyne_geppetto.netParams.cellParams = jsonData['net']['params']['cellParams']
else:
return self.getJSONError("Assertion error while importing the NetPyNE model", "The json file does not contain the following keys: [params, simConfig]")
else:
return self.getJSONError("Assertion error while importing the NetPyNE model", "The json file does not contain the following keys: [net]")
else:
return self.getJSONError("Assertion error while importing the NetPyNE model", "frontend sent a wrong option for 'importFormat'. allowed values are py and json")
return self.getJSONReply()
except:
return self.getJSONError("Error while importing the NetPyNE model",traceback.format_exc())
Expand Down Expand Up @@ -415,7 +436,7 @@ def deleteParam(self, paramToDel):

def validateFunction(self, functionString):
return utils.ValidateFunction(functionString, netParams.__dict__)

def generateScript(self, metadata):
def convert2bool(string):
return string.replace('true', 'True').replace('false', 'False')
Expand Down
2 changes: 1 addition & 1 deletion utilities/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def main(argv):
clone('https://github.com/openworm/pygeppetto.git','pygeppetto','v0.4.1-M1')
subprocess.call(['pip', 'install', '-e', '.'], cwd='./pygeppetto/')

clone('https://github.com/Neurosim-lab/netpyne.git','netpyne','0.7.9')
clone('https://github.com/Neurosim-lab/netpyne.git','netpyne','v0.7.9')
subprocess.call(['pip', 'install', '-e', '.'], cwd='./netpyne/')

clone('https://github.com/openworm/org.geppetto.frontend.jupyter.git','org.geppetto.frontend.jupyter','v0.4.1-M2','', True )
Expand Down