Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/crawlee/_utils/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Annotated

import psutil
from pydantic import BaseModel, ConfigDict, Field, PlainValidator
from pydantic import BaseModel, ConfigDict, Field, PlainSerializer, PlainValidator

from crawlee._utils.byte_size import ByteSize

Expand Down Expand Up @@ -43,8 +43,15 @@ class MemoryInfo(BaseModel):

model_config = ConfigDict(populate_by_name=True)

total_size: Annotated[ByteSize, PlainValidator(ByteSize.validate), Field(alias='totalSize')]
current_size: Annotated[ByteSize, PlainValidator(ByteSize.validate), Field(alias='currentSize')]
total_size: Annotated[
ByteSize, PlainValidator(ByteSize.validate), PlainSerializer(lambda size: size.bytes), Field(alias='totalSize')
]
current_size: Annotated[
ByteSize,
PlainValidator(ByteSize.validate),
PlainSerializer(lambda size: size.bytes),
Field(alias='currentSize'),
]
created_at: datetime = Field(
alias='createdAt',
default_factory=lambda: datetime.now(timezone.utc),
Expand Down