2023-04-21 00:45:15 +02:00
|
|
|
from marshmallow import pre_load
|
|
|
|
|
2023-04-22 13:11:48 +02:00
|
|
|
from .._base import SystemBaseSchema
|
2023-04-21 00:45:15 +02:00
|
|
|
|
|
|
|
|
2023-04-22 13:11:48 +02:00
|
|
|
class MemoryStatsBaseSchema(SystemBaseSchema):
|
2023-04-21 00:45:15 +02:00
|
|
|
"""
|
|
|
|
Base schema for memory stats.
|
|
|
|
"""
|
|
|
|
|
|
|
|
@pre_load
|
|
|
|
def pre_load(self, data: dict, **_) -> dict:
|
2023-04-22 13:11:48 +02:00
|
|
|
data = super().pre_load(data)
|
|
|
|
|
2023-04-21 00:45:15 +02:00
|
|
|
# Normalize the percentage between 0 and 1
|
|
|
|
if data.get('percent') is not None:
|
|
|
|
data['percent'] /= 100
|
|
|
|
return data
|