iblrig.base_tasks.NetworkSession

Inheritance diagram of NetworkSession

class iblrig.base_tasks.NetworkSession[source]

A mixin for communicating to auxiliary acquisition PC over a network.

__init__(*_, remote_rigs=None, **kwargs)[source]

A mixin for communicating to auxiliary acquisition PC over a network.

This should retrieve the services list, i.e. the list of available auxiliary rigs, and determine which is the main sync. The main sync is the rig that determines the experiment.

The services list is in a yaml file somewhere, called ‘remote_rigs.yaml’ and should be a map of device name to URI. These are then selectable in the GUI and the URI of those selected are added to the experiment description.

Subclasses should add their callbacks within init by calling self.remote_rigs.services.assign_callback().

Parameters:
  • remote_rigs (list, dict) – Either a list of remote device names (in which case URI is looked up from remote devices file), or a map of device name to URI.

  • kwargs – Optional args such as ‘file_iblrig_settings’ for defining location of remote data folder when loading remote devices file.

cleanup_mixin_network()[source]

Clean up services.

communicate(message, *args, raise_on_exception=True)[source]

Communicate message to remote services.

This method is blocking and by default will raise if not all responses received in time.

Parameters:
  • message (iblutil.io.net.base.ExpMessage, str, int) – An experiment message to send to remote services.

  • args – One or more optional variables to send.

  • raise_on_exception (bool) – If true, exceptions arising from message timeouts will be re-raised in main thread and services will be cleaned up. Only applies when wait is true.

Returns:

If raise_on_exception is False, returns an exception if failed to receive all responses in time, otherwise a map of service name to response is returned.

Return type:

Exception | dict

connect(remote_rigs)[source]

Connect to remote services.

Instantiates the Communicator objects that establish connections with each remote device. This also creates the thread that uses asynchronous callbacks.

Parameters:

remote_rigs (dict) – A map of name to URI.

get_exp_info()[source]
init_mixin_network()[source]

Initialize remote services.

This method sends an EXPINFO message to all services, expecting exactly one of the responses to contain main_sync: True, along with the experiment reference to use. It then sends an EXPINIT message to all services.

run()[source]

Run session and report exceptions to remote services.

start_mixin_network()[source]

Start remote services.

This method sends an EXPSTART message to all services, along with an exp_ref string. Responses are required but ignored.

stop_mixin_network()[source]

Start remote services.

This method sends an EXPEND message to all services. Responses are required but ignored.

exp_ref = None

The experiment reference (i.e. subject, date, sequence) as returned by main remote service.

Type:

dict

property one

Return ONE instance.

Unlike super class getter, this method will always instantiate ONE, allowing subclasses to update with an Alyx token from a remotely connected rig. This instance is used for formatting the experiment reference string.

Returns:

An instance of ONE.

Return type:

one.api.One

remote_rigs = None

An auxiliary services object for communicating with remote devices.

Type:

net.Auxiliaries