forked from instructlab/sdg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request instructlab#157 from gabe-l-hart/LLMBlockConcurren…
…cy-135 LLMBlock concurrency
- Loading branch information
Showing
10 changed files
with
351 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Common fixtures and testing utilities | ||
""" | ||
|
||
# Standard | ||
from unittest import mock | ||
|
||
# Third Party | ||
from datasets import Dataset | ||
import pytest | ||
|
||
# First Party | ||
from instructlab.sdg.pipeline import PipelineContext | ||
|
||
|
||
def get_ctx(**kwargs) -> PipelineContext: | ||
kwargs.setdefault("client", mock.MagicMock()) | ||
kwargs.setdefault("model_family", "test") | ||
kwargs.setdefault("model_id", "test-model") | ||
kwargs.setdefault("num_instructions_to_generate", 10) | ||
kwargs.setdefault("dataset_num_procs", 1) | ||
return PipelineContext(**kwargs) | ||
|
||
|
||
def get_single_threaded_ctx(**kwargs) -> PipelineContext: | ||
kwargs["batch_size"] = 0 | ||
return get_ctx(**kwargs) | ||
|
||
|
||
def get_threaded_ctx(**kwargs) -> PipelineContext: | ||
kwargs["batch_size"] = 6 | ||
kwargs["batch_num_workers"] = 2 | ||
return get_ctx(**kwargs) | ||
|
||
|
||
@pytest.fixture | ||
def single_threaded_ctx() -> PipelineContext: | ||
return get_single_threaded_ctx() | ||
|
||
|
||
@pytest.fixture | ||
def threaded_ctx() -> PipelineContext: | ||
return get_threaded_ctx() | ||
|
||
|
||
@pytest.fixture | ||
def sample_dataset(): | ||
return Dataset.from_list([{"foo": i} for i in range(10)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.