Skip to content

Commit d7b0f06

Browse files
authored
v0.14.18 - metricsToDataframe for current pandas version (#216)
* metricsToDataframe for current pandas version * flask 3.1.3 * Bump version from v0.14.17 to v0.14.18
1 parent 7c7f182 commit d7b0f06

5 files changed

Lines changed: 45 additions & 4 deletions

File tree

dbmsbenchmarker/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.14.17"
1+
__version__ = "0.14.18"

dbmsbenchmarker/monitor.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,53 @@ def fetch_interval(time_start, time_end, step):
151151
return list_values
152152
@staticmethod
153153
def metricsToDataframe(metric, values):
154+
"""
155+
Convert raw metric records into a normalized, time-indexed DataFrame.
156+
157+
The function performs the following steps:
158+
159+
1. Create a DataFrame from the raw records.
160+
2. Rename columns to ["time [s]", <metric title>].
161+
3. Convert the time column to integer.
162+
4. Normalize time so that it starts at 0 seconds.
163+
5. Set the time column as index.
164+
6. Convert metric values to float.
165+
166+
:param metric: Dictionary containing metric metadata.
167+
Must contain the key ``'title'`` which will be
168+
used as the column name for the metric values.
169+
:type metric: dict
170+
171+
:param values: Iterable of records representing metric measurements.
172+
Each record must contain two elements:
173+
(timestamp, metric_value).
174+
:type values: iterable
175+
176+
:return: A pandas DataFrame indexed by normalized time (seconds)
177+
containing one float column with metric values.
178+
:rtype: pandas.DataFrame
179+
"""
180+
df = pd.DataFrame.from_records(values)
181+
df.columns = ['time [s]', metric['title']]
182+
# Convert time column to integer
183+
df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0], errors="coerce").astype("Int64")
184+
# Normalize time to start at 0
185+
minimum = df.iloc[:, 0].min()
186+
df.iloc[:, 0] = df.iloc[:, 0] - minimum
187+
# Set time as index
188+
df = df.set_index(df.columns[0])
189+
# Convert metric values to float
190+
df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0], errors="coerce")
191+
return df
192+
def __OLD_metricsToDataframe(metric, values):
154193
df = pd.DataFrame.from_records(values)
155194
df.columns = ['time [s]', metric['title']]
156195
df.iloc[0:,0] = df.iloc[0:,0].map(int)
157196
minimum = df.iloc[0:,0].min()
158197
df.iloc[0:,0] = df.iloc[0:,0].map(lambda x: x-minimum)
159198
df = df.set_index(df.columns[0])
160199
df.iloc[0:,0] = df.iloc[0:,0].map(float)
200+
#df.iloc[:, 0] = pd.to_numeric(df.iloc[:, 0], errors="coerce")
161201
return df
162202
@staticmethod
163203
def saveMetricsDataframe(filename, df):

dbmsbenchmarker/scripts/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
The dbmsbenchmarker scripts
33
"""
44
__all__ = ["cli","dashboardcli","inspect"]
5-
from .__version__ import __version__
5+
from ..__version__ import __version__

dbmsbenchmarker/scripts/dashboardcli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3374,4 +3374,5 @@ def startup():
33743374

33753375
# Assign layout to app
33763376
app.layout = layout.serve_layout(preview)
3377-
app.run_server(debug=args.debug, host='0.0.0.0', threaded=True, processes=1)
3377+
app.run(debug=args.debug, host='0.0.0.0', threaded=True, processes=1)
3378+
#app.run_server(debug=args.debug, host='0.0.0.0', threaded=True, processes=1)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dash-daq
1919
dash-html-components
2020
dash-renderer
2121
dash-table
22-
Flask==2.2.5
22+
Flask==3.1.3
2323
Flask-Caching
2424
future>=0.18.2
2525
idna>=2.9

0 commit comments

Comments
 (0)