From c32394df0a59318819f64338716c4535faec4329 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Wed, 27 Oct 2021 14:46:07 +0100 Subject: [PATCH 1/6] Add provenance writing for app_vertex --- .../interface/provenance/db.sql | 9 +++++++++ .../interface/provenance/provenance_writer.py | 19 +++++++++++++++++++ .../provenance/test_provenance_database.py | 8 ++++++++ 3 files changed, 36 insertions(+) diff --git a/spinn_front_end_common/interface/provenance/db.sql b/spinn_front_end_common/interface/provenance/db.sql index a7d278b27e..f1bf86edf1 100644 --- a/spinn_front_end_common/interface/provenance/db.sql +++ b/spinn_front_end_common/interface/provenance/db.sql @@ -193,4 +193,13 @@ CREATE TABLE IF NOT EXISTS connector_provenance( description STRING NOT NULL, the_value INTEGER NOT NULL); +-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +-- A table app vertex provenance +CREATE TABLE IF NOT EXISTS app_vertex_provenance( + app_vertex_id INTEGER PRIMARY KEY AUTOINCREMENT, + population STRING NOT NULL, + the_type STRING NOT NULL, + description STRING NOT NULL, + the_value INTEGER NOT NULL); + diff --git a/spinn_front_end_common/interface/provenance/provenance_writer.py b/spinn_front_end_common/interface/provenance/provenance_writer.py index 6dac389395..5610af5828 100644 --- a/spinn_front_end_common/interface/provenance/provenance_writer.py +++ b/spinn_front_end_common/interface/provenance/provenance_writer.py @@ -268,3 +268,22 @@ def insert_connector( """, [pre_population, post_population, the_type, description, the_value]) + + def insert_app_vertex( + self, population, the_type, description, the_value): + """ + Inserts population level data into the app_vertex_provenance + + :param str population: Name of the post population / vertex + :param str the_type: Class of the app_vertex + :param str description: type of value + :param float the_value: data + """ + with self.transaction() as cur: + cur.execute( + """ + INSERT OR IGNORE INTO app_vertex_provenance( + population, the_type, description, the_value) + VALUES(?, ?, ?, ?) + """, + [population, the_type, description, the_value]) diff --git a/unittests/interface/provenance/test_provenance_database.py b/unittests/interface/provenance/test_provenance_database.py index f2c88d2dd0..6c9b51f887 100644 --- a/unittests/interface/provenance/test_provenance_database.py +++ b/unittests/interface/provenance/test_provenance_database.py @@ -157,3 +157,11 @@ def test_connector(self): data = reader.run_query("Select * from connector_provenance") expected = [(1, 'the pre', 'A post', 'OneToOne', 'foo', 12)] self.assertListEqual(expected, data) + + def test_app_vertex(self): + with ProvenanceWriter() as db: + db.insert_app_vertex("pop", "type", "description", 0.5) + reader = ProvenanceReader() + data = reader.run_query("Select * from app_vertex_provenance") + expected = [(1, 'pop', 'type', 'description', 0.5)] + self.assertListEqual(expected, data) From 3d682df08980a88b13674ac470d89ae4b7d7c51f Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Wed, 27 Oct 2021 16:27:17 +0100 Subject: [PATCH 2/6] Use the correct type --- spinn_front_end_common/interface/provenance/db.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spinn_front_end_common/interface/provenance/db.sql b/spinn_front_end_common/interface/provenance/db.sql index f1bf86edf1..4790b467d8 100644 --- a/spinn_front_end_common/interface/provenance/db.sql +++ b/spinn_front_end_common/interface/provenance/db.sql @@ -200,6 +200,6 @@ CREATE TABLE IF NOT EXISTS app_vertex_provenance( population STRING NOT NULL, the_type STRING NOT NULL, description STRING NOT NULL, - the_value INTEGER NOT NULL); + the_value FLOAT NOT NULL); From 8ca2f047f661e20d9286b458784b24b4a57f2e69 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Fri, 22 Jul 2022 10:45:04 +0100 Subject: [PATCH 3/6] Rename to label as that's what is being used --- spinn_front_end_common/interface/provenance/db.sql | 4 ++-- .../interface/provenance/provenance_writer.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spinn_front_end_common/interface/provenance/db.sql b/spinn_front_end_common/interface/provenance/db.sql index 161cab4d75..b8d0a19b96 100644 --- a/spinn_front_end_common/interface/provenance/db.sql +++ b/spinn_front_end_common/interface/provenance/db.sql @@ -223,7 +223,7 @@ CREATE TABLE IF NOT EXISTS boards_provenance( -- A table app vertex provenance CREATE TABLE IF NOT EXISTS app_vertex_provenance( app_vertex_id INTEGER PRIMARY KEY AUTOINCREMENT, - population STRING NOT NULL, - the_type STRING NOT NULL, + label STRING NOT NULL, + the_type STRING NOT NULL, description STRING NOT NULL, the_value FLOAT NOT NULL); diff --git a/spinn_front_end_common/interface/provenance/provenance_writer.py b/spinn_front_end_common/interface/provenance/provenance_writer.py index 47fc0b9811..859470a7a0 100644 --- a/spinn_front_end_common/interface/provenance/provenance_writer.py +++ b/spinn_front_end_common/interface/provenance/provenance_writer.py @@ -319,11 +319,11 @@ def insert_board_provenance(self, connections): for ((x, y), ipaddress) in connections.items())) def insert_app_vertex( - self, population, the_type, description, the_value): + self, label, the_type, description, the_value): """ - Inserts population level data into the app_vertex_provenance + Inserts app level data into the app_vertex_provenance - :param str population: Name of the post population / vertex + :param str label: Label of the app_vertex :param str the_type: Class of the app_vertex :param str description: type of value :param float the_value: data @@ -332,7 +332,7 @@ def insert_app_vertex( cur.execute( """ INSERT OR IGNORE INTO app_vertex_provenance( - population, the_type, description, the_value) + label, the_type, description, the_value) VALUES(?, ?, ?, ?) """, - [population, the_type, description, the_value]) + [label, the_type, description, the_value]) From cd1eaf41beec579120661b670a1f066f9b1c8688 Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Mon, 26 Sep 2022 16:54:54 +0100 Subject: [PATCH 4/6] Merge properly --- spinn_front_end_common/interface/provenance/db.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spinn_front_end_common/interface/provenance/db.sql b/spinn_front_end_common/interface/provenance/db.sql index 5ba7ea4bdd..c8277c7641 100644 --- a/spinn_front_end_common/interface/provenance/db.sql +++ b/spinn_front_end_common/interface/provenance/db.sql @@ -226,7 +226,7 @@ CREATE TABLE IF NOT EXISTS app_vertex_provenance( label STRING NOT NULL, the_type STRING NOT NULL, description STRING NOT NULL, - the_value FLOAT NOT NULL);======= + the_value FLOAT NOT NULL); --------------------------------------------------------------------- -- A table to store log.info From 58dc28a013902babeefa159c095240b52eeb531d Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Fri, 23 Jun 2023 12:30:09 +0100 Subject: [PATCH 5/6] Fix doc strings --- spinn_front_end_common/interface/ds/data_type.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/spinn_front_end_common/interface/ds/data_type.py b/spinn_front_end_common/interface/ds/data_type.py index d34b9b1852..28c7031fbb 100644 --- a/spinn_front_end_common/interface/ds/data_type.py +++ b/spinn_front_end_common/interface/ds/data_type.py @@ -413,8 +413,10 @@ def numpy_typename(self): return self._numpy_typename def closest_representable_value(self, value): - """ Returns the closest value to the given value that can be - represented by this type + """ + Returns the closest value to the given value that can be represented + by this type + :param value: :type value: float or in :rtype: float @@ -422,8 +424,10 @@ def closest_representable_value(self, value): return self.decode_from_int(self.encode_as_int(value)) def closest_representable_value_above(self, value): - """ Returns the closest value above the given value that can be - represented by this type + """ + Returns the closest value above the given value that can be + represented by this type. + :param value: :type value: float or in :rtype: float @@ -457,7 +461,9 @@ def encode_as_int(self, value): return value def decode_from_int(self, value): - """ Decode a single value represented as an int according to this type. + """ + Decode a single value represented as an int according to this type. + :param int array: :rtype: float or int """ From 439ce854930d6cc3faae50802266febf3f7e8e0c Mon Sep 17 00:00:00 2001 From: Andrew Gait Date: Tue, 26 Sep 2023 14:11:54 +0100 Subject: [PATCH 6/6] Update test --- unittests/interface/provenance/test_provenance_database.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unittests/interface/provenance/test_provenance_database.py b/unittests/interface/provenance/test_provenance_database.py index 8fb105cdec..ecdc49c211 100644 --- a/unittests/interface/provenance/test_provenance_database.py +++ b/unittests/interface/provenance/test_provenance_database.py @@ -188,8 +188,8 @@ def test_board(self): def test_app_vertex(self): with ProvenanceWriter() as db: db.insert_app_vertex("pop", "type", "description", 0.5) - reader = ProvenanceReader() - data = reader.run_query("Select * from app_vertex_provenance") + with ProvenanceReader() as db: + data = db.run_query("Select * from app_vertex_provenance") expected = [(1, 'pop', 'type', 'description', 0.5)] self.assertListEqual(expected, data)