TheVirtualBrain:

TheDocumentationwebsite.

Table Of Contents

Previous topic

web Package

Next topic

burst Package

This Page

controllers Package

autologging

Edited by Bogdan Valean <bogdan.valean@codemart.ro> : 29.05.2020 - Use internal TVB Logger by default. - Add logged user GID to the logging message

tvb.interfaces.web.controllers.autologging.TRACE = 1

A custom tracing log level, lower in severity than logging.DEBUG.

tvb.interfaces.web.controllers.autologging.logged(obj)[source]

Add a logger member to a decorated class or function.

Parameters:obj – the class or function object being decorated, or an optional logging.Logger object to be used as the parent logger (instead of the default module-named logger)
Returns:obj if obj is a class or function; otherwise, if obj is a logger, return a lambda decorator that will in turn set the logger attribute and return obj

If obj is a class, then obj.__log will have the logger name “<module-name>.<class-name>”:

>>> import sys
>>> logging.basicConfig(
...     level=logging.DEBUG, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @logged
... class Sample:
...
...     def test(self):
...         self.__log.debug("This is a test.")
...
>>> Sample().test()
DEBUG:autologging.Sample:test:This is a test.

Note

Autologging will prefer to use the class’s __qualname__ when it is available (Python 3.3+). Otherwise, the class’s __name__ is used. For example:

class Outer:

   @logged
   class Nested: pass

Under Python 3.3+, Nested.__log will have the name “autologging.Outer.Nested”, while under Python 2.7 or 3.2, the logger name will be “autologging.Nested”.

Changed in version 0.4.0: Functions decorated with @logged use a single underscore in the logger variable name (e.g. my_function._log) rather than a double underscore.

If obj is a function, then obj._log will have the logger name “<module-name>”:

>>> import sys
>>> logging.basicConfig(
...     level=logging.DEBUG, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @logged
... def test():
...     test._log.debug("This is a test.")
...
>>> test()
DEBUG:autologging:test:This is a test.

Note

Within a logged function, the _log attribute must be qualified by the function name.

If obj is a logging.Logger object, then that logger is used as the parent logger (instead of the default module-named logger):

>>> import sys
>>> logging.basicConfig(
...     level=logging.DEBUG, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @logged(logging.getLogger("test.parent"))
... class Sample:
...     def test(self):
...         self.__log.debug("This is a test.")
...
>>> Sample().test()
DEBUG:test.parent.Sample:test:This is a test.

Again, functions are similar:

>>> import sys
>>> logging.basicConfig(
...     level=logging.DEBUG, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @logged(logging.getLogger("test.parent"))
... def test():
...     test._log.debug("This is a test.")
...
>>> test()
DEBUG:test.parent:test:This is a test.

Note

For classes, the logger member is made “private” (i.e. __log with double underscore) to ensure that log messages that include the %(name)s format placeholder are written with the correct name.

Consider a subclass of a @logged-decorated parent class. If the subclass were not decorated with @logged and could access the parent’s logger member directly to make logging calls, those log messages would display the name of the parent class, not the subclass.

Therefore, subclasses of a @logged-decorated parent class that wish to use a provided self.__log object must themselves be decorated with @logged.

Warning

Although the @logged and @traced decorators will “do the right thing” regardless of the order in which they are applied to the same function, it is recommended that @logged always be used as the innermost decorator:

@traced
@logged
def my_function():
    my_function._log.info("message")

This is because @logged simply sets the _log attribute and then returns the original function, making it “safe” to use in combination with any other decorator.

Note

Both Jython and IronPython report an “internal” class name using its mangled form, which will be reflected in the default logger name.

For example, in the sample code below, both Jython and IronPython will use the default logger name “autologging._Outer__Nested” (whereas CPython/PyPy/Stackless would use “autologging.__Nested” under Python 2 or “autologging.Outer.__Nested” under Python 3.3+)

class Outer:
   @logged
   class __Nested:
      pass

Warning

IronPython does not fully support frames (even with the -X:FullFrames option), so you are likely to see things like misreported line numbers and “<unknown file>” in log records emitted when running under IronPython.

tvb.interfaces.web.controllers.autologging.traced(*args, **keywords)[source]

Add call and return tracing to an unbound function or to the methods of a class.

The arguments to traced differ depending on whether it is being used to trace an unbound function or the methods of a class:

Trace an unbound function using the default logger

Parameters:func – the unbound function to be traced

By default, a logger named for the function’s module is used:

>>> import sys
>>> logging.basicConfig(
...     level=TRACE, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @traced
... def func(x, y):
...     return x + y
...
>>> func(7, 9)
TRACE:autologging:func:CALL *(7, 9) **{}
TRACE:autologging:func:RETURN 16
16

Trace an unbound function using a named logger

Parameters:logger (logging.Logger) – the parent logger used to trace the unbound function
>>> import sys
>>> logging.basicConfig(
...     level=TRACE, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @traced(logging.getLogger("my.channel"))
... def func(x, y):
...     return x + y
...
>>> func(7, 9)
TRACE:my.channel:func:CALL *(7, 9) **{}
TRACE:my.channel:func:RETURN 16
16

Trace default methods using the default logger

Parameters:class – the class whose methods will be traced

By default, all “public”, “_nonpublic”, and “__internal” methods, as well as the special “__init__” and “__call__” methods, will be traced. Tracing log entries will be written to a logger named for the module and class:

>>> import sys
>>> logging.basicConfig(
...     level=TRACE, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @traced
... class Class:
...     def __init__(self, x):
...         self._x = x
...     def public(self, y):
...         return self._x + y
...     def _nonpublic(self, y):
...         return self._x - y
...     def __internal(self, y=2):
...         return self._x ** y
...     def __repr__(self):
...         return "Class(%r)" % self._x
...     def __call__(self):
...         return self._x
...
>>> obj = Class(7)
TRACE:autologging.Class:__init__:CALL *(7,) **{}
>>> obj.public(9)
TRACE:autologging.Class:public:CALL *(9,) **{}
TRACE:autologging.Class:public:RETURN 16
16
>>> obj._nonpublic(5)
TRACE:autologging.Class:_nonpublic:CALL *(5,) **{}
TRACE:autologging.Class:_nonpublic:RETURN 2
2
>>> obj._Class__internal(y=3)
TRACE:autologging.Class:__internal:CALL *() **{'y': 3}
TRACE:autologging.Class:__internal:RETURN 343
343
>>> repr(obj) # not traced by default
'Class(7)'
>>> obj()
TRACE:autologging.Class:__call__:CALL *() **{}
TRACE:autologging.Class:__call__:RETURN 7
7

Note

When the runtime Python version is >= 3.3, the qualified class name will be used to name the tracing logger (i.e. a nested class will write tracing log entries to a logger named “module.Parent.Nested”).

Trace default methods using a named logger

Parameters:logger (logging.Logger) – the parent logger used to trace the methods of the class

By default, all “public”, “_nonpublic”, and “__internal” methods, as well as the special “__init__” method, will be traced. Tracing log entries will be written to the specified logger:

>>> import sys
>>> logging.basicConfig(
...     level=TRACE, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @traced(logging.getLogger("my.channel"))
... class Class:
...     def __init__(self, x):
...         self._x = x
...     def public(self, y):
...         return self._x + y
...     def _nonpublic(self, y):
...         return self._x - y
...     def __internal(self, y=2):
...         return self._x ** y
...     def __repr__(self):
...         return "Class(%r)" % self._x
...     def __call__(self):
...         return self._x
...
>>> obj = Class(7)
TRACE:my.channel.Class:__init__:CALL *(7,) **{}
>>> obj.public(9)
TRACE:my.channel.Class:public:CALL *(9,) **{}
TRACE:my.channel.Class:public:RETURN 16
16
>>> obj._nonpublic(5)
TRACE:my.channel.Class:_nonpublic:CALL *(5,) **{}
TRACE:my.channel.Class:_nonpublic:RETURN 2
2
>>> obj._Class__internal(y=3)
TRACE:my.channel.Class:__internal:CALL *() **{'y': 3}
TRACE:my.channel.Class:__internal:RETURN 343
343
>>> repr(obj) # not traced by default
'Class(7)'
>>> obj()
TRACE:my.channel.Class:__call__:CALL *() **{}
TRACE:my.channel.Class:__call__:RETURN 7
7

Trace specified methods using the default logger

Parameters:method_names (tuple) – the names of the methods that will be traced

Tracing log entries will be written to a logger named for the module and class:

>>> import sys
>>> logging.basicConfig(
...     level=TRACE, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @traced("public", "__internal")
... class Class:
...     def __init__(self, x):
...         self._x = x
...     def public(self, y):
...         return self._x + y
...     def _nonpublic(self, y):
...         return self._x - y
...     def __internal(self, y=2):
...         return self._x ** y
...     def __repr__(self):
...         return "Class(%r)" % self._x
...     def __call__(self):
...         return self._x
...
>>> obj = Class(7)
>>> obj.public(9)
TRACE:autologging.Class:public:CALL *(9,) **{}
TRACE:autologging.Class:public:RETURN 16
16
>>> obj._nonpublic(5)
2
>>> obj._Class__internal(y=3)
TRACE:autologging.Class:__internal:CALL *() **{'y': 3}
TRACE:autologging.Class:__internal:RETURN 343
343
>>> repr(obj)
'Class(7)'
>>> obj()
7

Warning

When method names are specified explicitly via args, Autologging ensures that each method is actually defined in the body of the class being traced. (This means that inherited methods that are not overridden are never traced, even if they are named explicitly in args.)

If a defintion for any named method is not found in the class body, either because the method is inherited or because the name is misspelled, Autologging will issue a UserWarning.

If you wish to trace a method from a super class, you have two options:

  1. Use traced to decorate the super class.
  2. Override the method and trace it in the subclass.

Note

When the runtime Python version is >= 3.3, the qualified class name will be used to name the tracing logger (i.e. a nested class will write tracing log entries to a logger named “module.Parent.Nested”).

Trace specified methods using a named logger

Parameters:
  • logger (logging.Logger) – the parent logger used to trace the methods of the class
  • method_names (tuple) – the names of the methods that will be traced
>>> import sys
>>> logging.basicConfig(
...     level=TRACE, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @traced(logging.getLogger("my.channel"), "public", "__internal")
... class Class:
...     def __init__(self, x):
...         self._x = x
...     def public(self, y):
...         return self._x + y
...     def _nonpublic(self, y):
...         return self._x - y
...     def __internal(self, y=2):
...         return self._x ** y
...     def __repr__(self):
...         return "Class(%r)" % self._x
...     def __call__(self):
...         return self._x
...
>>> obj = Class(7)
>>> obj.public(9)
TRACE:my.channel.Class:public:CALL *(9,) **{}
TRACE:my.channel.Class:public:RETURN 16
16
>>> obj._nonpublic(5)
2
>>> obj._Class__internal(y=3)
TRACE:my.channel.Class:__internal:CALL *() **{'y': 3}
TRACE:my.channel.Class:__internal:RETURN 343
343
>>> repr(obj) # not traced by default
'Class(7)'
>>> obj()
7

Warning

When method names are specified explicitly via args, Autologging ensures that each method is actually defined in the body of the class being traced. (This means that inherited methods that are not overridden are never traced, even if they are named explicitly in args.)

If a defintion for any named method is not found in the class body, either because the method is inherited or because the name is misspelled, Autologging will issue a UserWarning.

If you wish to trace a method from a super class, you have two options:

  1. Use traced to decorate the super class.
  2. Override the method and trace it in the subclass.

Exclude specified methods from tracing

New in version 1.3.0.

Parameters:
  • method_names (tuple) – the names of the methods that will be excluded from tracing
  • exclude (bool) – True to cause the method names list to be interpreted as an exclusion list (False is the default, and causes the named methods to be included as described above)

The example below demonstrates exclusions using the default logger.

>>> import sys
>>> logging.basicConfig(
...     level=TRACE, stream=sys.stdout,
...     format="%(levelname)s:%(name)s:%(funcName)s:%(message)s")
>>> @traced("_nonpublic", "__internal", exclude=True)
... class Class:
...     def __init__(self, x):
...         self._x = x
...     def public(self, y):
...         return self._x + y
...     def _nonpublic(self, y):
...         return self._x - y
...     def __internal(self, y=2):
...         return self._x ** y
...     def __repr__(self):
...         return "Class(%r)" % self._x
...     def __call__(self):
...         return self._x
...
>>> obj = Class(7)
>>> obj.public(9)
TRACE:autologging.Class:public:CALL *(9,) **{}
TRACE:autologging.Class:public:RETURN 16
16
>>> obj._nonpublic(5)
2
>>> obj._Class__internal(y=3)
343
>>> repr(obj)
'Class(7)'
>>> obj()
TRACE:autologging.Class:__call__:CALL *() **{}
TRACE:autologging.Class:__call__:RETURN 7
7

When method names are excluded via args and the exclude keyword, Autologging ignores methods that are not actually defined in the body of the class being traced.

Warning

If an exclusion list causes the list of traceable methods to resolve empty, then Autologging will issue a UserWarning.

Note

When the runtime Python version is >= 3.3, the qualified class name will be used to name the tracing logger (i.e. a nested class will write tracing log entries to a logger named “module.Parent.Nested”).

Note

When tracing a class, if the default (class-named) logger is used and the runtime Python version is >= 3.3, then the qualified class name will be used to name the tracing logger (i.e. a nested class will write tracing log entries to a logger named “module.Parent.Nested”).

Note

If method names are specified when decorating a function, a UserWarning is issued, but the methods names are ignored and the function is traced as though the method names had not been specified.

Note

Both Jython and IronPython report an “internal” class name using its mangled form, which will be reflected in the default tracing logger name.

For example, in the sample code below, both Jython and IronPython will use the default tracing logger name “autologging._Outer__Nested” (whereas CPython/PyPy/Stackless would use “autologging.__Nested” under Python 2 or “autologging.Outer.__Nested” under Python 3.3+):

class Outer:
   @traced
   class __Nested:
      pass

Warning

Neither Jython nor IronPython currently implement the function.__code__.co_lnotab attribute, so the last line number of a function cannot be determined by Autologging.

Changed in version 1.3.1: Due to unavoidable inconsistencies in line number tracking across Python variants (see issues/6, as of version 1.3.1 and until further notice Autologging will only record the first line number of the function being traced in all tracing CALL and RETURN records. (Note that YIELD tracing records for generator iterators will continue to record the correct line number on variants other than IronPython.)

tvb.interfaces.web.controllers.autologging.install_traced_noop()[source]

Replace the traced() decorator with an identity (no-op) decorator.

Although the overhead of a @traced function or method is minimal when the TRACED log level is disabled, there is still some overhead (the logging level check, an extra function call).

If you would like to completely eliminate this overhead, call this function before any classes or functions in your application are decorated with @traced. The traced() decorator will be replaced with a no-op decorator that simply returns the class or function unmodified.

Note

The recommended way to install the no-op @traced decorator is to set the AUTOLOGGING_TRACED_NOOP environment variable to any non-empty value.

If the AUTOLOGGING_TRACED_NOOP environment variable is set to a non-empty value when Autologging is loaded, the @traced no-op will be installed automatically.

As an alternative to setting the AUTOLOGGING_TRACED_NOOP environment variable, you can also call this function directly in your application’s bootstrap module. For example:

import autologging

if running_in_production:
    autologging.install_traced_noop()

Warning

This function does not “revert” any already-@traced class or function! It simply replaces the autologging.traced module reference with a no-op.

For this reason it is imperative that autologging.install_traced_noop() be called before the @traced decorator has been applied to any class or function in the application. (This is why the AUTOLOGGING_TRACED_NOOP environment variable is the recommended approach for installing the no-op - it allows Autologging itself to guarantee that the no-op is installed before any classes or functions are decorated.)

base_controller

The Main class in this file is initialized in web/run.py to be served on the root of the Web site.

This is the main UI entry point.

class tvb.interfaces.web.controllers.base_controller.BaseController[source]

Bases: builtins.object

This class contains the methods served at the root of the Web site.

error(**data)[source]

Error page to redirect when something extremely bad happened

fill_default_attributes(template_dictionary, escape_db_operations=False)[source]

Fill into ‘template_dictionary’ data that we want to have ready in UI.

fill_overlay_attributes(template_dictionary, title, description, content_template, css_class, tabs_horizontal=None, overlay_indexes=None, tabs_vertical=None)[source]

This method prepares parameters for rendering overlay (overlay.html)

Parameters:
  • title – overlay title
  • description – overlay description
  • content_template – path&name of the template file which will fill overlay content (without .html)
  • css_class – CSS class to be applied on overlay
  • tabs_horizontal – list of strings containing names of the tabs spread horizontally
  • tabs_vertical – list of strings containing names of the tabs spread vertically
static get_url_adapter(step_key, adapter_id, back_page=None)[source]

Compute the URLs for a given adapter. Same URL is used both for GET and POST.

index()[source]

/ Path response Redirects to /tvb

static mark_file_for_delete(file_name, delete_parent_folder=False)[source]

This method stores provided file name in session, and later on when request is done, all these files/folders are deleted

Parameters:
  • file_name – name of the file or folder to be deleted
  • delete_parent_folder – specify if the parent folder of the file should be removed too.
render_adapter_form(adapter_form, is_callout=False)[source]
showBlockerOverlay(**data)[source]

Returns the content of the blocking overlay (covers entire page and do not allow any action)

tvb(error=False, **data)[source]

/tvb URL Returns the home page with the messages stored in the user’s session.

update_operations_count()[source]

If a project is selected, update Operation Numbers in call-out.

common

Constants and functions used by all controllers Custom exceptions

exception tvb.interfaces.web.controllers.common.InvalidFormValues(message, error_dict=None)[source]

Bases: tvb.basic.exceptions.TVBException

Exception to be thrown in case of existing some invalid values in a form.

display_full_errors()[source]
exception tvb.interfaces.web.controllers.common.MissingDataException(message)[source]

Bases: tvb.basic.exceptions.TVBException

exception tvb.interfaces.web.controllers.common.NotAllowed(message, redirect_url)[source]

Bases: tvb.basic.exceptions.TVBException

Raised when accessing a resource is not allowed

exception tvb.interfaces.web.controllers.common.NotAuthenticated(message, redirect_url)[source]

Bases: tvb.interfaces.web.controllers.common.NotAllowed

Raised when accessing a protected method with no user logged in

tvb.interfaces.web.controllers.common.add2session(key, value)[source]

Set in session, at a key, a value

tvb.interfaces.web.controllers.common.expire_session()[source]

Expires and cleans current session.

tvb.interfaces.web.controllers.common.get_current_project()[source]

Get current Project from session

tvb.interfaces.web.controllers.common.get_from_session(attribute)[source]

check if something exists in session and return

tvb.interfaces.web.controllers.common.get_logged_user()[source]

Get current logged User from session

tvb.interfaces.web.controllers.common.get_message_from_session()[source]
tvb.interfaces.web.controllers.common.has_error_message()[source]

check if the session contains an error message

tvb.interfaces.web.controllers.common.pop_message_from_session()[source]

Pops the message stored in the session and it’s type If no message is present returns an empty info message :returns: a message dict

tvb.interfaces.web.controllers.common.remove_from_session(key)[source]

Remove from session an attributes if exists.

tvb.interfaces.web.controllers.common.remove_project_from_session()[source]
tvb.interfaces.web.controllers.common.set_error_message(msg)[source]

Set error message in session

tvb.interfaces.web.controllers.common.set_important_message(msg)[source]

Set info message in session

tvb.interfaces.web.controllers.common.set_info_message(msg)[source]

Set info message in session

tvb.interfaces.web.controllers.common.set_message(msg, m_type='INFO')[source]

Set in session a message of a given type

tvb.interfaces.web.controllers.common.set_warning_message(msg)[source]

Set warning message in session

decorators

Decorators for Cherrypy exposed methods are defined here.

tvb.interfaces.web.controllers.decorators.check_admin(func)[source]

Decorator to check if a user is administrator before accessing a controller method

tvb.interfaces.web.controllers.decorators.check_kc_user(func)[source]

Decorator used to check if the incoming request has a valid keycloak refresh token

tvb.interfaces.web.controllers.decorators.check_kube_user(func)[source]
tvb.interfaces.web.controllers.decorators.check_user(func)[source]

Decorator to check if a user is logged before accessing a controller method.

tvb.interfaces.web.controllers.decorators.context_selected(func)[source]

Decorator to check if a project is currently selected.

tvb.interfaces.web.controllers.decorators.expose_endpoint(func)[source]

Equivalent to @cherrypy.expose @check_kc_user

tvb.interfaces.web.controllers.decorators.expose_fragment(template_name)[source]

Equivalent to @cherrypy.expose @handle_error(redirect=False) @using_template2(template) @check_user

tvb.interfaces.web.controllers.decorators.expose_json(func)[source]

Equivalent to @cherrypy.expose @handle_error(redirect=False) @jsonify @check_user

tvb.interfaces.web.controllers.decorators.expose_numpy_array(func)[source]
tvb.interfaces.web.controllers.decorators.expose_page(func)[source]

Equivalent to @cherrypy.expose @handle_error(redirect=True) @using_template2(‘base_template’) @check_user

tvb.interfaces.web.controllers.decorators.handle_error(redirect)[source]

If redirect is true(default) all errors will generate redirects. Generic errors will redirect to the error page. Authentication errors to login pages. If redirect is false redirect will be converted to errors http 500 All errors are logged Redirect false is used by ajax calls

tvb.interfaces.web.controllers.decorators.jsonify(func)[source]

Decorator to wrap all JSON calls, and log on server in case of an exception.

tvb.interfaces.web.controllers.decorators.ndarray_to_http_binary(func)[source]

Decorator to wrap calls that return numpy arrays. It serializes them as binary http response

tvb.interfaces.web.controllers.decorators.profile_func(func)[source]
tvb.interfaces.web.controllers.decorators.settings(func)[source]

Decorator to check if a the settings file exists before allowing access to some parts of TVB.

tvb.interfaces.web.controllers.decorators.using_template(template_name)[source]

Decorator that renders a template

flow_controller

Steps which a user needs to execute for achieving a given action are described here.

class tvb.interfaces.web.controllers.flow_controller.FlowController[source]

Bases: tvb.interfaces.web.controllers.base_controller.BaseController

This class takes care of executing steps in projects.

NEW_SELECTION_NAME = 'New selection'
cancel_or_remove_operation(operation_id, is_group, remove_after_stop=False)[source]

Stop the operation given by operation_id. If is_group is true stop all the operations from that group.

create_row_of_specs(count)[source]
default(step_key, adapter_key, cancel=False, back_page=None, **data)[source]

Render a specific adapter. ‘data’ are arguments for POST

execute_post(project_id, submit_url, step_key, algorithm, **data)[source]

Execute HTTP POST on a generic step.

fill_default_attributes(template_dictionary, title='-')[source]

Overwrite base controller to add required parameters for adapter templates.

get_adapter_template(project_id, algorithm_id, is_upload=False, back_page=None, is_callout=False)[source]

Get the template for an adapter based on the algo group id.

get_available_selections(**data)[source]
get_filtered_datatypes(dt_module, dt_class, filters, has_all_option, has_none_option)[source]

Given the name from the input tree, the dataType required and a number of filters, return the available dataType that satisfy the conditions imposed.

get_pse_filters()[source]
get_simple_adapter_interface(algorithm_id, parent_div='', is_uploader=False)[source]

AJAX exposed method. Will return only the interface for a adapter, to be used when tabs are needed.

get_template_for_adapter(project_id, step_key, stored_adapter, submit_url, is_burst=True, is_callout=False)[source]

Get Input HTML Interface template or a given adapter

getadapterinterface(project_id, algorithm_id, back_page=None)[source]

AJAX exposed method. Will return only a piece of a page, to be integrated as part in another page.

invoke_adapter(algo_id, method_name, entity_gid, **kwargs)[source]
prepare_group_launch(group_gid, step_key, algorithm_id, **data)[source]

Receives as input a group gid and an algorithm given by category and id, along with data that gives the name of the required input parameter for the algorithm. Having these generate a range of GID’s for all the DataTypes in the group and launch a new operation group.

read_binary_datatype_attribute(entity_gid, method_name, datatype_kwargs='null', **kwargs)[source]
read_datatype_attribute(entity_gid, dataset_name, flatten=False, datatype_kwargs='null', **kwargs)[source]

Retrieve from a given DataType a property or a method result.

Returns:

JSON representation of the attribute.

Parameters:
  • entity_gid – GID for DataType entity
  • dataset_name – name of the dataType property /method
  • flatten – result should be flatten before return (use with WebGL data mainly e.g vertices/triangles) Ignored if the attribute is not an ndarray
  • datatype_kwargs – if passed, will contain a dictionary of type {‘name’ : ‘gid’}, and for each such pair, a load_entity will be performed and kwargs will be updated to contain the result
  • kwargs – extra parameters to be passed when dataset_name is method.
read_from_h5_file(entity_gid, method_name, flatten=False, datatype_kwargs='null', **kwargs)[source]
readserverstaticfile(coded_path)[source]

Retrieve file from Local storage, having a File System Path.

reload_burst_operation(operation_id, is_group, **_)[source]

Find out from which burst was this operation launched. Set that burst as the selected one and redirect to the burst page.

reloadoperation(operation_id, **_)[source]

Redirect to Operation Input selection page, with input data already selected.

show_group_of_algorithms(step_key, algorithm_ids)[source]
step_analyzers()[source]

Choose exact action/adapter for current step.

step_connectivity()[source]

Display menu for Connectivity Footer tab.

store_exploration_section(val_range, step, dt_group_guid)[source]

Launching method for further simulations.

store_measure_points_selection(ui_name, **data)[source]

Save a MeasurePoints selection (new or update existing entity).

store_pse_filter(config_name, **data)[source]

hpc_controller

REST endpoints that we use while running simulations on HPC nodes.

class tvb.interfaces.web.controllers.hpc_controller.HPCController[source]

Bases: builtins.object

Receive requests from simulation jobs that run on HPC nodes.

encryption_config(simulator_gid, operation_id)[source]
update_status(simulator_gid, operation_id, **data)[source]

kube_controller

class tvb.interfaces.web.controllers.kube_controller.KubeController[source]

Bases: tvb.interfaces.web.controllers.base_controller.BaseController

start_operation_pod(operation_id)[source]
stop_operation_process(operation_id)[source]

settings_controller

class tvb.interfaces.web.controllers.settings_controller.AsciiValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Allow only ascii strings

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 114
class tvb.interfaces.web.controllers.settings_controller.DiskSpaceValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator for TVB disk space / user.

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 109
class tvb.interfaces.web.controllers.settings_controller.MatlabValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator for the number of vertices allowed for a surface

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 113
class tvb.interfaces.web.controllers.settings_controller.PortValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator for OS Port number.

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 110
class tvb.interfaces.web.controllers.settings_controller.SettingsController[source]

Bases: tvb.interfaces.web.controllers.users_controller.UserController

Controller for TVB-Settings web page. Inherit from UserController, to have the same fill_default_attributes method (with versionInfo).

check_db_url(**data)[source]

Action on DB-URL validate button.

settings(save_settings=False, **data)[source]

Main settings page submit and get

validate_matlab_path(**data)[source]

Check if the set path from the ui actually corresponds to a matlab executable.

class tvb.interfaces.web.controllers.settings_controller.SettingsForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate Settings Page inputs.

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = []
declarative_count = 137
fields = {'ADMINISTRATOR_NAME': <All [<UnicodeString object 115 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, <PlainText object 116 regex=re.compile('^[a-zA-Z_\\-0-9]*$')>]>, 'ADMINISTRATOR_DISPLAY_NAME': <All [<UnicodeString object 118 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, <PlainText object 119 regex=re.compile('^[a-zA-Z_\\-0-9]*$')>]>, 'ADMINISTRATOR_PASSWORD': <UnicodeString object 121 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'ADMINISTRATOR_EMAIL': <Email object 122 not_empty=True>, 'WEB_SERVER_PORT': <PortValidator object 123>, 'SELECTED_DB': <UnicodeString object 124 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'URL_VALUE': <UnicodeString object 125 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'DEPLOY_CLUSTER': <Bool object 126>, 'CLUSTER_SCHEDULER': <UnicodeString object 127 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'KEYCLOAK_CONFIGURATION': <UnicodeString object 128 inputEncoding='utf-8' outputEncoding='utf-8'>, 'KEYCLOAK_WEB_CONFIGURATION': <UnicodeString object 129 inputEncoding='utf-8' outputEncoding='utf-8'>, 'ENABLE_KEYCLOAK_LOGIN': <Bool object 130>, 'TVB_STORAGE': <UnicodeString object 131 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'USR_DISK_SPACE': <DiskSpaceValidator object 132 not_empty=True>, 'MATLAB_EXECUTABLE': <MatlabValidator object 133>, 'MAXIMUM_NR_OF_THREADS': <ThreadNrValidator object 134>, 'MAXIMUM_NR_OF_VERTICES_ON_SURFACE': <SurfaceVerticesNrValidator object 135>, 'MAXIMUM_NR_OF_OPS_IN_RANGE': <Int object 136 max=5000 min=5 not_empty=True>}
pre_validators = []
class tvb.interfaces.web.controllers.settings_controller.SurfaceVerticesNrValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator for the number of vertices allowed for a surface

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
MAX_VALUE = 16777217
declarative_count = 112
class tvb.interfaces.web.controllers.settings_controller.ThreadNrValidator(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator number of threads.

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 111

users_controller

Here, user related tasks are described. Basic authentication processes are described here, but also user related annotation (checked-logged).

class tvb.interfaces.web.controllers.users_controller.EditUserForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate fields on user-edit

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = [<FieldsMatch object 106 field_names=('password', 'password2')>, <RequireIfMissing object 107 present='old_password' required='password'>]
declarative_count = 108
fields = {'old_password': <UnicodeString object 102 if_missing=None inputEncoding='utf-8' outputEncoding='utf-8'>, 'password': <UnicodeString object 103 if_missing=None inputEncoding='utf-8' outputEncoding='utf-8'>, 'password2': <UnicodeString object 104 if_missing=None inputEncoding='utf-8' outputEncoding='utf-8'>, 'email': <Email object 105 if_missing=None>}
pre_validators = []
class tvb.interfaces.web.controllers.users_controller.KeycloakLoginForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate for Login UI Form

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = []
declarative_count = 85
empty_msg = 'Please enter a value'
fields = {'auth_token': <UnicodeString object 84 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8' use_builtins_gettext=False>}
pre_validators = []
class tvb.interfaces.web.controllers.users_controller.LoginForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate for Login UI Form

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = []
declarative_count = 83
empty_msg = 'Please enter a value'
fields = {'username': <UnicodeString object 81 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8' use_builtins_gettext=False>, 'password': <UnicodeString object 82 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8' use_builtins_gettext=False>}
pre_validators = []
class tvb.interfaces.web.controllers.users_controller.RecoveryForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate Recover Password Form

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = []
declarative_count = 101
fields = {'email': <Email object 99 not_empty=True>, 'username': <UnicodeString object 100 inputEncoding='utf-8' not_empty=False outputEncoding='utf-8'>}
pre_validators = []
class tvb.interfaces.web.controllers.users_controller.RegisterForm(*args, **kw)[source]

Bases: formencode.schema.Schema

Validate Register Form

Messages

badDictType:
The input must be dict-like (not a %(type)s: %(value)r)
badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
missingValue:
Missing value
noneType:
The input must be a string (not None)
notExpected:
The input field %(name)s was not expected.
singleValueExpected:
Please provide only one value
chained_validators = [<FieldsMatch object 97 field_names=('password', 'password2')>]
declarative_count = 98
fields = {'username': <All [<UnicodeString object 87 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, <PlainText object 88 regex=re.compile('^[a-zA-Z_\\-0-9]*$')>, <UniqueUsername object 89>]>, 'display_name': <UnicodeString object 91 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'password': <UnicodeString object 92 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'password2': <UnicodeString object 93 inputEncoding='utf-8' not_empty=True outputEncoding='utf-8'>, 'email': <Email object 94 not_empty=True>, 'comment': <UnicodeString object 95 inputEncoding='utf-8' outputEncoding='utf-8'>, 'role': <UnicodeString object 96 inputEncoding='utf-8' outputEncoding='utf-8'>}
pre_validators = []
class tvb.interfaces.web.controllers.users_controller.UniqueUsername(*args, **kw)[source]

Bases: formencode.api.FancyValidator

Custom validator to check that a given user-name is unique.

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)
declarative_count = 86
class tvb.interfaces.web.controllers.users_controller.UserController[source]

Bases: tvb.interfaces.web.controllers.base_controller.BaseController

This class takes care of the user authentication and/or register.

base_url(**data)[source]
check_sso()[source]
create_new(cancel=False, **data)[source]

Create new user with data submitted from UI.

fill_default_attributes(template_dictionary)[source]

Fill into ‘template_dictionary’ data that we want to have ready in UI.

get_color_schemes_json()[source]
get_viewer_color_scheme()[source]
index(**data)[source]

Login page (with or without messages).

is_storage_ready()[source]

Check if all storage updates are done

keycloak_web_config()[source]
logout()[source]

Logging out user and clean session

profile(logout=False, save=False, **data)[source]

Display current user’s profile page. On POST: logout, or save password/email.

recoverpassword(cancel=False, **data)[source]

This form should reset a password for a given userName/email and send a notification message to that email.

register(cancel=False, **data)[source]

This register form send an e-mail to the user and to the site admin.

set_viewer_color_scheme(color_scheme_name)[source]
switch_online_help()[source]

Switch flag that displays online helps

usermanagement(cancel=False, page=1, do_persist=False, **data)[source]

Display a table used for user management.

validate(name)[source]

A link to this page will be sent to the administrator to validate the registration of each user.