Skip to content

Commit

Permalink
Merge pull request EleutherAI#8 from dirkgr/PytestUpdate
Browse files Browse the repository at this point in the history
Pytest update
  • Loading branch information
StellaAthena committed Apr 27, 2022
2 parents e5a55c7 + f4d7e69 commit 75435b6
Show file tree
Hide file tree
Showing 25 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
pip install -e .
pip install -e .[dev]
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
Expand Down
2 changes: 1 addition & 1 deletion docs/task_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you haven't already, go ahead and fork the main repo, clone it, create a bran
git clone https://github.com/<YOUR-USERNAME>/lm-evaluation-harness.git
cd lm-evaluation-harness
git checkout -b <task-name>
pip install -r requirements.txt
pip install -e ".[dev]"
```

## Creating Your Task File
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
10 changes: 4 additions & 6 deletions lm_eval/tasks/hendrycks_ethics.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,18 @@ class EthicsUtilitarianism(Ethics):
DATASET_NAME = "utilitarianism"

def training_docs(self):
rnd = random.Random()
for doc in self.dataset["train"]:
yield self._process_doc(doc, rnd)
yield self._process_doc(doc)

def validation_docs(self):
raise NotImplementedError

def test_docs(self):
rnd = random.Random()
for doc in self.dataset["test"]:
yield self._process_doc(doc, rnd)
yield self._process_doc(doc)

def _process_doc(self, doc, rnd):
rnd.seed(doc["activity"])
def _process_doc(self, doc):
rnd = random.Random(doc["activity"])
scenarios = [doc["activity"], doc["baseline"]]
ordering = [0, 1]
rnd.shuffle(ordering)
Expand Down
6 changes: 3 additions & 3 deletions lm_eval/tasks/hendrycks_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ def has_test_docs(self):
return True

def training_docs(self):
return map(self._load_doc, self.dataset["train"])
return map(self._process_doc, self.dataset["train"])

def validation_docs(self):
return NotImplemented

def test_docs(self):
return map(self._load_doc, self.dataset["test"])
return map(self._process_doc, self.dataset["test"])

def _load_doc(self, doc):
def _process_doc(self, doc):
doc["answer"] = self.remove_boxed(
self.last_boxed_only_string(doc["solution"]))
return doc
Expand Down
8 changes: 4 additions & 4 deletions lm_eval/tasks/wikitext.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ def has_test_docs(self):
return True

def training_docs(self):
return map(self._load_doc, self.dataset["train"])
return map(self._process_doc, self.dataset["train"])

def validation_docs(self):
return map(self._load_doc, self.dataset["validation"])
return map(self._process_doc, self.dataset["validation"])

def test_docs(self):
return map(self._load_doc, self.dataset["test"])
return map(self._process_doc, self.dataset["test"])

def _load_doc(self, doc):
def _process_doc(self, doc):
return doc["page"]

def doc_to_target(self, doc):
Expand Down
4 changes: 2 additions & 2 deletions lm_eval/tasks/wsc273.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def has_test_docs(self):
return True

def test_docs(self):
return map(self._load_doc, self.dataset["test"])
return map(self._process_doc, self.dataset["test"])

def _load_doc(self, doc):
def _process_doc(self, doc):
# The HF implementation of `wsc273` is not `partial evaluation` friendly.
doc["text"] = doc["text"].replace(" ", " ")
doc["options"][0] = self.__normalize_option(doc, doc["options"][0])
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"pycountry==20.7.3",
"numexpr==2.7.2",
"lm_dataformat==0.0.20",
"pytest==6.2.3",
"pybind11==2.6.2",
"tqdm-multiprocess==0.0.11",
"zstandard==0.15.2",
Expand All @@ -51,4 +50,5 @@
dependency_links=[
"https://github.com/google-research/bleurt/archive/b610120347ef22b494b6d69b4316e303f5932516.zip#egg=bleurt",
],
extras_require={'dev': [ 'pytest', 'black' ]}
)

0 comments on commit 75435b6

Please sign in to comment.