pwact 0.1.27__py3-none-any.whl → 0.1.28__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,20 @@ import re
6
6
  import json
7
7
  import numpy as np
8
8
  import random
9
+ import torch
10
+
11
+ def check_model_type(model_load_path):
12
+ try:
13
+ _model_checkpoint = torch.load(model_load_path, map_location=torch.device("cpu"))
14
+ model_type = _model_checkpoint['json_file']['model_type']
15
+ except Exception as e:
16
+ with open(model_load_path, 'r') as rf:
17
+ line = rf.readline()
18
+ if "nep" not in line:
19
+ raise Exception("ERROR! The input model file cannot be parsed!")
20
+ else:
21
+ model_type = "NEP"
22
+ return model_type
9
23
 
10
24
  '''
11
25
  description:
@@ -1,15 +1,26 @@
1
1
  import os
2
2
  import signal
3
3
  import subprocess
4
+ from subprocess import Popen, PIPE
5
+ import time
6
+ from pwact.active_learning.slurm.slurm import scancle_byjobid
7
+ def kill_process(pid:str, job_id:str):
8
+ if job_id is None:
9
+ try:
10
+ # 发送终止信号 (SIGTERM) 给指定的进程
11
+ os.kill(pid, signal.SIGTERM)
12
+ print(f"process {pid} has been terminated.")
13
+ except ProcessLookupError:
14
+ print(f"process {pid} non-existent.")
15
+ except PermissionError:
16
+ print(f"No permission to terminate the process {pid}.")
17
+ except Exception as e:
18
+ print(f"Error terminating process {pid}: {e}")
19
+ else:
20
+ scancle_byjobid(job_id)
21
+
22
+ def get_pid():
23
+ pid = os.getpid()
24
+ job_id = os.getenv('SLURM_JOB_ID')
25
+ return "pid {} job {}".format(pid, job_id) if job_id is not None else "pid {}".format(pid)
4
26
 
5
- def kill_process(pid:int):
6
- try:
7
- # 发送终止信号 (SIGTERM) 给指定的进程
8
- os.kill(pid, signal.SIGTERM)
9
- print(f"process {pid} has been terminated.")
10
- except ProcessLookupError:
11
- print(f"process {pid} non-existent.")
12
- except PermissionError:
13
- print(f"No permission to terminate the process {pid}.")
14
- except Exception as e:
15
- print(f"Error terminating process {pid}: {e}")
@@ -1,4 +1,5 @@
1
1
  import glob
2
+ import re
2
3
  import os
3
4
  from math import ceil
4
5
  from pwact.utils.constant import DFT_STYLE
@@ -8,7 +9,6 @@ GPU_SCRIPT_HEAD = \
8
9
  #SBATCH --nodes={}\n\
9
10
  #SBATCH --ntasks-per-node={}\n\
10
11
  #SBATCH --gres=gpu:{}\n\
11
- #SBATCH --gpus-per-task={}\n\
12
12
  #SBATCH --partition={}\n\
13
13
  \
14
14
  "
@@ -22,20 +22,6 @@ CPU_SCRIPT_HEAD = \
22
22
  \
23
23
  "
24
24
 
25
- CONDA_ENV = '__conda_setup="$(\'/data/home/wuxingxing/anaconda3/bin/conda\' \'shell.bash\' \'hook\' 2> /dev/null)"\n' \
26
- 'if [ $? -eq 0 ]; then\n' \
27
- ' eval "$__conda_setup"\n' \
28
- 'else\n' \
29
- ' if [ -f "/data/home/wuxingxing/anaconda3/etc/profile.d/conda.sh" ]; then\n' \
30
- ' . "/data/home/wuxingxing/anaconda3/etc/profile.d/conda.sh"\n' \
31
- ' else\n' \
32
- ' export PATH="/data/home/wuxingxing/anaconda3/bin:$PATH"\n' \
33
- ' fi\n' \
34
- 'fi\n' \
35
- 'unset __conda_setup\n' \
36
- '# <<< conda initialize <<<\n' \
37
- 'conda activate torch2_feat\n\n'
38
-
39
25
  '''
40
26
  Description:
41
27
  Obtain the execution status of the slurm jobs under the 'dir'
@@ -71,6 +57,24 @@ def get_slurm_job_run_info(dir:str, job_patten:str="*.job", tag_patten:str="tag.
71
57
 
72
58
  return slurm_failed, slurm_success
73
59
 
60
+ def recheck_slurm_by_jobtag(slurm_files:list[str], tag):
61
+ remain_job = []
62
+ for slurm_file in slurm_files:
63
+ with open(slurm_file, 'r') as f:
64
+ content = f.read()
65
+ cd_pattern = r'cd\s+([^\n]+)'
66
+ directories = re.findall(cd_pattern, content)
67
+ if not directories:
68
+ raise Exception("Error! There is no task in the slurm.job file {}".format(slurm_file))
69
+ for directory in directories:
70
+ directory = directory.strip()
71
+ success_file = os.path.join(directory, tag)
72
+ if os.path.exists(success_file):
73
+ continue
74
+ else:
75
+ remain_job.append(slurm_file)
76
+ break
77
+ return remain_job
74
78
 
75
79
  '''
76
80
  description:
@@ -146,14 +150,13 @@ def set_slurm_script_content(
146
150
  script += CPU_SCRIPT_HEAD.format(job_name, number_node, cpu_per_node, queue_name)
147
151
  script += "export CUDA_VISIBLE_DEVICES=''\n"
148
152
  else:
149
- script += GPU_SCRIPT_HEAD.format(job_name, number_node, cpu_per_node, gpu_per_node, 1, queue_name)
153
+ script += GPU_SCRIPT_HEAD.format(job_name, number_node, cpu_per_node, gpu_per_node, queue_name)
150
154
 
151
155
  for custom_flag in custom_flags:
152
156
  script += custom_flag + "\n"
153
157
 
154
158
  # set conda env
155
159
  script += "\n"
156
- # script += CONDA_ENV
157
160
  # script += "\n"
158
161
 
159
162
  script += "echo \"SLURM_SUBMIT_DIR is $SLURM_SUBMIT_DIR\"\n\n"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pwact
3
- Version: 0.1.27
3
+ Version: 0.1.28
4
4
  Summary: PWACT is an open-source automated active learning platform based on PWMLFF for efficient data sampling.
5
5
  Home-page: https://github.com/LonxunQuantum/PWact
6
6
  Author: LonxunQuantum
@@ -1,63 +1,63 @@
1
1
  pwact/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- pwact/main.py,sha256=EKFcwo_gk9BWhg3zU36RW7NXMLDfyhzrtjtvcv4h5dQ,17036
2
+ pwact/main.py,sha256=_EApUrHe-rfOiYMeI-FbnGxFtL6iOdua7vrM3ezXs3c,15186
3
3
  pwact/active_learning/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pwact/active_learning/environment.py,sha256=KvyMaOXrM-HMMma4SnoOQFO6fZxDsk0Fsyyy7xqfGCo,684
5
5
  pwact/active_learning/explore/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- pwact/active_learning/explore/run_model_md.py,sha256=opflniIxbT8SSPNwkGXcd8j_GVpWvDexhFhxYXXO8Yk,21053
7
- pwact/active_learning/explore/select_image.py,sha256=dmsMoxFwQ7JDPHK2vRFzUfXeEovT86cmUnmEm-qrfwE,12665
6
+ pwact/active_learning/explore/run_model_md.py,sha256=hrE-vMJBlvgxTiG0WFG86RX2Gi7ImtutF0PoT2RTTN0,21312
7
+ pwact/active_learning/explore/select_image.py,sha256=bDhDbdu6aoFfAdq_z3ha6qnxDGrQjfoHPVOKH7_u1VQ,14470
8
8
  pwact/active_learning/init_bulk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  pwact/active_learning/init_bulk/aimd.py,sha256=XzDlX2vylaljQKoUnv6nrI2NfiOdHZpq8qr3DenA1F4,10465
10
10
  pwact/active_learning/init_bulk/duplicate_scale.py,sha256=Z9mYBASy9gNLTV_db8lqfXpcahHbrQq6emae169P2wM,9468
11
- pwact/active_learning/init_bulk/init_bulk_run.py,sha256=FG1EAXvuBJ1ERCg2htFVooif8mxcx4XyVgOoKF-1B_Q,8683
11
+ pwact/active_learning/init_bulk/init_bulk_run.py,sha256=B6miVKjY9ClxYW-SyhsY63OHdJRDeL6zc0BMW75SBg8,9151
12
12
  pwact/active_learning/init_bulk/relabel.py,sha256=DJR90gnC_AIWkcbWGcf2FYVCwPU40iP1uB48cTgGn7k,10447
13
13
  pwact/active_learning/init_bulk/relax.py,sha256=edyCZLEylUckIwOLBa55agUMo-aedj0dvoyG165YpuE,10450
14
14
  pwact/active_learning/label/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- pwact/active_learning/label/labeling.py,sha256=tAFyTZjg64cNkG2_3p8qn5pc5F3je64UBgXnJT5PYtU,15687
15
+ pwact/active_learning/label/labeling.py,sha256=qtJdAGI_TyO0PtfexqCOITnHOnbTwVZCcaAH7BPGLCk,15102
16
16
  pwact/active_learning/slurm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- pwact/active_learning/slurm/slurm.py,sha256=xIDePutt8Q00--61y-RemT4Ky6qL9258kykaxKhIw8w,15637
17
+ pwact/active_learning/slurm/slurm.py,sha256=-Dmc2B9y4_27THCR2tZFXnwJvMmifivJeZ2FX8iy2Tw,16881
18
18
  pwact/active_learning/slurm/slurm_tool.py,sha256=-4tc5dkpAUP0vmEdmqM8oYLcsUwixa4Z8h5_E9Gevdg,1249
19
19
  pwact/active_learning/test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  pwact/active_learning/test/test.py,sha256=TXsk-gDDOHDLywVljpqA-zHK3-PrZbGAHnK1T7T6T-o,3587
21
21
  pwact/active_learning/train/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  pwact/active_learning/train/dp_kpu.py,sha256=GkGKEGhLmOvPERqgTkf_0_vD9zOEPlBX2N7vuSQG_-c,9317
23
- pwact/active_learning/train/train_model.py,sha256=NXqTKrl7Lb_UGt2-Lq_gLM9iZDAZFY09nxP_aGtBdrE,10525
23
+ pwact/active_learning/train/train_model.py,sha256=F6DUOuTsYGvinv-qz2iqa2j7DPy3hnCySVUkx8DpR_U,11605
24
24
  pwact/active_learning/user_input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  pwact/active_learning/user_input/cmd_infos.py,sha256=g1QW5Wi3JvmC5xEY4F-7AO1xBuJSjHG8IhZjom8haxQ,3728
26
- pwact/active_learning/user_input/init_bulk_input.py,sha256=NCUAB1xpa67MXHRRWAkmWZjkQbTibE4EjmtlOmr0HdQ,6762
27
- pwact/active_learning/user_input/iter_input.py,sha256=zwFCI6dDFIEVWitEqBBZP7TtrSvxMbmSUEPiM0Z8ZOk,10732
26
+ pwact/active_learning/user_input/init_bulk_input.py,sha256=7Suhxtgu84bn0ziL1RFF-7eSJUcLKJ2HF132RZmpNxw,6982
27
+ pwact/active_learning/user_input/iter_input.py,sha256=ffGNq8Qm2mALEviVHpZ0nFuKrqy1FuWriI2hg8F54X0,12131
28
28
  pwact/active_learning/user_input/resource.py,sha256=bg1rkdjIzuj7pDUvp6h1yMWFT0PqYzH4BfX5tJ7MZzc,6812
29
- pwact/active_learning/user_input/scf_param.py,sha256=Cvwbab-SjMBSblBxA-5ETVlDpLQohP_xux2OjrPSCYU,10244
29
+ pwact/active_learning/user_input/scf_param.py,sha256=tHmGnWrWiZ1dD-EZHfvWtzKGnT6BjIhXKMXNhPmWSQc,10376
30
30
  pwact/active_learning/user_input/workdir.py,sha256=64J3wBbYzy6ztYHs513YHfEIF5d8zwv_WpF-U9HOEkA,8245
31
31
  pwact/active_learning/user_input/train_param/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  pwact/active_learning/user_input/train_param/model_param.py,sha256=4-bJAGOJDTLT11lLqpEZAWMqgen7zghHESfHeb0UUb4,4574
33
33
  pwact/active_learning/user_input/train_param/nep_param.py,sha256=IoaQNwaXQFDXA7ET8NKptrkhvTE4lDknp23VccG6A1I,21251
34
34
  pwact/active_learning/user_input/train_param/nn_feature_type.py,sha256=eGmqfsPTlIpftzvUqHV_VziGQuUZ_KKqek3SQKZl85o,15640
35
35
  pwact/active_learning/user_input/train_param/optimizer_param.py,sha256=1Vl_BulrLkJmOPSetyn2HJMcwjizkkjrhvz0x8DzLRU,13084
36
- pwact/active_learning/user_input/train_param/train_param.py,sha256=hsdVojgQZbQGSexZ_ckuxdqJpjJTN8sBOlRM6VHUYjA,15814
37
- pwact/active_learning/user_input/train_param/work_file_param.py,sha256=tmedoLodmkcSK6uRIXTML0BhXFkgE96zPX0_kAXmGoo,11631
36
+ pwact/active_learning/user_input/train_param/train_param.py,sha256=rpLmOncwqQ82Hudwwl-VzZKJv2jCtrsCsJN2UpuHqKg,16640
37
+ pwact/active_learning/user_input/train_param/work_file_param.py,sha256=uFeCTJS7OS33NDaQBUtQZsKXTeHZpVVfybwCJgDW4x0,12246
38
38
  pwact/bin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  pwact/data_format/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
- pwact/data_format/configop.py,sha256=S2WaES4-9_FX_o6fLaBMw2uSIF1cUMLGj9APRRASy6Q,11984
40
+ pwact/data_format/configop.py,sha256=6JA84cK7Ck-t1z3iLz3pPVJ-q4srhDiQQhs9-G-cxY0,11772
41
41
  pwact/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
- pwact/utils/constant.py,sha256=ZM43rI0JNHA_nVKdRW1YvPGCEkomRNgdmA3_L8hAVSY,18379
43
- pwact/utils/file_operation.py,sha256=LFQ247afF_nUhxagZTYqIYs9GrJCwsiI2EuDhoxWIKQ,9032
42
+ pwact/utils/constant.py,sha256=nx1zArBWAwC17gIx7G-KHAhf_wrU1kPsfSxB3hr3Fuw,18764
43
+ pwact/utils/file_operation.py,sha256=1W5kGzGAznbAs2vyUhh5sDim62qQOkTPgphSOe_oDvI,9536
44
44
  pwact/utils/format_input_output.py,sha256=oYFydQy3-btXzieO2O2LbHFoeRyhPnLVE4c5TNgS-IQ,1798
45
45
  pwact/utils/json_operation.py,sha256=BqBsnIjk1URoMW_s2yu7Gk8IBxlir-oo6ivt8P3RIqg,1794
46
46
  pwact/utils/pre_al_data_util.py,sha256=QE-axnVYUIyORFiVs-WK9-UaJlMUFY816_rSyYOOJc8,2542
47
- pwact/utils/process_tool.py,sha256=trzp6GbP_SYFiS_vheobV_FI4PSWVJvX3xHsFQ6DWME,478
48
- pwact/utils/slurm_script.py,sha256=mgueOrhYteg6XXvJitdjmbV4lzxMujuna9Jxr3wgC7Q,8237
47
+ pwact/utils/process_tool.py,sha256=j4yp9DoPshTxTX3g7SS-yuEbBVhuoYNNZdAv2mq3efE,876
48
+ pwact/utils/slurm_script.py,sha256=tbclNkYBVM-t8GeiLGNK2s5kxypjy8luf4ZrlHEGjjM,8278
49
49
  pwact/utils/tmp.py,sha256=en_GltoNwfA40vSHttMRi9cEg-8xnPZlvnnBq1_vHfw,2285
50
50
  pwact/utils/app_lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
51
  pwact/utils/app_lib/common.py,sha256=lQmI-9Qumq62MNjr-eVlLL88ISDHBOb6vAfYYFcDIgM,6040
52
- pwact/utils/app_lib/cp2k.py,sha256=ljhCCHmZ2kfoXEXn5O7-D56EgTLn2a7H3y_TIkHiasY,13157
52
+ pwact/utils/app_lib/cp2k.py,sha256=txd-eMDUOsWPug395WJOQz3aqhwz7eU4hcEZIWTF1OY,15492
53
53
  pwact/utils/app_lib/cp2k_dp.py,sha256=VP4gyPGhLcMAqAjrqCQSUiiGlESNlyYz7Gs3Q4QoUHo,6912
54
54
  pwact/utils/app_lib/lammps.py,sha256=2oxHJHdDxfDDWWmnjo0gMNwgGvxABwuDgDlb8kbhgfk,8037
55
55
  pwact/utils/app_lib/pwmat.py,sha256=PTRPkG_d00ibGhpCe2-4M7MW3dx2ZuAyb9hT2jl_LAs,18047
56
56
  pwact/utils/draw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
57
  pwact/utils/draw/hist_model_devi.py,sha256=o1Try-ekith2A7S6u1mt3zuTqaQwyw5tdURReh8BeLY,4945
58
- pwact-0.1.27.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
59
- pwact-0.1.27.dist-info/METADATA,sha256=Kk2-JzZqYkUYiqFRbvXMFLiJBj5hV-jIITIG1U2G8q0,3659
60
- pwact-0.1.27.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
61
- pwact-0.1.27.dist-info/entry_points.txt,sha256=p61auAnpbn8E2WjvHNBA7rb9_NRAOCew4zdcCj33cGc,42
62
- pwact-0.1.27.dist-info/top_level.txt,sha256=fY1_7sH5Lke4dC9L8MbYM4fT5aat5eCkAmpkIzY1SlM,6
63
- pwact-0.1.27.dist-info/RECORD,,
58
+ pwact-0.1.28.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
59
+ pwact-0.1.28.dist-info/METADATA,sha256=nAiDrWaNcIP_GubrMMqGYpDX6AMCXtoawCE6tA41zvI,3659
60
+ pwact-0.1.28.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
61
+ pwact-0.1.28.dist-info/entry_points.txt,sha256=p61auAnpbn8E2WjvHNBA7rb9_NRAOCew4zdcCj33cGc,42
62
+ pwact-0.1.28.dist-info/top_level.txt,sha256=fY1_7sH5Lke4dC9L8MbYM4fT5aat5eCkAmpkIzY1SlM,6
63
+ pwact-0.1.28.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.44.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5