scidash / neuronunit

A package for data-driven validation of neuron and ion channel models using SciUnit
http://neuronunit.scidash.org
38 stars 24 forks source link

When backends NEURON lives in a new file, new model objects can't be minted. #157

Closed russelljjarvis closed 6 years ago

russelljjarvis commented 6 years ago

reduced.py needs Backend NEURON to reside in the same file. One strategy might involve just making code climate ignore backends.py file. As shortening files may not always make code more maintainable.

~/neuronunit/neuronunit/optimization/nsga_parallel.py in dtc_to_rheo(dtc)
     39     dtc.model_path = get_neab.LEMS_MODEL_PATH
     40     dtc.LEMS_MODEL_PATH = get_neab.LEMS_MODEL_PATH
---> 41     model = ReducedModel(dtc.LEMS_MODEL_PATH,name=str('vanilla'),backend='NEURON')
     42     model.set_attrs(dtc.attrs)
     43     model.rheobase = None
~/neuronunit/neuronunit/models/reduced.py in __init__(self, LEMS_file_path, name, backend, attrs)
     22         """
     23         super(ReducedModel,self).__init__(LEMS_file_path,name=name,
---> 24                                           backend=backend,attrs=attrs)
     25         self.run_number = 0
     26         self.tstop = None

~/neuronunit/neuronunit/models/__init__.py in __init__(self, LEMS_file_path, name, backend, attrs)
     44         self.rerun = True # Needs to be rerun since it hasn't been run yet!
     45         self.unpicklable = []
---> 46         self.set_backend(backend)
     47 
     48     def get_backend(self):

~/neuronunit/neuronunit/models/__init__.py in set_backend(self, backend)
     81         else:
     82             raise Exception("Backend %s not found in backends.py" \
---> 83                             % name)
     84         self._backend.model = self
     85         self._backend.init_backend(*args, **kwargs)

Exception: Backend NEURON not found in backends.py

At the bottom of neuronunit/models/backends.py I have:

from neuronunit.models import section_extension
from neuronunit.models import backendsNEURON

possibly not the standard pattern for expanding out a module.

rgerkin commented 6 years ago

set_backend does a check for which models live inside backends.py. We can fix this by having it instead search inside backends/__init__.py, where we will have all the backends in the various other files (including backends/neuron.py) imported.

russelljjarvis commented 6 years ago

How complicated would these expressions for searching look? If they are simple expressions than I agree.

rgerkin commented 6 years ago

Simple. I'll take care of it on Monday.

russelljjarvis commented 6 years ago

Yes, actually come to think of it we need it for PyNN and Brian, you want backends to grow with increasing neuronunit support. We can't make the file ~1,000s of line long.

rgerkin commented 6 years ago

See implementation in 294c0db9b8adb008ec48bcbe6c9737130302d970

russelljjarvis commented 6 years ago

Fixed.