Bobby Bruce has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/59273?usp=email )
(
10 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the
submitted one.
)Change subject: stdlib: Rename JsonSerializable to SerializableStat
......................................................................
stdlib: Rename JsonSerializable to SerializableStat
As this abstract class now allows the output of text stats, it's more
appropriate to rename it. It no longer handles processing just for JSON
output
Change-Id: Ia9a1e3ef4029de45a11ac261fb14c9bdfa412cdd
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/59273
Reviewed-by: Bobby Bruce <bbr...@ucdavis.edu>
Tested-by: kokoro <noreply+kok...@google.com>
Maintainer: Bobby Bruce <bbr...@ucdavis.edu>
---
M src/python/SConscript
M src/python/m5/ext/pystats/__init__.py
M src/python/m5/ext/pystats/group.py
R src/python/m5/ext/pystats/serializable_stat.py
M src/python/m5/ext/pystats/simstat.py
M src/python/m5/ext/pystats/statistic.py
M tests/pyunit/pyunit_jsonserializable_check.py
7 files changed, 33 insertions(+), 19 deletions(-)
Approvals:
kokoro: Regressions pass
Bobby Bruce: Looks good to me, approved; Looks good to me, approved
diff --git a/src/python/SConscript b/src/python/SConscript
index 6e0f6d7..f08752a 100644
--- a/src/python/SConscript
+++ b/src/python/SConscript
@@ -283,7 +283,7 @@
PySource('m5.ext.pyfdt', 'm5/ext/pyfdt/__init__.py')
PySource('m5.ext.pystats', 'm5/ext/pystats/__init__.py')
-PySource('m5.ext.pystats', 'm5/ext/pystats/jsonserializable.py')
+PySource('m5.ext.pystats', 'm5/ext/pystats/serializable_stat.py')
PySource('m5.ext.pystats', 'm5/ext/pystats/group.py')
PySource('m5.ext.pystats', 'm5/ext/pystats/simstat.py')
PySource('m5.ext.pystats', 'm5/ext/pystats/statistic.py')
diff --git a/src/python/m5/ext/pystats/__init__.py
b/src/python/m5/ext/pystats/__init__.py
index 04d7d11..942979a 100644
--- a/src/python/m5/ext/pystats/__init__.py
+++ b/src/python/m5/ext/pystats/__init__.py
@@ -24,7 +24,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-from .jsonserializable import JsonSerializable
+from .serializable_stat import SerializableStat
from .group import Group
from .simstat import SimStat
from .statistic import Statistic
@@ -38,6 +38,6 @@
"Statistic",
"TimeConversion",
"StorageType",
- "JsonSerializable",
+ "SerializableStat",
"JsonLoader",
]
diff --git a/src/python/m5/ext/pystats/group.py
b/src/python/m5/ext/pystats/group.py
index c71f291..55ec4b2 100644
--- a/src/python/m5/ext/pystats/group.py
+++ b/src/python/m5/ext/pystats/group.py
@@ -36,12 +36,11 @@
Union,
)
-from .jsonserializable import JsonSerializable
+from .serializable_stat import SerializableStat
from .statistic import Scalar, Statistic
from .timeconversion import TimeConversion
-
-class Group(JsonSerializable):
+class Group(SerializableStat):
"""
Used to create the heirarchical stats structure. A Group object
contains a
map of labeled Groups, Statistics, Lists of Groups, or List of
Statistics.
diff --git a/src/python/m5/ext/pystats/jsonserializable.py
b/src/python/m5/ext/pystats/serializable_stat.py
similarity index 96%
rename from src/python/m5/ext/pystats/jsonserializable.py
rename to src/python/m5/ext/pystats/serializable_stat.py
index 63cb16f..3ad9b50 100644
--- a/src/python/m5/ext/pystats/jsonserializable.py
+++ b/src/python/m5/ext/pystats/serializable_stat.py
@@ -30,11 +30,10 @@
from .storagetype import StorageType
-
-class JsonSerializable:
+class SerializableStat:
"""
- Classes which inherit from JsonSerializable can be translated into JSON
- using Python's json package.
+ Classes which inherit from SerializableStat can be serialized as JSON
+ output.
Usage
-----
@@ -80,7 +79,7 @@
A value which can be handled by the Python stdlib JSON package.
"""
- if isinstance(value, JsonSerializable):
+ if isinstance(value, SerializableStat):
return value.to_json()
elif isinstance(value, (str, int, float)):
return value
diff --git a/src/python/m5/ext/pystats/simstat.py
b/src/python/m5/ext/pystats/simstat.py
index 5a48009..3cea133 100644
--- a/src/python/m5/ext/pystats/simstat.py
+++ b/src/python/m5/ext/pystats/simstat.py
@@ -27,13 +27,12 @@
from datetime import datetime
from typing import Dict, List, Optional, Union
-from .jsonserializable import JsonSerializable
+from .serializable_stat import SerializableStat
from .group import Group
from .statistic import Statistic
from .timeconversion import TimeConversion
-
-class SimStat(JsonSerializable):
+class SimStat(SerializableStat):
"""
Contains all the statistics for a given simulation.
"""
diff --git a/src/python/m5/ext/pystats/statistic.py
b/src/python/m5/ext/pystats/statistic.py
index 6119f10..446c9ba 100644
--- a/src/python/m5/ext/pystats/statistic.py
+++ b/src/python/m5/ext/pystats/statistic.py
@@ -27,11 +27,11 @@
from abc import ABC
from typing import Any, Iterable, Optional, Union, List
-from .jsonserializable import JsonSerializable
+from .serializable_stat import SerializableStat
from .storagetype import StorageType
-class Statistic(ABC, JsonSerializable):
+class Statistic(ABC, SerializableStat):
"""
The abstract base class for all Python statistics.
"""
diff --git a/tests/pyunit/pyunit_jsonserializable_check.py
b/tests/pyunit/pyunit_jsonserializable_check.py
index 97642a4..8d5d2fa 100644
--- a/tests/pyunit/pyunit_jsonserializable_check.py
+++ b/tests/pyunit/pyunit_jsonserializable_check.py
@@ -25,10 +25,10 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import unittest
-from m5.ext.pystats.jsonserializable import JsonSerializable
+from m5.ext.pystats.serializable_stat import SerializableStat
-class MockSerializable(JsonSerializable):
+class MockSerializable(SerializableStat):
def __init__(self):
self.child_1 = MockSerializableChild()
self.child_1.stat1 = 2
@@ -43,7 +43,7 @@
self.child_list.append(child_list_2)
-class MockSerializableChild(JsonSerializable):
+class MockSerializableChild(SerializableStat):
def __init__(self):
pass
--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/59273?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ia9a1e3ef4029de45a11ac261fb14c9bdfa412cdd
Gerrit-Change-Number: 59273
Gerrit-PatchSet: 12
Gerrit-Owner: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org