neocom Package

_h5loader

class tvb.core.neocom._h5loader.DirLoader(base_dir: str, registry: Registry, recursive: bool = False)[source]

Bases: object

A simple recursive loader. Stores all files in a directory. You refer to files by their gid

find_file_by_gid(gid: Union[UUID, str]) str[source]
find_file_for_has_traits_type(has_traits_class)[source]
load(gid: Optional[Union[UUID, str]] = None, fname: Optional[str] = None) HasTraits[source]

Load from file a HasTraits entity. Either gid or fname should be given, or else an error is raised.

Parameters:
  • gid – optional entity GUID to search for it under self.base_dir

  • fname – optional file name to search for it under self.base_dir.

Returns:

HasTraits instance read from the given location

path_for(h5_file_class, gid)[source]

where will this Loader expect to find a file of this format and with this gid

path_for_has_traits(has_traits_class, gid)[source]
store(datatype: HasTraits, fname: Optional[str] = None) str[source]
class tvb.core.neocom._h5loader.DtLoader(base_dir, registry)[source]

Bases: ViewModelLoader

A recursive loader for datatypes (HasTraits). Stores all files in one directory specified at initialization time. Does not access the TVB database. Does not take into consideration the TVB storage folder structure. Stores every linked HasTraits object in a file (even datatypes which might already exist in the TVB storage). Intended for storing tvb-library results in H5 files.

load(gid: Optional[Union[UUID, str]] = None, fname: Optional[str] = None) ViewModel[source]

Load a HasTraits datatype object by reading the H5 file with the given GID, from the directory self.base_dir

store(ht_datatype: HasTraits, fname: Optional[str] = None) str[source]

Completely store any HasTraits datatype object to the directory specified by self.base_dir. Works recursively for datatypes that are serialized in multiple files (eg. Simulator)

class tvb.core.neocom._h5loader.Loader(registry)[source]

Bases: object

A default simple loader. Does not do recursive loads. Loads stores just to paths.

load(source: str) HasTraits[source]
store(datatype: HasTraits, destination: str) None[source]
class tvb.core.neocom._h5loader.TVBLoader(registry)[source]

Bases: object

A loader for HasTraits objects. Works with the TVB database and the TVB storage folder structure to identify and load datatypes starting from their corresponding HasTraitsIndex or a file path. Intended for usage in tvb-framework.

load_complete_by_function(file_path: str, load_ht_function: callable)[source]
load_from_index(dt_index: DataType) HasTraits[source]
load_with_references(file_path)[source]
path_by_dir(base_dir, h5_file_class, gid, dt_class)[source]
path_for(op_id, h5_file_class, gid, project_name, dt_class)[source]
path_for_stored_index(dt_index_instance: DataType) str[source]

Given a Datatype(HasTraitsIndex) instance, build where the corresponding H5 should be or is stored

class tvb.core.neocom._h5loader.ViewModelLoader(base_dir, registry=None)[source]

Bases: DirLoader

A recursive loader for ViewModel objects. Stores all files in one directory specified at initialization time. Does not access the TVB database. Does not take into consideration the TVB storage folder structure. Stores every linked HasTraits in a file, but not datatypes that are already stored in TVB storage. Intended for usage within tvb-framework to store view models in H5 files.

gather_reference_files(gid, vm_ref_files, dt_ref_files, load_dts=None)[source]
get_class_path(vm)[source]
load(gid: Optional[Union[UUID, str]] = None, fname: Optional[str] = None) ViewModel[source]

Load a ViewModel object by reading the H5 file with the given GID, from the directory self.base_dir

store(view_model: ViewModel, fname: Optional[str] = None) str[source]

Completely store any ViewModel object to the directory specified by self.base_dir. Works recursively for view models that are serialized in multiple files (eg. SimulatorAdapterModel)

_registry

class tvb.core.neocom._registry.Registry[source]

Bases: object

A configuration class that holds the one to one relationship between datatypes and H5Files that can read/write them to disk

get_base_datatype_for_h5file(h5file_class: Type[H5File]) Type[HasTraits][source]
get_datatype_for_h5file(h5file: H5File) Type[HasTraits][source]
get_datatype_for_index(index: HasTraitsIndex) Type[HasTraits][source]
get_h5file_for_datatype(datatype_class: Type[HasTraits]) Type[H5File][source]
get_h5file_for_index(index_class: Type[DataType]) Type[H5File][source]
get_index_for_datatype(datatype_class: Type[HasTraits]) Type[DataType][source]
get_index_for_h5file(h5file_class: Type[H5File]) Type[DataType][source]
register_datatype(datatype_class: HasTraits, h5file_class: H5File, datatype_index: DataType, subtype_factory: Optional[callable] = None, subtype_enum: Optional[Enum] = None) None[source]

h5

tvb.core.neocom.h5.determine_filepath(gid, base_dir)[source]

Find the file path containing a datatype with the given GID within the directory specified by base_dir

tvb.core.neocom.h5.gather_all_references_by_index(h5_file, ref_files)[source]
tvb.core.neocom.h5.gather_references_of_view_model(gid, base_dir, only_view_models=False)[source]

Gather in 2 lists all file paths that are referenced by a ViewModel with the given GID stored in base_dir directory. If only_view_models=True, returns only ViewModelH5 file paths, otherwise, returns also datatype H5 file paths.

tvb.core.neocom.h5.h5_file_for_gid(data_gid: str) H5File[source]
tvb.core.neocom.h5.h5_file_for_index(dt_index_instance: DataType) H5File[source]
tvb.core.neocom.h5.index_for_h5_file(source_path: str) Type[DataType][source]
tvb.core.neocom.h5.load(source_path: str, with_references: bool = False) HasTraits[source]

Load a datatype stored in the tvb h5 file found at the given path

tvb.core.neocom.h5.load_from_dir(base_dir: str, gid: Union[str, UUID], recursive: bool = False) HasTraits[source]

Loads a datatype with the requested gid from the given directory. The datatype should have been written with store_to_dir The name and location of the file is chosen for you. :param base_dir: The h5 storage directory :param gid: the gid of the to be loaded datatype :param recursive: if datatypes contained in this datatype should be loaded as well

tvb.core.neocom.h5.load_from_gid(data_gid: str) HasTraits[source]
tvb.core.neocom.h5.load_from_index(dt_index: DataType) HasTraits[source]
tvb.core.neocom.h5.load_ht(gid: Union[UUID, str], base_dir: str) str[source]

Completely load any HasTraits object with the gid specified from the base_dir directory

tvb.core.neocom.h5.load_view_model(gid: Union[UUID, str], base_dir: str) ViewModel[source]

Load a ViewModel object by reading the H5 file with the given GID, from the directory specified by base_dir.

tvb.core.neocom.h5.load_view_model_from_file(filepath: str) ViewModel[source]

Load a ViewModel object by reading the H5 file specified by filepath.

Load a datatype stored in the tvb h5 file found at the given path, but also create empty linked entities to hold GID

tvb.core.neocom.h5.load_with_references(source_path: str)[source]

Load a datatype stored in the tvb h5 file found at the given path, but also load linked entities through GID

tvb.core.neocom.h5.load_with_references_from_dir(base_dir: str, gid: Union[UUID, str]) HasTraits[source]
tvb.core.neocom.h5.path_by_dir(base_dir: str, h5_file_class: Type[H5File], gid: str, dt_class: Optional[str] = None) str[source]
tvb.core.neocom.h5.path_for(op_id: int, h5_file_class: Type[H5File], gid: object, project_name: str, dt_class: Optional[str] = None) str[source]
tvb.core.neocom.h5.path_for_stored_index(dt_index_instance: DataType) str[source]
tvb.core.neocom.h5.store(datatype: HasTraits, destination: str, recursive: bool = False) None[source]

Stores the given datatype in a tvb h5 file at the given path

tvb.core.neocom.h5.store_complete(datatype, op_id, project_name, generic_attributes=<tvb.core.entities.generic_attributes.GenericAttributes object>)[source]
tvb.core.neocom.h5.store_complete_to_dir(datatype, base_dir, generic_attributes=<tvb.core.entities.generic_attributes.GenericAttributes object>)[source]
tvb.core.neocom.h5.store_ht(ht: HasTraits, base_dir: str) str[source]

Completely store any HasTraits object to the directory specified by base_dir

tvb.core.neocom.h5.store_to_dir(datatype: HasTraits, base_dir: str, recursive: bool = False) str[source]

Stores the given datatype in the given directory. The name and location of the stored file(s) is chosen for you by this function. If recursive is true than datatypes referenced by this one are stored as well.

tvb.core.neocom.h5.store_view_model(view_model: ViewModel, base_dir: str) str[source]

Completely store any ViewModel object to the directory specified by base_dir.