def test_create_and_config(tmpdir):
    a = tmpdir.mkdir("a")
    b = tmpdir.mkdir("b")
    ef = ExecutableFinder([str(a), str(b)])
    assert ef.binary_paths == "{} : {}".format(a, b)
    c = tmpdir.mkdir("c")
    ef.add_path(str(c))
    assert ef.binary_paths == "{} : {} : {}".format(a, b, c)
def test_find_no_duplicates(tmpdir):
    a = tmpdir.mkdir("a")
    b = tmpdir.mkdir("b")
    ef = ExecutableFinder([str(a), str(b)])
    assert ef.binary_paths == "{} : {}".format(a, b)
    ef.add_path(str(a))
    ef.add_path(str(a))
    ef.add_path(str(b))
    ef.add_path(str(b))
    ef.add_path(str(a))
    ef.add_path(str(a))
    ef.add_path(str(b))
    ef.add_path(str(b))
    assert ef.binary_paths == "{} : {}".format(a, b)
Exemplo n.º 3
0
    def compress(self, register):
        """ Apply the on-machine compression algorithm.

        :param int register: number of user register to check
        """
        # pylint: disable=too-many-arguments

        # build progress bar
        progress_bar = ProgressBar(
            len(self._routing_tables.routing_tables) * 2,
            self._progresses_text)

        self._compressor_app_id = self._transceiver.app_id_tracker.get_new_id()

        # figure size of SDRAM needed for each chip for storing the routing
        # table
        for routing_table in progress_bar.over(self._routing_tables, False):
            self._load_routing_table(routing_table)

        # load the router compressor executable
        executable_targets = self._load_executables()

        executable_finder = ExecutableFinder(binary_search_paths=[])
        read_algorithm_iobuf = True
        run_system_application(
            executable_targets, self._compressor_app_id, self._transceiver,
            self._provenance_file_path, executable_finder,
            read_algorithm_iobuf,
            functools.partial(
                self._check_for_success,
                register=register),
            [CPUState.FINISHED], False, "compressor_on_{}_{}_{}.txt",
            [self._binary_path], progress_bar)
    def __init__(self,
                 binary_search_paths=None,
                 include_common_binaries_folder=True):
        """

        :param binary_search_paths: The initial set of folders to search for\
                    binaries.
        :type binary_search_paths: iterable of str
        :param include_common_binaries_folder: If True (i.e. the default), \
                    the spinn_front_end_common.common_model_binaries folder \
                    is searched for binaries.  If you are not using the common\
                    models, or the model binary names conflict with your own,\
                    this parameter can be used to avoid this issue.  Note that\
                    the folder will be appended to the value of\
                    binary_search_paths, so the common binary search path will\
                    be looked in last.
        :type include_common_binaries_folder: bool
        """
        if binary_search_paths is None:
            binary_search_paths = list()
        BaseEF.__init__(self, binary_search_paths)
        if include_common_binaries_folder:
            self.add_path(os.path.dirname(common_model_binaries.__file__))
def test_find_in_two_places(tmpdir):
    a = tmpdir.mkdir("a")
    b = tmpdir.mkdir("b")
    ef = ExecutableFinder([str(a), str(b)])
    w1 = tmpdir.join("a/abc.aplx")
    w1.write("any old content")
    w2 = tmpdir.join("b/abc.aplx")
    w2.write("any old content")
    assert ef.get_executable_path("abc.aplx") == str(w1)
    w1.remove()
    assert ef.get_executable_path("abc.aplx") == str(w2)
    w1.write("any old content")
    assert ef.get_executable_path("abc.aplx") == str(w1)
    w2.remove()
    assert ef.get_executable_path("abc.aplx") == str(w1)
    w1.remove()
    with pytest.raises(KeyError):
        ef.get_executable_path("abc.aplx")
Exemplo n.º 6
0
 def _handle_failure(executable_targets, txrx, provenance_file_path,
                     compressor_app_id):
     """
     :param executable_targets:
     :param txrx: the spinnman interface
     :type txrx: :py:class:`~spinnman.Transceiver`
     :param provenance_file_path:
     :rtype: None
     """
     logger.info("Router compressor has failed")
     iobuf_extractor = ChipIOBufExtractor()
     executable_finder = ExecutableFinder(binary_search_paths=[])
     io_errors, io_warnings = iobuf_extractor(txrx, executable_targets,
                                              executable_finder,
                                              provenance_file_path)
     for warning in io_warnings:
         logger.warning(warning)
     for error in io_errors:
         logger.error(error)
     txrx.stop_application(compressor_app_id)
     txrx.app_id_tracker.free_id(compressor_app_id)
def test_logs(tmpdir):
    if "BINARY_LOGS_DIR" not in os.environ:
        os.environ["BINARY_LOGS_DIR"] = tmpdir.strpath
    a = tmpdir.mkdir("a")
    b = tmpdir.mkdir("b")
    ef = ExecutableFinder([str(a), str(b)])
    ef.add_path("bad_directory_name")
    w = tmpdir.join("a/abc.aplx")
    w.write("any old content")
    w = tmpdir.join("b/def.aplx")
    w.write("any old content")
    w = tmpdir.join("b/ghi.aplx")
    w.write("any old content")
    w = tmpdir.join("b/jkl.aplx")
    w.write("any old content")
    ef.get_executable_path("abc.aplx")
    ef.get_executable_path("jkl.aplx")
    ef2 = ExecutableFinder([])
    ef2.check_logs()
    ef2.clear_logs()
def test_find_in_one_place(tmpdir):
    ef = ExecutableFinder([str(tmpdir)])
    w = tmpdir.join("abc.aplx")
    w.write("any old content")
    assert ef.get_executable_path("abc.aplx") == str(w)
def test_find_in_no_places():
    ef = ExecutableFinder([])
    with pytest.raises(KeyError):
        ef.get_executable_path("abc.aplx")
Exemplo n.º 10
0
text001, result_error001, result_warning001 = mock_text(0, 0, 1)
text002, result_error002, result_warning002 = mock_text(0, 0, 2)
text111, result_error111, result_warning111 = mock_text(1, 1, 1)
text112, result_error112, result_warning112 = mock_text(1, 1, 2)
text003, result_error003, result_warning003 = mock_text(0, 0, 3)

path = os.path.dirname(os.path.abspath(__file__))


def mock_aplx(id):
    return os.path.join(path, "mock{}.aplx".format(id))


extractor = ChipIOBufExtractor()
executableFinder = ExecutableFinder([path])

transceiver = _PretendTransceiver([
    IOBuffer(0, 0, 1, text001),
    IOBuffer(0, 0, 2, text002),
    IOBuffer(1, 1, 1, text111),
    IOBuffer(1, 1, 2, text112),
    IOBuffer(0, 0, 3, text003)
])

executable_targets = ExecutableTargets()
core_subsets = CoreSubsets([CoreSubset(0, 0, [1, 2])])
fooaplx = mock_aplx("foo")
executable_targets.add_subsets(fooaplx, core_subsets)
core_subsets = CoreSubsets([CoreSubset(1, 1, [1, 2])])
baraplx = mock_aplx("bar")