Skip to content

Commit 06bea68

Browse files
committed
fix lint
1 parent 0b208e2 commit 06bea68

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

netboxlabs/diode/sdk/chunking.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
#!/usr/bin/env python
22
# Copyright 2026 NetBox Labs Inc
3-
"""Message chunking utilities for Diode SDK.
3+
"""
4+
Message chunking utilities for Diode SDK.
45
56
This module provides utilities for chunking large lists of entities into
67
size-appropriate chunks for gRPC ingestion, ensuring no chunk exceeds
78
the gRPC message size limit.
89
"""
910

10-
from typing import Iterable
11+
from collections.abc import Iterable
1112

1213
from .diode.v1 import ingester_pb2
1314

1415

1516
def create_message_chunks(
1617
entities: Iterable[ingester_pb2.Entity], max_chunk_size_mb: float = 3.0
1718
) -> list[list[ingester_pb2.Entity]]:
18-
"""Create size-aware chunks from entities using greedy bin-packing.
19+
"""
20+
Create size-aware chunks from entities using greedy bin-packing.
1921
2022
This function chunks entities to ensure each chunk stays under the specified
2123
size limit. It uses a greedy bin-packing algorithm that accumulates entities
@@ -40,6 +42,7 @@ def create_message_chunks(
4042
4143
>>> # Use a custom chunk size
4244
>>> chunks = create_message_chunks(entities, max_chunk_size_mb=3.5)
45+
4346
"""
4447
# Convert iterable to list if necessary for size estimation
4548
if not isinstance(entities, list):
@@ -85,7 +88,8 @@ def create_message_chunks(
8588

8689

8790
def estimate_message_size(entities: Iterable[ingester_pb2.Entity]) -> int:
88-
"""Estimate the serialized size of entities in bytes.
91+
"""
92+
Estimate the serialized size of entities in bytes.
8993
9094
Calculates the total size by summing individual entity sizes plus the
9195
IngestRequest protobuf overhead.
@@ -101,6 +105,7 @@ def estimate_message_size(entities: Iterable[ingester_pb2.Entity]) -> int:
101105
>>> size_bytes = estimate_message_size(entities)
102106
>>> size_mb = size_bytes / (1024 * 1024)
103107
>>> print(f"Estimated size: {size_mb:.2f} MB")
108+
104109
"""
105110
# Convert iterable to list if necessary
106111
if not isinstance(entities, list):

netboxlabs/diode/sdk/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def __init__(
668668
options=channel_opts,
669669
)
670670
else:
671-
_LOGGER.debug(f"Setting up gRPC insecure channel")
671+
_LOGGER.debug("Setting up gRPC insecure channel")
672672
base_channel = grpc.insecure_channel(
673673
target=self._target,
674674
options=channel_opts,

tests/test_chunking.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ def entity_generator():
179179

180180

181181
def test_create_message_chunks_single_large_entity():
182-
"""Test create_message_chunks with a single entity that exceeds chunk size.
182+
"""
183+
Test create_message_chunks with a single entity that exceeds chunk size.
183184
184185
This edge case verifies the function doesn't fail when a single entity
185186
is larger than the chunk size limit.

0 commit comments

Comments
 (0)