Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion lambench/models/ase_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from ase.io import write
from ase.optimize import FIRE
from ase.calculators.emt import EMT
from dftd3.ase import DFTD3
from tqdm import tqdm

from lambench.models.basemodel import BaseLargeAtomModel
Expand Down Expand Up @@ -379,6 +378,8 @@ def run_ase_dptest(

calc = model.calc
if dispersion_correction is not None:
from dftd3.ase import DFTD3

calc = SumCalculator(
[calc, DFTD3(method="PBE", damping=dispersion_correction)]
)
Expand Down
23 changes: 1 addition & 22 deletions lambench/workflow/dflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,6 @@
from lambench.models.basemodel import BaseLargeAtomModel
from lambench.tasks.base_task import BaseTask

# ASEModel imports dftd3 at module load, so the worker must install it before
# `from lambench.workflow.dflow import run_task_op`. PythonOPTemplate prepends
# this block to `script`. Do not use str.format placeholders here: dflow calls
# pre_script.format(tmp_root=...). Worker images often pin a Tsinghua PyPI
# mirror that 403s on dftd3 wheels; force indexes that Bohrium can reach.
_DFTD3_PRE_SCRIPT = """\
import importlib.util
import os
import subprocess
import sys

os.environ.pop("PIP_INDEX_URL", None)
os.environ.pop("PIP_EXTRA_INDEX_URL", None)
if importlib.util.find_spec("dftd3") is None:
install = [sys.executable, "-m", "pip", "install", "dftd3"]
try:
subprocess.check_call(install + ["--index-url", "https://mirrors.aliyun.com/pypi/simple", "--trusted-host", "mirrors.aliyun.com"])
except subprocess.CalledProcessError:
subprocess.check_call(install + ["--index-url", "https://pypi.org/simple", "--trusted-host", "pypi.org"])
"""


@OP.function
def run_task_op(
Expand Down Expand Up @@ -93,7 +72,7 @@ def submit_tasks_dflow(
python_packages=[
Path(package.__path__[0]) for package in [lambench, dpdata]
],
pre_script=_DFTD3_PRE_SCRIPT,
pre_script="import os\nos.system('pip install dftd3')\n",
),
parameters={
"task": task,
Expand Down
Loading