diff --git a/abipy/dynamics/hist.py b/abipy/dynamics/hist.py index 8bd7eeb1a..e4ac16ffe 100644 --- a/abipy/dynamics/hist.py +++ b/abipy/dynamics/hist.py @@ -14,7 +14,6 @@ from monty.string import marquee, list_strings from pymatgen.core.periodic_table import Element from pymatgen.analysis.structure_analyzer import RelaxationAnalyzer -from pymatgen.io.vasp.outputs import Xdatcar from abipy.tools.plotting import add_fig_kwargs, get_ax_fig_plt, get_axarray_fig_plt, set_visible, get_figs_plotly, \ get_fig_plotly, add_plotly_fig_kwargs, plotlyfigs_to_browser, push_to_chart_studio, PlotlyRowColDesc, plotly_set_lims, \ latex_greek_2unicode @@ -180,6 +179,8 @@ def to_xdatcar(self, filepath=None, groupby_type=True, to_unit_cell=False, **kwa to_unit_cell (bool): Whether to translate sites into the unit cell. kwargs: keywords arguments passed to Xdatcar constructor. """ + from pymatgen.io.vasp.outputs import Xdatcar + filepath = self.write_xdatcar(filepath=filepath, groupby_type=groupby_type, to_unit_cell=to_unit_cell, overwrite=True) @@ -201,6 +202,9 @@ def write_xdatcar(self, filepath="XDATCAR", groupby_type=True, overwrite=False, Return: path to Xdatcar file. """ + # This library takes 13s to import on HPC (07/02/24) so moved to class method instead of header + from pymatgen.io.vasp.outputs import Xdatcar + if filepath is not None and os.path.exists(filepath) and not overwrite: raise RuntimeError("Cannot overwrite pre-existing file `%s`" % filepath) diff --git a/abipy/electrons/lobster.py b/abipy/electrons/lobster.py index 5df57e512..75d7d2bdf 100644 --- a/abipy/electrons/lobster.py +++ b/abipy/electrons/lobster.py @@ -15,8 +15,6 @@ from monty.functools import lazy_property from pymatgen.core.periodic_table import Element from pymatgen.electronic_structure.core import OrbitalType -from pymatgen.io.vasp.outputs import Vasprun -from pymatgen.io.vasp.inputs import Potcar from pymatgen.io.abinit.pseudos import Pseudo from abipy.core.func1d import Function1D from abipy.core.mixins import BaseFile, NotebookWriter @@ -1166,6 +1164,10 @@ def from_dir(cls, dirpath, dE=0.01, **kwargs): Returns: A LobsterInput. """ + # These two libraries take a long time to import on HPC (07/02/24) so moved to method instead of header + from pymatgen.io.vasp.outputs import Vasprun + from pymatgen.io.vasp.inputs import Potcar + # Try to determine the code used for the calculation dft_code = None if os.path.isfile(os.path.join(dirpath, 'vasprun.xml')):