• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SpiNNakerManchester / SpiNNFrontEndCommon / 8246920254

12 Mar 2024 10:03AM UTC coverage: 47.983% (+0.01%) from 47.973%
8246920254

push

github

web-flow
Merge pull request #1163 from SpiNNakerManchester/live_tweaks

Live tweaks

2046 of 4791 branches covered (42.71%)

Branch coverage included in aggregate %.

6 of 12 new or added lines in 3 files covered. (50.0%)

1 existing line in 1 file now uncovered.

5485 of 10904 relevant lines covered (50.3%)

0.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.54
/spinn_front_end_common/interface/interface_functions/database_interface.py
1
# Copyright (c) 2015 The University of Manchester
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     https://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14

15
import logging
1✔
16
from typing import Optional, Set, Tuple
1✔
17
from spinn_utilities.config_holder import (
1✔
18
    get_config_bool, get_config_bool_or_none)
19
from spinn_utilities.progress_bar import ProgressBar
1✔
20
from spinn_utilities.log import FormatAdapter
1✔
21
from pacman.model.graphs.machine import MachineVertex
1✔
22
from spinn_front_end_common.utilities.database import DatabaseWriter
1✔
23
from spinn_front_end_common.abstract_models import (
1✔
24
    AbstractSupportsDatabaseInjection)
25
from spinn_front_end_common.data import FecDataView
1✔
26

27
logger = FormatAdapter(logging.getLogger(__name__))
1✔
28

29

30
def database_interface(runtime: Optional[float]) -> Optional[str]:
1✔
31
    """
32
    :param int runtime:
33
    :return: where the database is located, if one is made
34
    :rtype: str or None
35
    """
36
    needs_db = DatabaseWriter.auto_detect_database()
1✔
37
    user_create_database = get_config_bool_or_none(
1✔
38
        "Database", "create_database")
39
    if user_create_database is not None:
1!
40
        if user_create_database != needs_db:
1!
41
            logger.warning(
×
42
                "Database creating changed to {} due to cfg settings",
43
                user_create_database)
44
            needs_db = user_create_database
×
45
    if not needs_db:
1!
46
        return None
×
47

48
    with DatabaseWriter() as writer:
1✔
49
        logger.info("Creating live event connection database in {}",
1✔
50
                    writer.database_path)
51
        _write_to_db(writer, runtime)
1✔
52
        return writer.database_path
1✔
53

54

55
def _write_to_db(w: DatabaseWriter, runtime: Optional[float]):
1✔
56
    """
57
    :param DatabaseWriter w:
58
    :param int runtime:
59
    """
60
    with ProgressBar(6, "Creating graph description database") as p:
1✔
61
        w.add_system_params(runtime)
1✔
62
        w.add_proxy_configuration()
1✔
63
        p.update()
1✔
64
        w.add_machine_objects()
1✔
65
        p.update()
1✔
66
        w.add_application_vertices()
1✔
67
        p.update()
1✔
68
        w.add_placements()
1✔
69
        p.update()
1✔
70
        w.add_tags()
1✔
71
        p.update()
1✔
72
        lpg_source_machine_vertices = w.add_lpg_mapping()
1✔
73

74
        if get_config_bool(
1!
75
                "Database", "create_routing_info_to_neuron_id_mapping"):
76
            machine_vertices: Set[Tuple[MachineVertex, str]] = {
1!
77
                (vertex, vertex.injection_partition_id)
78
                for vertex in FecDataView.iterate_machine_vertices()
79
                if isinstance(vertex, AbstractSupportsDatabaseInjection)
80
                and vertex.is_in_injection_mode}
81
            machine_vertices.update(lpg_source_machine_vertices)
1✔
82
            live_vertices = FecDataView.iterate_live_output_vertices()
1✔
83
            for vertex, part_id in live_vertices:
1!
NEW
84
                machine_vertices.update(
×
85
                    (m_vertex, part_id)
86
                    for m_vertex in vertex.splitter.get_out_going_vertices(
87
                        part_id))
88
            w.create_atom_to_event_id_mapping(machine_vertices)
1✔
89
            w.create_device_atom_event_id_mapping(
1✔
90
                FecDataView.iterate_live_output_devices())
91
        p.update()
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc