Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace distutils.version.LooseVersion by packaging.version.Version #1095

Merged
merged 1 commit into from
Dec 30, 2022
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
6 changes: 3 additions & 3 deletions dpgen/auto_test/common_equi.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from dpgen.auto_test.calculator import make_calculator
from dpgen.auto_test.mpdb import get_structure
from dpgen.dispatcher.Dispatcher import make_dispatcher
from distutils.version import LooseVersion
from packaging.version import Version
from dpgen.dispatcher.Dispatcher import make_submission
from dpgen.remote.decide_machine import convert_mdata
from dpgen.auto_test.lib.utils import create_path
Expand Down Expand Up @@ -177,7 +177,7 @@ def run_equi(confs,
print("%s --> Runing... " % (work_path))

api_version = mdata.get('api_version', '0.9')
if LooseVersion(api_version) < LooseVersion('1.0'):
if Version(api_version) < Version('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
disp = make_dispatcher(machine, resources, work_path, run_tasks, group_size)
Expand All @@ -191,7 +191,7 @@ def run_equi(confs,
backward_files,
outlog='outlog',
errlog='errlog')
elif LooseVersion(api_version) >= LooseVersion('1.0'):
elif Version(api_version) >= Version('1.0'):

submission = make_submission(
mdata_machine=machine,
Expand Down
6 changes: 3 additions & 3 deletions dpgen/auto_test/common_prop.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from distutils.version import LooseVersion
from packaging.version import Version
import glob
import os
import warnings
Expand Down Expand Up @@ -191,7 +191,7 @@ def worker(work_path,
run_tasks = [os.path.basename(ii) for ii in all_task]
machine, resources, command, group_size = util.get_machine_info(mdata, inter_type)
api_version = mdata.get('api_version', '0.9')
if LooseVersion(api_version) < LooseVersion('1.0'):
if Version(api_version) < Version('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
disp = make_dispatcher(machine, resources, work_path, run_tasks, group_size)
Expand All @@ -205,7 +205,7 @@ def worker(work_path,
backward_files,
outlog='outlog',
errlog='errlog')
elif LooseVersion(api_version) >= LooseVersion('1.0'):
elif Version(api_version) >= Version('1.0'):
submission = make_submission(
mdata_machine=machine,
mdata_resources=resources,
Expand Down
4 changes: 2 additions & 2 deletions dpgen/auto_test/lib/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import dpdata
import subprocess as sp
import dpgen.auto_test.lib.util as util
from distutils.version import LooseVersion
from packaging.version import Version
from dpdata.periodic_table import Element


Expand Down Expand Up @@ -103,7 +103,7 @@ def inter_deepmd(param):
model_list = ""
for ii in models:
model_list += ii + " "
if LooseVersion(deepmd_version) < LooseVersion('1'):
if Version(deepmd_version) < Version('1'):
## DeePMD-kit version == 0.x
if len(models) > 1:
ret += '%s 10 model_devi.out\n' % model_list
Expand Down
18 changes: 9 additions & 9 deletions dpgen/data/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import dpgen.data.tools.bcc as bcc
import dpgen.data.tools.diamond as diamond
import dpgen.data.tools.sc as sc
from distutils.version import LooseVersion
from packaging.version import Version
from dpgen.generator.lib.vasp import incar_upper
from dpgen.generator.lib.utils import symlink_user_forward_files
from dpgen.generator.lib.abacus_scf import get_abacus_input_parameters, get_abacus_STRU, make_supercell_abacus, make_abacus_scf_stru\
Expand Down Expand Up @@ -1061,7 +1061,7 @@ def run_vasp_relax(jdata, mdata):
run_tasks = [os.path.basename(ii) for ii in relax_run_tasks]

api_version = mdata.get('api_version', '0.9')
if LooseVersion(api_version) < LooseVersion('1.0'):
if Version(api_version) < Version('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
dispatcher = make_dispatcher(mdata['fp_machine'], mdata['fp_resources'], work_dir, run_tasks, fp_group_size)
Expand All @@ -1074,7 +1074,7 @@ def run_vasp_relax(jdata, mdata):
forward_files,
backward_files)

elif LooseVersion(api_version) >= LooseVersion('1.0'):
elif Version(api_version) >= Version('1.0'):
submission = make_submission(
mdata['fp_machine'],
mdata['fp_resources'],
Expand Down Expand Up @@ -1197,7 +1197,7 @@ def run_abacus_relax(jdata, mdata):
run_tasks = [os.path.basename(ii) for ii in relax_run_tasks]

api_version = mdata.get('api_version', '0.9')
if LooseVersion(api_version) < LooseVersion('1.0'):
if Version(api_version) < Version('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
dispatcher = make_dispatcher(mdata['fp_machine'], mdata['fp_resources'], work_dir, run_tasks, fp_group_size)
Expand All @@ -1210,7 +1210,7 @@ def run_abacus_relax(jdata, mdata):
forward_files,
backward_files)

elif LooseVersion(api_version) >= LooseVersion('1.0'):
elif Version(api_version) >= Version('1.0'):
submission = make_submission(
mdata['fp_machine'],
mdata['fp_resources'],
Expand Down Expand Up @@ -1264,7 +1264,7 @@ def run_vasp_md(jdata, mdata):
#dlog.info("md_work_dir", work_dir)
#dlog.info("run_tasks",run_tasks)
api_version = mdata.get('api_version', '0.9')
if LooseVersion(api_version) < LooseVersion('1.0'):
if Version(api_version) < Version('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
dispatcher = make_dispatcher(mdata['fp_machine'], mdata['fp_resources'], work_dir, run_tasks, fp_group_size)
Expand All @@ -1277,7 +1277,7 @@ def run_vasp_md(jdata, mdata):
forward_files,
backward_files)

elif LooseVersion(api_version) >= LooseVersion('1.0'):
elif Version(api_version) >= Version('1.0'):
submission = make_submission(
mdata['fp_machine'],
mdata['fp_resources'],
Expand Down Expand Up @@ -1344,7 +1344,7 @@ def run_abacus_md(jdata, mdata):
#dlog.info("md_work_dir", work_dir)
#dlog.info("run_tasks",run_tasks)
api_version = mdata.get('api_version', '0.9')
if LooseVersion(api_version) < LooseVersion('1.0'):
if Version(api_version) < Version('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
dispatcher = make_dispatcher(mdata['fp_machine'], mdata['fp_resources'], work_dir, run_tasks, fp_group_size)
Expand All @@ -1357,7 +1357,7 @@ def run_abacus_md(jdata, mdata):
forward_files,
backward_files)

elif LooseVersion(api_version) >= LooseVersion('1.0'):
elif Version(api_version) >= Version('1.0'):
submission = make_submission(
mdata['fp_machine'],
mdata['fp_resources'],
Expand Down
6 changes: 3 additions & 3 deletions dpgen/generator/lib/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import subprocess as sp
import scipy.constants as pc
from distutils.version import LooseVersion
from packaging.version import Version

def _sample_sphere() :
while True:
Expand Down Expand Up @@ -33,7 +33,7 @@ def make_lammps_input(ensemble,
max_seed = 1000000,
nopbc = False,
deepmd_version = '0.1') :
if (ele_temp_f is not None or ele_temp_a is not None) and LooseVersion(deepmd_version) < LooseVersion('1'):
if (ele_temp_f is not None or ele_temp_a is not None) and Version(deepmd_version) < Version('1'):
raise RuntimeError('the electron temperature is only supported by deepmd-kit >= 1.0.0, please upgrade your deepmd-kit')
if ele_temp_f is not None and ele_temp_a is not None:
raise RuntimeError('the frame style ele_temp and atom style ele_temp should not be set at the same time')
Expand Down Expand Up @@ -68,7 +68,7 @@ def make_lammps_input(ensemble,
graph_list = ""
for ii in graphs :
graph_list += ii + " "
if LooseVersion(deepmd_version) < LooseVersion('1'):
if Version(deepmd_version) < Version('1'):
# 0.x
ret+= "pair_style deepmd %s ${THERMO_FREQ} model_devi.out\n" % graph_list
else:
Expand Down
12 changes: 6 additions & 6 deletions dpgen/generator/lib/run_calypso.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ase.io.trajectory import Trajectory
from pathlib import Path
from itertools import combinations
from distutils.version import LooseVersion
from packaging.version import Version
from dpgen import dlog
from dpgen.generator.lib.utils import create_path
from dpgen.generator.lib.utils import make_iter_name
Expand Down Expand Up @@ -122,7 +122,7 @@ def gen_structures(iter_index, jdata, mdata, caly_run_path, current_idx, length_

run_tasks = [os.path.basename(ii) for ii in run_tasks_]

if LooseVersion(api_version) < LooseVersion('1.0'):
if Version(api_version) < Version('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
dispatcher=make_dispatcher(mdata['model_devi_machine'],mdata['model_devi_resources'],'./', run_tasks, model_devi_group_size)
Expand All @@ -136,7 +136,7 @@ def gen_structures(iter_index, jdata, mdata, caly_run_path, current_idx, length_
backward_files,
outlog = 'model_devi.log',
errlog = 'model_devi.log')
elif LooseVersion(api_version) >= LooseVersion('1.0'):
elif Version(api_version) >= Version('1.0'):
os.chdir(cwd)
submission = make_submission(
mdata['model_devi_machine'],
Expand Down Expand Up @@ -169,7 +169,7 @@ def gen_structures(iter_index, jdata, mdata, caly_run_path, current_idx, length_
# to traj
shutil.copyfile(os.path.join('task.%03d'%(jjj),'traj.traj'),os.path.join('traj','%s.traj'%str(jjj+1)),)

if LooseVersion(api_version) < LooseVersion('1.0'):
if Version(api_version) < Version('1.0'):
os.rename('jr.json','jr_%s.json'%(str(ii)))

tlist = glob.glob('task.*')
Expand Down Expand Up @@ -232,7 +232,7 @@ def gen_structures(iter_index, jdata, mdata, caly_run_path, current_idx, length_

run_tasks = [os.path.basename(ii) for ii in run_tasks_]

if LooseVersion(api_version) < LooseVersion('1.0'):
if Version(api_version) < Version('1.0'):
warnings.warn(f"the dpdispatcher will be updated to new version."
f"And the interface may be changed. Please check the documents for more details")
dispatcher=make_dispatcher(mdata['model_devi_machine'],mdata['model_devi_resources'],'./', run_tasks, model_devi_group_size)
Expand All @@ -246,7 +246,7 @@ def gen_structures(iter_index, jdata, mdata, caly_run_path, current_idx, length_
backward_files,
outlog = 'model_devi.log',
errlog = 'model_devi.log')
elif LooseVersion(api_version) >= LooseVersion('1.0'):
elif Version(api_version) >= Version('1.0'):
os.chdir(cwd)
submission = make_submission(
mdata['model_devi_machine'],
Expand Down
Loading