adapters
Package¶
abcadapter
¶
Root classes for adding custom functionality to the code.
- class tvb.core.adapters.abcadapter.ABCAdapter[source]¶
Bases:
object
Root Abstract class for all TVB Adapters.
- add_operation_additional_info(message)[source]¶
Adds additional info on the operation to be displayed in the UI. Usually a warning message.
- static build_adapter(stored_adapter: Algorithm) ABCAdapter [source]¶
Having a module and a class name, create an instance of ABCAdapter.
- static build_adapter_from_class(adapter_class)[source]¶
Having a subclass of ABCAdapter, prepare an instance for launching an operation with it.
- static can_be_active()[source]¶
To be overridden where needed (e.g. Matlab dependent adapters). :return: By default True, and False when the current Adapter can not be executed in the current env for various reasons
- configure(view_model)[source]¶
To be implemented in each Adapter that requires any specific configurations before the actual launch.
- static determine_adapter_class(stored_adapter: Algorithm) ABCAdapter [source]¶
Determine the class of an adapter based on module and classname strings from stored_adapter :param stored_adapter: Algorithm or AlgorithmDTO type :return: a subclass of ABCAdapter
- static fill_index_from_h5(analyzer_index, analyzer_h5)[source]¶
Method used only by analyzers that write slices of data. As they never have the whole array_data in memory, the metadata related to array_data (min, max, etc.) they store on the index is not correct, so we need to update them.
- get_adapter_fragments(view_model)[source]¶
The result will be used for introspecting and checking operation changed input params from the defaults, to show in web gui. :return: a list of ABCAdapterForm classes, in case the current Adapter GUI will be composed of multiple sub-forms.
- get_execution_time_approximation(view_model)[source]¶
Method should approximate based on input arguments, the time it will take for the operation to finish (in seconds).
- abstract get_required_disk_size(view_model)[source]¶
Abstract method to be implemented in each adapter. Should return the required memory for launching the adapter in kilo-Bytes.
- abstract get_required_memory_size(view_model)[source]¶
Abstract method to be implemented in each adapter. Should return the required memory for launching the adapter.
- abstract launch(view_model)[source]¶
To be implemented in each Adapter. Will contain the logic of the Adapter. Takes a ViewModel with data, dependency direction is: Adapter -> Form -> ViewModel Any returned DataType will be stored in DB, by the Framework.
- Parameters:
view_model – the data model corresponding to the current adapter
- launch_mode = 'async_diff_mem'¶
- load_entity_by_gid(data_gid: UUID | str) DataType [source]¶
Load a generic DataType, specified by GID.
- load_traited_by_gid(data_gid: UUID | str) HasTraits [source]¶
Load a generic HasTraits instance, specified by GID.
- store_complete(datatype, generic_attributes=<tvb.core.entities.generic_attributes.GenericAttributes object>)[source]¶
- stored_adapter = None¶
- class tvb.core.adapters.abcadapter.ABCAdapterForm[source]¶
Bases:
Form
- static get_filters()[source]¶
Should keep filters for the required_datatype. These filters are stored in DB at introspection time. :return: FilterChain
- static get_input_name()[source]¶
The Form’s input name for the required_datatype. Will be stored in DB at introspection time. :return: str
- class tvb.core.adapters.abcadapter.AdapterLaunchModeEnum(value)[source]¶
Bases:
Enum
An enumeration.
- ASYNC_DIFF_MEM = 'async_diff_mem'¶
- SYNC_DIFF_MEM = 'sync_diff_mem'¶
- SYNC_SAME_MEM = 'sync_same_mem'¶
- tvb.core.adapters.abcadapter.nan_allowed()[source]¶
Annotation that configures NumPy not to throw an exception in case of floating points errors are computed. It should be used on Adapter methods where computation of NaN/ Inf/etc. is allowed.
- tvb.core.adapters.abcadapter.nan_not_allowed()[source]¶
Annotation that guides NumPy behavior in case of floating point errors. The NumPy default is to just print a warning to sys.stdout, this annotation will raise our custom exception. This annotation will enforce that an exception is thrown in case a floating point error is produced.
- e.g. If NaN is take as input and not produced inside the context covered by this annotation,
nothing happens from this method p.o.v.
- e.g. If inside a method annotated with this method we have something like numpy.log(-1),
then LaunchException is thrown.
abcdisplayer
¶
- class tvb.core.adapters.abcdisplayer.ABCDisplayer[source]¶
Bases:
ABCAdapter
Abstract class, for marking Adapters used for UI display only.
- KEY_CONTENT = 'mainContent'¶
- KEY_IS_ADAPTER = 'isAdapter'¶
- VISUALIZERS_ROOT = ''¶
- build_display_result(template, parameters, pages=None)[source]¶
Helper method for building the result of the ABCDisplayer. :param template : relative path towards the HTML template to display :param parameters : dictionary with parameters for “template” :param pages : dictionary of pages to be used with <xi:include>
- static dump_with_precision(xs, precision=3)[source]¶
Dump a list of numbers into a string, each at the specified precision.
- static get_one_dimensional_list(list_of_elements, expected_size, error_msg)[source]¶
Used for obtaining a list of ‘expected_size’ number of elements from the list ‘list_of_elements’. If the list ‘list_of_elements’ doesn’t have sufficient elements then an exception will be thrown.
list_of_elements - a list of one or two dimensions expected_size - the number of elements that should have the returned list error_msg - the message that will be used for the thrown exception.
- static handle_infinite_values(data)[source]¶
Replace positive infinite values with the biggest float number available in numpy, and negative infinite values with the smallest float number available in numpy.
- launch_mode = 'sync_same_mem'¶
- class tvb.core.adapters.abcdisplayer.URLGenerator[source]¶
Bases:
object
- BINARY_DATATYPE_ATTRIBUTE = 'read_binary_datatype_attribute'¶
- DATATYPE_ATTRIBUTE = 'read_datatype_attribute'¶
- FLOW = 'flow'¶
- H5_FILE = 'read_from_h5_file'¶
- INVOKE_ADAPTER = 'invoke_adapter'¶
abcremover
¶
abcuploader
¶
- class tvb.core.adapters.abcuploader.ABCUploader[source]¶
Bases:
ABCAdapter
Base class of the uploading algorithms
- LOGGER = <Logger tvb.core.adapters.abcuploader (INFO)>¶
- get_required_disk_size(view_model)[source]¶
As it is an upload algorithm and we do not have information about data, we can not approximate this.
- get_required_memory_size(view_model)[source]¶
Return the required memory to run this algorithm. As it is an upload algorithm and we do not have information about data, we can not approximate this.
- launch_mode = 'sync_diff_mem'¶
- class tvb.core.adapters.abcuploader.ABCUploaderForm[source]¶
Bases:
ABCAdapterForm
- static get_filters()[source]¶
Should keep filters for the required_datatype. These filters are stored in DB at introspection time. :return: FilterChain
- static get_input_name()[source]¶
The Form’s input name for the required_datatype. Will be stored in DB at introspection time. :return: str
arguments_serialisation
¶
This is a framework helper module. Some framework datatypes have functions that will be called via http by the TVB GUI. These functions will receive some arguments as strings and return json serializable structures usually dicts. This module contains functions to parse those strings and construct those responses.
- tvb.core.adapters.arguments_serialisation.parse_slice(slice_string)[source]¶
Parse a slicing expression >>> parse_slice(“::1, :”) (slice(None, None, 1), slice(None, None, None)) >>> parse_slice(“2”) 2 >>> parse_slice(“[2]”) 2
- tvb.core.adapters.arguments_serialisation.postprocess_voxel_ts(ts, slices, background_value=None, background_min=None, background_max=None, label=None)[source]¶
Read TimeLine from TS and prepare the result for TSVolumeViewer.
- Parameters:
ts – TS instance, with read_data_slice method
slices – slices for reading from H5
- Returns:
A complex dictionary with information about current voxel.
- tvb.core.adapters.arguments_serialisation.preprocess_space_parameters(x, y, z, max_x, max_y, max_z)[source]¶
Covert ajax call parameters into numbers and validate them.
- Parameters:
x – coordinate
y – coordinate
z – coordinate that will be reversed
max_x – maximum x accepted value
max_y – maximum y accepted value
max_z – maximum z accepted value
- Returns:
(x, y, z) as integers, Z reversed
constants
¶
exceptions
¶
- exception tvb.core.adapters.exceptions.IntrospectionException(message, parent_exception=None)[source]¶
Bases:
TVBException
Exception class for problems when introspection failed.
- exception tvb.core.adapters.exceptions.InvalidParameterException(message, parent_exception=None)[source]¶
Bases:
LaunchException
Exception class for parameter validation issue.
- exception tvb.core.adapters.exceptions.LaunchException(message, parent_exception=None)[source]¶
Bases:
TVBException
Exception class for problem with launching an operation.
- exception tvb.core.adapters.exceptions.NoMemoryAvailableException(message, parent_exception=None)[source]¶
Bases:
TVBException
Exception class raised when an adapter requires more memory that is available on machine.
- exception tvb.core.adapters.exceptions.ParseException(message, parent_exception=None)[source]¶
Bases:
TVBException
Exception class for problem with parsing files an operation.
- exception tvb.core.adapters.exceptions.XmlParserException(message, parent_exception=None)[source]¶
Bases:
IntrospectionException
Exception class for problems when parsing xml files.