Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/context #109

Merged
merged 33 commits into from
Feb 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
051ace1
Add base dataset
steffencruz Feb 19, 2024
94cda65
Add selector class
steffencruz Feb 19, 2024
5d40ff7
Add wiki datasets (date and normal)
steffencruz Feb 19, 2024
41f1615
Add context class
steffencruz Feb 19, 2024
481632b
Add mock dataset
steffencruz Feb 19, 2024
17873e9
Add code dataset
steffencruz Feb 19, 2024
a6e7b6a
Add math dataset
steffencruz Feb 19, 2024
b2c8425
Add init
steffencruz Feb 19, 2024
3768036
Remove old monolothic dataset file
steffencruz Feb 19, 2024
9fcf494
Update submodule init
steffencruz Feb 19, 2024
ae9769a
Refactor QA task to use new context class, and cleanup
steffencruz Feb 19, 2024
849ab97
Refactor summarization task to use new context class, and cleanup
steffencruz Feb 19, 2024
7171a28
Update base task so that context can be unpacked into state dict
steffencruz Feb 19, 2024
d5ceec4
Refactor date QA task to use new context class, and cleanup
steffencruz Feb 19, 2024
9824cb5
Refactor math task to use new context class, and cleanup
steffencruz Feb 19, 2024
edb0a39
Refactor debugging task to use new context class, and cleanup
steffencruz Feb 19, 2024
b0cc7da
Add TASKS list in submodule init
steffencruz Feb 19, 2024
1f6b2af
Add MaxRetryError exception class
steffencruz Feb 19, 2024
b37b110
Catch MaxRetryError and continue validation
steffencruz Feb 19, 2024
7682f76
Update dependencies: synapse fork of mathegenerator and wiki sections
steffencruz Feb 19, 2024
bfdf7b3
Update fixtures for dataset tests to use updated dataset and context …
steffencruz Feb 19, 2024
73ed922
Update tests for dataset and context
steffencruz Feb 19, 2024
5aa8673
Update tests for tasks
steffencruz Feb 19, 2024
5dca2dd
Add pre-staging to workflows
steffencruz Feb 19, 2024
e282a27
Fix dataset name typos
steffencruz Feb 19, 2024
5543e90
Import REWARD_MODELS dict from pipeline for global access to reward m…
steffencruz Feb 19, 2024
a57a491
Import TASKS from tasks submodule
steffencruz Feb 19, 2024
a58c973
Remove redundant args
steffencruz Feb 19, 2024
9694848
Remove redundant args
steffencruz Feb 19, 2024
9229eac
Remove redundant args
steffencruz Feb 19, 2024
0dbd3f0
Add more task fields to tests
steffencruz Feb 19, 2024
77ee3ed
Add tests for reward and penalty definitions and make test_task_field…
steffencruz Feb 19, 2024
5112b47
Remove hanging reference to score decay
steffencruz Feb 20, 2024
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
Prev Previous commit
Next Next commit
Update tests for dataset and context
  • Loading branch information
steffencruz committed Feb 19, 2024
commit 73ed922f31f210f1f19ac395a6eb14475e4a4ccd
57 changes: 50 additions & 7 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,63 @@
import pytest

from .fixtures.dataset import DATASETS, CONTEXTS, CONTEXT_FIELDS
from prompting.tools.datasets import Dataset
from prompting.tools import Context


@pytest.mark.parametrize('dataset', DATASETS)
def test_create_dataset(dataset):
data = dataset()
assert data is not None
def test_create_dataset(dataset: Dataset):
ds = dataset()
assert ds is not None


@pytest.mark.parametrize('dataset', DATASETS)
def test_context_is_dict(dataset):
assert type(CONTEXTS[dataset]) == dict
def test_dataset_is_subclass_of_dataset_class(dataset: Dataset):
ds = dataset()
assert issubclass(type(ds), Dataset)


@pytest.mark.parametrize('dataset', DATASETS)
def test_dataset_context_contains_expected_fields(dataset):
assert set(CONTEXTS[dataset].keys()) == CONTEXT_FIELDS[dataset]
@pytest.mark.parametrize('method', ('next', 'get', 'random', 'search'))
def test_dataset_has_expected_methods(dataset: Dataset, method: str):
ds = dataset()
assert hasattr(ds, method)
assert callable(getattr(ds, method))


@pytest.mark.skip(reason="Not implemented")
@pytest.mark.parametrize('dataset', DATASETS)
@pytest.mark.parametrize('method', ('next', 'get', 'random', 'search'))
def test_dataset_methods_return_contexts(dataset: Dataset, method: str):
ds = dataset()
assert hasattr(ds, method)
assert callable(getattr(ds, method))


@pytest.mark.parametrize('dataset', DATASETS)
def test_context_is_of_type_context_class(dataset: Dataset):
assert type(CONTEXTS[dataset]) == Context


@pytest.mark.parametrize('dataset', DATASETS)
@pytest.mark.parametrize('field', CONTEXT_FIELDS.keys())
def test_context_contains_expected_field(dataset: Dataset, field: str):
assert hasattr(CONTEXTS[dataset], field)


@pytest.mark.parametrize('dataset', DATASETS)
@pytest.mark.parametrize('field, expected_type', list(CONTEXT_FIELDS.items()))
def test_context_field_has_expected_types(dataset: Dataset, field: str, expected_type: type):
assert isinstance(getattr(CONTEXTS[dataset], field), expected_type)


@pytest.mark.parametrize('dataset', DATASETS)
@pytest.mark.parametrize('field', CONTEXT_FIELDS.keys())
def test_context_field_is_not_null(dataset: Dataset, field: str):
assert getattr(CONTEXTS[dataset], field)


@pytest.mark.parametrize('dataset', DATASETS)
@pytest.mark.parametrize('field', ('creator', 'fetch_time', 'num_tries', 'fetch_method', 'next_kwargs'))
def test_context_stats_field_contains_expected_keys(dataset: Dataset, field: str):
assert field in CONTEXTS[dataset].stats