core Package

This is an abstract package.

It should be capable of managing (store, create, repeat, log, etc.) a generic and abstract workFlow of algorithms.

@Developers:

Make sure that all the code you add to this package is abstract!!!! You’ve been warned! No dependencies towards specific adapters should be included here.

decorators

tvb.core.decorators.user_environment_execution(func)[source]

Decorator that makes sure a function is executed in a ‘user’ environment, removing any TVB specific configurations that alter either LD_LIBRARY_PATH or LD_RUN_PATH.

operation_async_launcher

This module is called in a new process by the rpserver: Example: python operation_async_launcher.py 4 user_name_label 4 is the operation id stored in the DataBase in the table “OPERATIONS” It gets the algorithm, and the adapter with its parameters from database. And finally launches the computation. The results of the computation will be stored by the adapter itself.

tvb.core.operation_async_launcher.do_operation_launch(operation_id)[source]

Event attached to the local queue for executing an operation, when we will have resources available.

operation_hpc_launcher

tvb.core.operation_hpc_launcher.do_operation_launch(simulator_gid, available_disk_space, is_group_launch, base_url, operation_id, plain_dir='/root/plain')[source]

removers_factory

Created on Nov 1, 2011

tvb.core.removers_factory.get_remover(datatype_index_class: HasTraitsIndex) Type[ABCRemover][source]
Parameters:

datatype_index_class – class of datatype index; to search for a remover class for this.

tvb.core.removers_factory.update_dictionary(new_dict: dict) None[source]

Update removers dictionary.

utils

class tvb.core.utils.TVBJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Bases: JSONEncoder

Custom encoder class. Referring towards “to_json” method, when found, or default behaviour otherwise.

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
tvb.core.utils.date2string(date_input, complex_format=True, date_format=None)[source]

Convert date into string, after internal format

tvb.core.utils.format_bytes_human(size, si=False)[source]
Parameters:
  • size – size in kilobytes

  • si – if True use SI units (multiple of 1000 not 1024)

Returns:

a String with [number] [memory unit measure]

tvb.core.utils.format_timedelta(timedelta, most_significant2=True)[source]

Format a datetime.timedelta. :param timedelta: object timedelta to format :param most_significant2: Will show only the 2 most significant units (ex: hours, minutes). Default True.

tvb.core.utils.generate_guid()[source]

Generate new Global Unique Identifier. This identifier should be unique per each station, and unique for different machines.

tvb.core.utils.get_unique_file_name(storage_folder, file_name, try_number=0)[source]

Compute non-existent file name, in storage_folder. Try file_name, and if already exists, try adding a number.

tvb.core.utils.hash_password(pass_string)[source]
tvb.core.utils.parse_json_parameters(parameters)[source]

From JSON with Unicodes, return a dictionary having strings as keys. Loading from DB a JSON will return instead of string keys, unicodes.

tvb.core.utils.path2url_part(file_path)[source]

Prepare a File System Path for passing into an URL.

tvb.core.utils.prepare_time_slice(total_time_length, max_length=10000)[source]

Limit the time dimension when retrieving from TS. If total time length is greater than MAX, then retrieve only the last part of the TS

Parameters:
  • total_time_length – TS time dimension

  • max_length – limiting number of TS steps

Returns:

python slice

tvb.core.utils.string2bool(string_input)[source]

Convert given string into boolean value.

tvb.core.utils.string2date(string_input, complex_format=True, date_format=None)[source]

Read date from string, after internal format

tvb.core.utils.url2path(encoded_path)[source]

Retrieve File System Path from encoded URL (inverse of path2url_part).

Subpackages