Skip to content

Commit 5b84933

Browse files
authored
Merge pull request #754 from hackingmaterials/revert-739-pytest-split
Revert "use pytest-split in GHA test workflow"
2 parents ee66a6e + f5c1ca4 commit 5b84933

File tree

9 files changed

+32
-88
lines changed

9 files changed

+32
-88
lines changed

.github/workflows/combine_durations.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 14 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,20 @@ jobs:
1010
test:
1111
if: github.repository_owner == 'hackingmaterials' # don't run on forks
1212
runs-on: ubuntu-latest
13-
strategy:
14-
matrix:
15-
# pytest-split groups for automatically equally split concurrent test runners
16-
group: [1, 2, 3, 4, 5]
1713
services:
1814
mongodb:
1915
image: mongo
2016
ports:
2117
- 27017:27017
2218

2319
steps:
24-
- name: Check out repo
25-
uses: actions/checkout@v3
20+
- name: Checkout repo
21+
uses: actions/checkout@v2
2622

27-
- name: Set up python
28-
uses: actions/setup-python@v3
23+
- name: Setup Python
24+
uses: actions/setup-python@v2
2925
with:
3026
python-version: 3.8
31-
cache: pip
32-
cache-dependency-path: |
33-
setup.py
34-
requirements-ci.txt
3527

3628
- name: Install OpenBabel
3729
run: |
@@ -40,54 +32,19 @@ jobs:
4032
# https://github.com/openbabel/openbabel/issues/2408#issuecomment-1014466193
4133
sudo ln -s /usr/include/openbabel3 /usr/local/include/openbabel3
4234
43-
- name: Install dependencies
44-
run: |
45-
pip install -r requirements-ci.txt
46-
pip install .[complete]
47-
48-
- name: Get durations from cache
35+
- name: Cache pip
4936
uses: actions/cache@v2
5037
with:
51-
path: test_durations
52-
# the key must never match, even when restarting workflows, as that
53-
# will cause durations to get out of sync between groups, the
54-
# combined durations will be loaded if available
55-
key: test-durations-split-${{ github.run_id }}-${{ github.run_number}}-${{ matrix.group }}
38+
path: ~/.cache/pip
39+
key: ${{ runner.os }}-pip-${{ hashFiles('requirements-ci.txt', 'setup.py') }}
5640
restore-keys: |
57-
test-durations-combined-${{ github.sha }}
58-
test-durations-combined
41+
${{ runner.os }}-pip-
5942
60-
- name: Run tests
43+
- name: Install dependencies
6144
run: |
62-
pytest --splits 5 --group ${{ matrix.group }} --store-durations \
63-
--cov=atomate --cov-report html:coverage_reports atomate
64-
65-
- name: Upload partial durations
66-
uses: actions/upload-artifact@v2
67-
with:
68-
name: split-${{ matrix.group }}
69-
path: .test_durations
70-
71-
update_durations:
72-
name: Combine and update test durations
73-
runs-on: ubuntu-latest
74-
needs: test
75-
steps:
76-
- name: Check out repo
77-
uses: actions/checkout@v2
78-
79-
- name: Get durations from cache
80-
uses: actions/cache@v2
81-
with:
82-
path: .test_durations
83-
# key won't match during the first run for the given commit, but
84-
# restore-key will if there's a previous stored durations file,
85-
# so cache will both be loaded and stored
86-
key: test-durations-combined-${{ github.sha }}
87-
restore-keys: test-durations-combined
88-
89-
- name: Download artifacts
90-
uses: actions/download-artifact@v2
45+
pip install -r requirements-ci.txt
46+
pip install .[complete]
9147
92-
- name: Combine test durations
93-
run: python3 .github/workflows/combine_durations.py
48+
- name: pytest
49+
run: |
50+
pytest --ignore=atomate/qchem/test_files --cov=atomate --cov-report html:coverage_reports atomate

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pip-log.txt
3131
# Unit test / coverage reports
3232
.coverage
3333
.tox
34-
.test_durations
34+
nosetests.xml
3535
*.mypy_cache/*
3636

3737
# Translations

atomate/common/firetasks/tests/test_parse_outputs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def __init__(self):
2121
def assimilate(self, path):
2222
return {"drone": "Test Drone", "dir_name": "/test", "state": "successful"}
2323

24+
def get_valid_paths(self, path):
25+
return path
26+
2427

2528
class TestToDbTask(AtomateTest):
2629
def test_ToDbTask(self):

atomate/lammps/drones.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def assimilate(
8383
dump_files = [dump_files] if isinstance(dump_files, str) else dump_files
8484

8585
# input set
86-
lmps_input = LammpsInputSet.from_file( # noqa: F821
86+
lmps_input = LammpsInputSet.from_file(
8787
"lammps", input_file, {}, data_file, data_filename
8888
)
8989

@@ -94,7 +94,7 @@ def assimilate(
9494
dumps.append((df, LammpsDump.from_file(os.path.join(path, df))))
9595

9696
# log
97-
log = LammpsLog(log_file=log_file) # noqa: F821
97+
log = LammpsLog(log_file=log_file)
9898

9999
logger.info(f"Getting task doc for base dir :{path}")
100100
d = self.generate_doc(path, lmps_input, log, dumps)
@@ -163,6 +163,9 @@ def generate_doc(self, dir_name, lmps_input, log, dumps):
163163
)
164164
return None
165165

166+
def get_valid_paths(self, path):
167+
return [path]
168+
166169
def as_dict(self):
167170
init_args = {
168171
"additional_fields": self.additional_fields,

atomate/qchem/drones.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,3 +503,7 @@ def validate_doc(self, d):
503503
diff = v.difference(set(d.get(k, d).keys()))
504504
if diff:
505505
logger.warning(f"The keys {diff} in {k} not set")
506+
507+
@staticmethod
508+
def get_valid_paths(self, path):
509+
return [path]

atomate/vasp/drones.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ def generate_doc(self, dir_name, vasprun_files, outcar_files):
420420
d["output"][k] = d_calc_final["output"][k]
421421

422422
# store optical data, overwrites the LOPTICS data
423-
if d["input"]["incar"].get("ALGO") == "CHI":
423+
if d["input"]["incar"].get("ALGO") == 'CHI':
424424
for k in ["optical_absorption_coeff", "dielectric"]:
425425
d["output"][k] = d_calc_final["output"][k]
426426

@@ -486,12 +486,12 @@ def process_vasprun(self, dir_name, taskname, filename):
486486
d["output"][k] = d["output"].pop(v)
487487

488488
# Process bandstructure and DOS
489-
if self.bandstructure_mode is not False:
489+
if self.bandstructure_mode is not False: # noqa
490490
bs = self.process_bandstructure(vrun)
491491
if bs:
492492
d["bandstructure"] = bs
493493

494-
if self.parse_dos is not False:
494+
if self.parse_dos is not False: # noqa
495495
dos = self.process_dos(vrun)
496496
if dos:
497497
d["dos"] = dos
@@ -588,7 +588,7 @@ def process_vasprun(self, dir_name, taskname, filename):
588588
d["output"]["optical_absorption_coeff"] = vrun.optical_absorption_coeff
589589

590590
# parse output from response function
591-
if vrun.incar.get("ALGO") == "CHI":
591+
if vrun.incar.get("ALGO") == 'CHI':
592592
dielectric = vrun.dielectric
593593
d["output"]["dielectric"] = dict(
594594
energy=dielectric[0], real=dielectric[1], imag=dielectric[2]

atomate/vasp/firetasks/lobster_tasks.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ def __init__(self, *args, **kwargs):
231231
f"Check that you did not misspell it."
232232
)
233233

234-
@staticmethod
235-
def _find_gz_file(filename):
234+
def _find_gz_file(self, filename):
236235
gz_filename = filename + ".gz"
237236
if os.path.exists(gz_filename):
238237
return gz_filename

requirements-ci.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ coverage==5.5
33
moto==2.0.10
44
pytest-cov==2.12.1
55
pytest==6.2.4
6-
pytest-split

0 commit comments

Comments
 (0)