Ejemplo n.º 1
0
    def __init__(self, logger=None, conf_file="", param_file=""):
        """

        :param logger:
            the logger object which is used for logging

        :param conf_file:
            the pySPACE conf file

        :param param_file:
            the live-parameter file

        """
        self.logger = logger

        # save raw file names for later
        self.conf_file = conf_file
        self.param_file = param_file

        # load configuration
        pySPACE.load_configuration(conf_file)
        self.conf = pySPACE.configuration

        self.executable_path = os.path.join(pyspace_path, "pySPACE", "tools",
                                            "live", "eegmanager", "eegmanager",
                                            "eegmanager")
        if not os.path.isfile(self.executable_path):
            self.logger.error("cannot find eegmanager executable!")
            self.logger.error("it should be in %s", self.executable_path)
            exit(0)

        # reference to abri-online subprocess
        self.abri_online = None

        # create eeg-streaming subprocess
        self.eegmanager = None
        self.eegmanager_remote = None
        self.create_eegmanager()

        # load parameter file
        self.params = yaml.load(
            open(os.path.join(self.conf.spec_dir, "live_settings",
                              param_file)))
Ejemplo n.º 2
0
    def __init__(self, logger=None, conf_file="", param_file=""):

        """

        :param logger:
            the logger object which is used for logging

        :param conf_file:
            the pySPACE conf file

        :param param_file:
            the live-parameter file

        """
        self.logger = logger

        # save raw file names for later
        self.conf_file = conf_file
        self.param_file = param_file

        # load configuration
        pySPACE.load_configuration(conf_file)
        self.conf = pySPACE.configuration


        self.executable_path = os.path.join(pyspace_path, "pySPACE", "tools", "live", "eegmanager", "eegmanager", "eegmanager")
        if not os.path.isfile(self.executable_path):
            self.logger.error("cannot find eegmanager executable!")
            self.logger.error("it should be in %s", self.executable_path)
            exit(0)

        # reference to abri-online subprocess
        self.abri_online = None

        # create eeg-streaming subprocess
        self.eegmanager = None
        self.eegmanager_remote = None
        self.create_eegmanager()

        # load parameter file
        self.params = yaml.load(open(os.path.join(self.conf.spec_dir, "live_settings", param_file)))
Ejemplo n.º 3
0
def main():
    #### Find pySPACE package and import it ####

    # Determine path of current file
    path = os.path.realpath(__file__)

    # Move up to parent directory that contains the pySPACE tree
    suffix = []
    for i in range(3):
        path, tail = os.path.split(path)
        suffix.append(tail)
    parent_dir = path

    # Check proper directory structure
    if suffix != ['launch.py', 'run', 'pySPACE']:
        raise RuntimeError, "Encountered incorrect directory structure. "\
                            "launch.py needs to reside in $PARENT_DIR/pySPACE/run"

    # Workaround for eegserver crashing after 255 open ports
    # - Now it crashes after 4096 open ports ;-)
    import resource
    (fd1, fd2) = resource.getrlimit(resource.RLIMIT_NOFILE)
    fd1 = 4096 if fd2 == resource.RLIM_INFINITY else fd2 - 1
    resource.setrlimit(resource.RLIMIT_NOFILE, (fd1, fd2))
    # ------------------------------------------------------

    #########################################

    ### Parsing of command line arguments
    usage = "Usage: %prog [BACKEND_SPECIFICATION]  [--config <conf.yaml>] "\
            "[--operation <operation.yaml> | --operation_chain <operation_chain.yaml>] "\
            "[--profile]"\
            " where BACKEND_SPECIFICATION can be --serial, --mcore, --loadl or --mpi"

    parser = LaunchParser(usage=usage, epilog=epilog)

    # Configuration
    parser.add_option(
        "-c",
        "--configuration",
        help=
        "Choose the configuration file, which is looked up in PYSPACE_CONF_DIR",
        action="store")
    # Backends
    parser.add_option(
        "-s",
        "--serial",
        action="store_true",
        default=False,
        help="Enables execution on the SerialBackend (one local process)")
    parser.add_option(
        "-m",
        "--mcore",
        action="store_true",
        default=False,
        help=
        "Enables execution on the MulticoreBackend (one process per CPU core)")
    parser.add_option(
        "-l",
        "--local",
        action="store_true",
        default=False,
        help=
        "Enables execution on the MulticoreBackend (one process per CPU core)")
    parser.add_option("-i",
                      "--mpi",
                      action="store_true",
                      default=False,
                      help="Enables execution via MPI")
    parser.add_option("-L",
                      "--loadl",
                      action="store_true",
                      default=False,
                      help="Enables execution via LoadLeveler.")
    # Operation / operation chain
    parser.add_option("-o",
                      "--operation",
                      help="Chooses the operation that will be executed. The "
                      "operation specification file is looked up in "
                      "$SPEC_DIR/operations",
                      action="store")
    parser.add_option(
        "-O",
        "-C",
        "--operation_chain",
        help="Chooses the operation chain that will be executed. "
        "The operation chain specification file is looked up "
        "in $SPEC_DIR/operation_chains",
        action="store")
    # Profiling
    parser.add_option(
        "-p",
        "--profile",
        help="Profiles execution.",
        action="store_true",
        default=False,
    )

    (options, args) = parser.parse_args()

    # Load configuration file
    pySPACE.load_configuration(options.configuration)

    if hasattr(pySPACE.configuration, "eeg_acquisition_dir"):
        eeg_parent_dir =\
        os.sep.join(pySPACE.configuration.eeg_acquisition_dir.split(os.sep)[:-1])
        if not hasattr(pySPACE.configuration, "eeg_acquisition_dir"):
            pySPACE.configuration.eeg_module_path = eeg_parent_dir
    else:
        eeg_parent_dir, tail = os.path.split(parent_dir)
        eeg_parent_dir = os.path.join(eeg_parent_dir, "eeg_modules")
        pySPACE.configuration.eeg_module_path = eeg_parent_dir
    sys.path.append(eeg_parent_dir)

    # Create backend
    if options.serial:
        default_backend = create_backend("serial")
    elif options.mcore or options.local:
        default_backend = create_backend("mcore")
    elif options.mpi:
        default_backend = create_backend("mpi")
    elif options.loadl:
        default_backend = create_backend("loadl")
    else:  # Falling back to serial backend
        default_backend = create_backend("serial")

    print(" --> Using backend: \n\t\t %s." % str(default_backend))

    if not options.operation is None:
        # Create operation for the given name
        operation = create_operation_from_file(options.operation)
        # Store current source code for later inspection
        create_source_archive(archive_path=operation.get_output_directory())
        if not options.profile:
            # Execute the current operation
            run_operation(default_backend, operation)
        else:
            # Execute and profile operation
            cProfile.runctx('pySPACE.run_operation(default_backend, operation)',
                            globals(), locals(),
                            filename = operation.get_output_directory()\
                                       + os.sep + "profile.pstat")
    elif not options.operation_chain is None:
        # Create operation chain for the given name
        operation_chain = create_operation_chain(options.operation_chain)
        # Store current source code for later inspection
        create_source_archive(
            archive_path=operation_chain.get_output_directory())

        if not options.profile:
            # Execute the current operation_chain
            run_operation_chain(default_backend, operation_chain)
        else:
            # Execute and profile operation
            cProfile.runctx('pySPACE.run_operation_chain(default_backend, operation_chain)',
                            globals(), locals(),
                            filename=operation_chain.get_output_directory()\
                                     + os.sep + "profile.pstat")
    else:
        parser.error(
            "Neither operation chain nor operation specification file given!")

    logging.shutdown()
    # Stop logger thread in backend
    default_backend._stop_logging()

    del default_backend
Ejemplo n.º 4
0
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os, inspect

# Add root of the tree --> go to place before docs
root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
if not root_dir in sys.path:
    sys.path.append(root_dir)

import pySPACE
try:
    pySPACE.load_configuration("config.yaml")
except:
    pass
import pySPACE.missions.nodes

# If your extensions are in another directory, add it here. If the directory
# is relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
#sys.path.append(os.path.abspath('.'))

# General configuration
# ---------------------

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
# autodoc is an extension to extract documentation automatically
Ejemplo n.º 5
0
    if os.path.isdir (path_param):
        online_logger.info( "parameters file backup successful!")


    online_logger.info("Creating backup finished!")

if __name__ == "__main__":

    (options,args) = parse_arguments()

    server_process = None

    if options.remote:
        online_logger.info("Starting remote modus")
        conf_file_name = options.configuration
        conf = pySPACE.load_configuration(conf_file_name)
        adrf = pySPACE.environments.live.communication.adrf_messenger.AdrfMessenger()
        adrf.register()
        # register the interface with ADRF
        online_logger.info("Starting event loop")
        while True:
            online_logger.info("Check register status")
            time.sleep(0.5)
            while adrf.is_registered():
                #online_logger.info("Get command")
                command = adrf.adrf_receive_command()

                if command[0] == 3: # 3 = C_CONFIGURE
                    online_logger.info( "received command: C_CONFIGURE")
                    online_logger.info( "Loading parameter file..")
Ejemplo n.º 6
0
def main():
    #### Find pySPACE package and import it ####

    # Determine path of current file
    path = os.path.realpath(__file__)

    # Move up to parent directory that contains the pySPACE tree
    suffix = []
    for i in range(3):
        path, tail = os.path.split(path)
        suffix.append(tail)
    parent_dir = path

    # Check proper directory structure
    if suffix != ['launch.py', 'run', 'pySPACE']:
        raise RuntimeError, "Encountered incorrect directory structure. "\
                            "launch.py needs to reside in $PARENT_DIR/pySPACE/run"


    # Workaround for eegserver crashing after 255 open ports
    # - Now it crashes after 4096 open ports ;-)
    import resource
    (fd1, fd2) = resource.getrlimit(resource.RLIMIT_NOFILE)
    fd1 = 4096 if fd2 == resource.RLIM_INFINITY else fd2-1
    resource.setrlimit(resource.RLIMIT_NOFILE, (fd1,fd2))
    # ------------------------------------------------------

    #########################################

    ### Parsing of command line arguments
    usage = "Usage: %prog [BACKEND_SPECIFICATION]  [--config <conf.yaml>] "\
            "[--operation <operation.yaml> | --operation_chain <operation_chain.yaml>] "\
            "[--profile]"\
            " where BACKEND_SPECIFICATION can be --serial, --mcore, --loadl or --mpi"

    parser = LaunchParser(usage=usage, epilog=epilog)

    # Configuration
    parser.add_option("-c", "--configuration",
                      default="config.yaml",
                      help="Choose the configuration file, which is looked up in PYSPACE_CONF_DIR",
                      action="store")
    # Backends
    parser.add_option("-s", "--serial", action="store_true", default=False,
                      help="Enables execution on the SerialBackend (one local process)")
    parser.add_option("-m", "--mcore", action="store_true", default=False,
                      help="Enables execution on the MulticoreBackend (one process per CPU core)")
    parser.add_option("-l", "--local", action="store_true", default=False,
                      help="Enables execution on the MulticoreBackend (one process per CPU core)")
    parser.add_option("-i", "--mpi", action="store_true", default=False,
                      help="Enables execution via MPI")
    parser.add_option("-L", "--loadl", action="store_true", default=False,
                      help="Enables execution via LoadLeveler.")
    # Operation / operation chain
    parser.add_option("-o", "--operation",
                      help="Chooses the operation that will be executed. The "
                           "operation specification file is looked up in "
                           "$SPEC_DIR/operations",
                      action="store")
    parser.add_option("-O", "-C", "--operation_chain",
                      help="Chooses the operation chain that will be executed. "
                           "The operation chain specification file is looked up "
                           "in $SPEC_DIR/operation_chains",
                      action="store")
    # Profiling
    parser.add_option("-p", "--profile",
                      help="Profiles execution.",
                      action="store_true", default=False,)

    (options, args) = parser.parse_args()

    # Load configuration file
    pySPACE.load_configuration(options.configuration)

    if hasattr(pySPACE.configuration, "eeg_acquisition_dir"):
        eeg_parent_dir =\
        os.sep.join(pySPACE.configuration.eeg_acquisition_dir.split(os.sep)[:-1])
        if not hasattr(pySPACE.configuration, "eeg_acquisition_dir"):
            pySPACE.configuration.eeg_module_path = eeg_parent_dir
    else:
        eeg_parent_dir, tail = os.path.split(parent_dir)
        eeg_parent_dir = os.path.join(eeg_parent_dir, "eeg_modules")
        pySPACE.configuration.eeg_module_path = eeg_parent_dir
    sys.path.append(eeg_parent_dir)

    # Create backend
    if options.serial:
        default_backend = create_backend("serial")
    elif options.mcore or options.local:
        default_backend = create_backend("mcore")
    elif options.mpi:
        default_backend = create_backend("mpi")
    elif options.loadl:
        default_backend = create_backend("loadl")
    else: # Falling back to serial backend
        default_backend = create_backend("serial")

    print(" --> Using backend: \n\t\t %s."%str(default_backend))

    if not options.operation is None:
        # Create operation for the given name
        operation = create_operation_from_file(options.operation)
        # Store current source code for later inspection
        create_source_archive(archive_path=operation.get_output_directory())
        if not options.profile:
            # Execute the current operation
            run_operation(default_backend, operation)
        else:
            # Execute and profile operation
            cProfile.runctx('pySPACE.run_operation(default_backend, operation)',
                            globals(), locals(),
                            filename = operation.get_output_directory()\
                                       + os.sep + "profile.pstat")
    elif not options.operation_chain is None:
        # Create operation chain for the given name
        operation_chain = create_operation_chain(options.operation_chain)
        # Store current source code for later inspection
        create_source_archive(archive_path=operation_chain.get_output_directory())

        if not options.profile:
            # Execute the current operation_chain
            run_operation_chain(default_backend, operation_chain)
        else:
            # Execute and profile operation
            cProfile.runctx('pySPACE.run_operation_chain(default_backend, operation_chain)',
                            globals(), locals(),
                            filename=operation_chain.get_output_directory()\
                                     + os.sep + "profile.pstat")
    else:
        parser.error("Neither operation chain nor operation specification file given!")

    logging.shutdown()
    # Stop logger thread in backend
    default_backend._stop_logging()

    del default_backend
Ejemplo n.º 7
0
if __name__ == '__main__':
    #Creating Qt application
    app = QtGui.QApplication(sys.argv) 
    gui = PySpaceGui()

    # Let user select a configuration file
    config_file = \
        str(QtGui.QFileDialog.getOpenFileName(gui, "Select a configuration file ",
                                              os.sep.join([parent_dir, "docs","examples", "conf"]),
                                              "configuration files (*.yaml)"))
    config_file = config_file.split(os.sep)[-1]
     
    # Load configuration file
    import pySPACE
    pySPACE.load_configuration(config_file)

    gui.set_up()
    gui.show()
 
    #Initing application
    sys.exit(app.exec_())

class ControlWidget(QtGui.QWidget):
    """ Widget for configuring a node chain operation and monitor its progress. """

    # Two signals that are used to provide the GUI with the status of the
    # running operation.
    operationStatusChangedSignal = \
                QtCore.pyqtSignal(int, name='operationStatusChanged')
Ejemplo n.º 8
0
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os, inspect

# Add root of the tree --> go to place before docs
root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
if not root_dir in sys.path:
    sys.path.append(root_dir)

import pySPACE
try:
    pySPACE.load_configuration("config.yaml")
except:
    pass
import pySPACE.missions.nodes

# If your extensions are in another directory, add it here. If the directory
# is relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
#sys.path.append(os.path.abspath('.'))

# General configuration
# ---------------------

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
# autodoc is an extension to extract documentation automatically
Ejemplo n.º 9
0
    if os.path.isdir(path_param):
        online_logger.info("parameters file backup successful!")

    online_logger.info("Creating backup finished!")


if __name__ == "__main__":

    (options, args) = parse_arguments()

    server_process = None

    if options.remote:
        online_logger.info("Starting remote modus")
        conf_file_name = options.configuration
        conf = pySPACE.load_configuration(conf_file_name)
        adrf = pySPACE.environments.live.communication.adrf_messenger.AdrfMessenger(
        )
        adrf.register()
        # register the interface with ADRF
        online_logger.info("Starting event loop")
        while True:
            online_logger.info("Check register status")
            time.sleep(0.5)
            while adrf.is_registered():
                #online_logger.info("Get command")
                command = adrf.adrf_receive_command()

                if command[0] == 3:  # 3 = C_CONFIGURE
                    online_logger.info("received command: C_CONFIGURE")
                    online_logger.info("Loading parameter file..")
Ejemplo n.º 10
0
                        ' results to the terminal screen instead of to the ' +
                        ' log file')

    parser.add_argument('-sn', '--singlenode', default="",
                        help='If you want to test a single node, specify it ' +
                             'under the SINGLENODE variable')

    parser.add_argument('-r', '--report', default=False,
                        action='store_true',
                        help='Decides whether an HTML report should be ' +
                        'generated from the results of the unittest')

    parser.add_argument('-c', '--configfile', default=None,
                        help="Specify a different name for the configuration"
                             "file that is to be used by pySPACE")

    args = parser.parse_args()

    # if the user gave a different configuration file, use the new file

    if args.configfile is not None:
        pySPACE.load_configuration(args.configfile)
    else:
        pySPACE.load_configuration()

    # The single node execution is done by default under verbose mode
    if args.singlenode != "":
        single_node_testing(args.singlenode)
    else:
        multiple_node_testing(args.verbose, args.report)
Ejemplo n.º 11
0
                        help='If you want to test a single node, specify it ' +
                        'under the SINGLENODE variable')

    parser.add_argument('-r',
                        '--report',
                        default=False,
                        action='store_true',
                        help='Decides whether an HTML report should be ' +
                        'generated from the results of the unittest')

    parser.add_argument('-c',
                        '--configfile',
                        default=None,
                        help="Specify a different name for the configuration"
                        "file that is to be used by pySPACE")

    args = parser.parse_args()

    # if the user gave a different configuration file, use the new file

    if args.configfile is not None:
        pySPACE.load_configuration(args.configfile)
    else:
        pySPACE.load_configuration()

    # The single node execution is done by default under verbose mode
    if args.singlenode != "":
        single_node_testing(args.singlenode)
    else:
        multiple_node_testing(args.verbose, args.report)