Skip to content

Commit

Permalink
fixes from review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
markurtz committed Jul 3, 2024
1 parent 6a3ada2 commit 407079a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/guidellm/request/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from transformers import AutoTokenizer, PreTrainedTokenizer

from guidellm.core.request import TextGenerationRequest
from guidellm.utils import STANDARD_SLEEP_INTERVAL

__all__ = ["RequestGenerator"]

Expand Down Expand Up @@ -146,13 +147,13 @@ def _populate_queue(self):
try:
if self._queue.qsize() < self._async_queue_size:
item = self.create_item()
self._queue.put(item, timeout=0.1)
self._queue.put(item, timeout=STANDARD_SLEEP_INTERVAL)
logger.debug(
"Item added to queue. Current queue size: {}",
self._queue.qsize(),
)
else:
time.sleep(0.1)
time.sleep(STANDARD_SLEEP_INTERVAL)
except Full:
continue
logger.info("RequestGenerator stopped populating queue")
8 changes: 6 additions & 2 deletions src/guidellm/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from .constants import PREFERRED_DATA_COLUMNS, PREFERRED_DATA_SPLITS
from .constants import (
PREFERRED_DATA_COLUMNS,
PREFERRED_DATA_SPLITS,
STANDARD_SLEEP_INTERVAL,
)

__all__ = ["PREFERRED_DATA_COLUMNS", "PREFERRED_DATA_SPLITS"]
__all__ = ["PREFERRED_DATA_COLUMNS", "PREFERRED_DATA_SPLITS", "STANDARD_SLEEP_INTERVAL"]
4 changes: 3 additions & 1 deletion src/guidellm/utils/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__all__ = ["PREFERRED_DATA_COLUMNS", "PREFERRED_DATA_SPLITS"]
__all__ = ["PREFERRED_DATA_COLUMNS", "PREFERRED_DATA_SPLITS", "STANDARD_SLEEP_INTERVAL"]


PREFERRED_DATA_COLUMNS = [
Expand All @@ -15,3 +15,5 @@
]

PREFERRED_DATA_SPLITS = ["test", "validation", "train"]

STANDARD_SLEEP_INTERVAL = 0.1
1 change: 1 addition & 0 deletions tests/integration/request/test_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from transformers import AutoTokenizer, PreTrainedTokenizerBase

from guidellm.core.request import TextGenerationRequest
from guidellm.request.base import RequestGenerator

Expand Down
8 changes: 6 additions & 2 deletions tests/unit/request/test_base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from unittest.mock import Mock, patch

import pytest
Expand Down Expand Up @@ -79,6 +80,7 @@ def test_request_generator_repr():
@pytest.mark.regression
def test_request_generator_create_item_not_implemented():
with pytest.raises(TypeError):

class IncompleteRequestGenerator(RequestGenerator):
pass

Expand Down Expand Up @@ -106,7 +108,7 @@ def test_request_generator_iter_calls_create_item():
if len(items) == 5:
break

assert len(items) == 5
assert generator._queue.qsize() == 0
generator.create_item.assert_called()


Expand All @@ -124,5 +126,7 @@ def test_request_generator_async_iter_calls_create_item():
break

generator.stop()
assert len(items) == 5
stop_size = generator._queue.qsize()
time.sleep(0.1)
assert generator._queue.qsize() == stop_size
generator.create_item.assert_called()

0 comments on commit 407079a

Please sign in to comment.