Skip to content

Commit 0911d1f

Browse files
committed
skip TestInsertionWorkflow if ChargeInsertionAnalyzer not importable
following @jmmshn's recommendation, see materialsproject/pymatgen#2582 (comment)
1 parent 6946020 commit 0911d1f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

atomate/vasp/firetasks/electrode_tasks.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import math
22

33
from fireworks import FiretaskBase, Firework, FWAction, Workflow, explicit_serialize
4-
from pymatgen.analysis.defects.utils import ChargeInsertionAnalyzer
54
from pymatgen.analysis.structure_matcher import StructureMatcher
65
from pymatgen.core import Structure
76

@@ -12,6 +11,15 @@
1211
from atomate.vasp.firetasks import pass_vasp_result
1312
from atomate.vasp.fireworks.core import OptimizeFW, StaticFW
1413

14+
try:
15+
from pymatgen.analysis.defects import ChargeInsertionAnalyzer
16+
except ImportError:
17+
print(
18+
"Failed to import ChargeInsertionAnalyzer. This is likely due to converting the pymatgen defects module "
19+
"to a namespace package. See https://github.com/materialsproject/pymatgen/pull/2582#issuecomment-1198318101 "
20+
"for updates."
21+
)
22+
1523
__author__ = "Jimmy Shen"
1624
__email__ = "[email protected]"
1725

atomate/vasp/workflows/tests/test_insertion_workflow.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import unittest
23
from pathlib import Path
34

45
from fireworks.core.fworker import FWorker
@@ -10,6 +11,12 @@
1011
from atomate.vasp.powerups import add_modify_incar, use_fake_vasp, use_potcar_spec
1112
from atomate.vasp.workflows.base.electrode import get_ion_insertion_wf
1213

14+
try:
15+
from pymatgen.analysis.defects import ChargeInsertionAnalyzer
16+
except ImportError:
17+
ChargeInsertionAnalyzer = None
18+
19+
1320
__author__ = "Jimmy Shen"
1421
__email__ = "[email protected]"
1522

@@ -19,6 +26,9 @@
1926
wf_dir = ref_dir / "insertion_wf"
2027

2128

29+
@unittest.skipIf(
30+
ChargeInsertionAnalyzer is None, "pymatgen.analysis.defects not installed"
31+
)
2232
class TestInsertionWorkflow(AtomateTest):
2333
def setUp(self):
2434
super().setUp()

0 commit comments

Comments
 (0)