Skip to content

Instantly share code, notes, and snippets.

@nicain
Created August 3, 2017 19:39
Show Gist options
  • Save nicain/65dd4758590641af1f612827a4b467a2 to your computer and use it in GitHub Desktop.
Save nicain/65dd4758590641af1f612827a4b467a2 to your computer and use it in GitHub Desktop.
extension_module_dataset_example
from pynwb import NWBNamespaceBuilder, NWBDatasetSpec, NWBAttributeSpec
import numpy as np
from pynwb import get_class, load_namespaces
from datetime import datetime
from pynwb import NWBFile
from form.backends.hdf5 import HDF5IO
from pynwb import get_build_manager
ns_path = "mylab.namespace.yaml"
ext_source = "mylab.extensions.yaml"
nwb_as = NWBAttributeSpec('data', 'int', 'gid')
ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', "mylab")
ext = NWBDatasetSpec('A custom TimeSeries for my lab',
attributes=[nwb_as],
dtype='float',
neurodata_type_inc='TimeSeries',
neurodata_type_def='PopulationSpikeTrain')
ns_builder.add_spec(ext_source, ext)
ns_builder.export(ns_path)
ns_path = "mylab.namespace.yaml"
load_namespaces(ns_path)
@nicain
Copy link
Author

nicain commented Aug 3, 2017

ValueError                                Traceback (most recent call last)
<ipython-input-20-ea290742411b> in <module>()
----> 1 load_namespaces(ns_path)

/data/mat/nicholasc/pynwb/src/form/utils.py in func_call(*args, **kwargs)
    276                 if parse_err:
    277                     raise TypeError(', '.join(parse_err))
--> 278                 return func(**parsed['args'])
    279         _rtype = rtype
    280         if isinstance(rtype, type):

/data/mat/nicholasc/pynwb/src/pynwb/__init__.py in load_namespaces(**kwargs)
     41     '''Load namespaces from file'''
     42     namespace_path = getargs('namespace_path', kwargs)
---> 43     __TYPE_MAP.load_namespaces(namespace_path)
     44 
     45 __resources = __get_resources()

/data/mat/nicholasc/pynwb/src/form/utils.py in func_call(*args, **kwargs)
    269                 if parse_err:
    270                     raise TypeError(', '.join(parse_err)) from None
--> 271                 return func(self, **parsed['args'])
    272         else:
    273             def func_call(*args, **kwargs):

/data/mat/nicholasc/pynwb/src/form/build/map.py in load_namespaces(self, **kwargs)
    594         '''
    595         namespace_path, resolve = getargs('namespace_path', 'resolve', kwargs)
--> 596         deps = self.__ns_catalog.load_namespaces(namespace_path, resolve)
    597         for new_ns, ns_deps in deps.items():
    598             for src_ns, types in ns_deps.items():

/data/mat/nicholasc/pynwb/src/form/utils.py in func_call(*args, **kwargs)
    269                 if parse_err:
    270                     raise TypeError(', '.join(parse_err)) from None
--> 271                 return func(self, **parsed['args'])
    272         else:
    273             def func_call(*args, **kwargs):

/data/mat/nicholasc/pynwb/src/form/spec/namespace.py in load_namespaces(self, **kwargs)
    256                     if types_key in s:
    257                         dtypes = set(s[types_key])
--> 258                     ndts = self.__load_spec_file(spec_file, catalog, dtypes=dtypes, resolve=resolve)
    259                 elif 'namespace' in s:
    260                     # load specs from namespace

/data/mat/nicholasc/pynwb/src/form/spec/namespace.py in __load_spec_file(self, spec_file_path, catalog, dtypes, resolve)
    203                 specs = d.get('groups')
    204                 if specs is None:
--> 205                     raise ValueError("no 'specs' found in %s" % spec_file_path)
    206                 for spec_dict in specs:
    207                     dt_def = spec_dict.get(self.__group_spec_cls.def_key())

ValueError: no 'specs' found in mylab.extensions.yaml```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment