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

version 1.2.0 #66

Merged
merged 225 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
225 commits
Select commit Hold shift + click to select a range
09bb072
feat: add MongoDB plugin
ZLI-afk Nov 10, 2023
2be826a
feat: add record data function for MongoDB.py
ZLI-afk Nov 13, 2023
3d943ca
feat: support auto archive results after workflow completed
ZLI-afk Nov 13, 2023
30c3c6f
fix: support depth for recursive update for sync database
ZLI-afk Nov 14, 2023
a3d2660
fix(IMPORTANT): duplicated files in property task path resulted from …
ZLI-afk Nov 14, 2023
9c59b6b
feat: add DynamoDB.py to support DynamoDB
ZLI-afk Nov 14, 2023
e73fdda
feat: add DynamoDB.py to support DynamoDB
ZLI-afk Nov 15, 2023
5ae7e5b
feat: add database client and archive.py for result archive
ZLI-afk Nov 22, 2023
c9b1c83
feat(unfinished): add DASH reporter function for local results visual…
ZLI-afk Nov 28, 2023
0652e9d
feat(unfinished): add DASH reporter function for local results visual…
ZLI-afk Nov 28, 2023
c5791bb
feat(unfinished): add DASH reporter function for local results visual…
ZLI-afk Nov 28, 2023
a4662ee
feat(unfinished): add DASH reporter function for local results visual…
ZLI-afk Nov 28, 2023
54aa2e1
feat(unfinished): add DASH reporter function for local results visual…
ZLI-afk Nov 28, 2023
35723c1
feat: add DASH reporter function for local results visualization
ZLI-afk Dec 5, 2023
eb74d46
feat: add DASH reporter function for local results visualization
ZLI-afk Dec 5, 2023
cac2e21
feat: add DASH reporter function for local results visualization
ZLI-afk Dec 6, 2023
d064257
fix: turn off reload mode of flask
ZLI-afk Dec 7, 2023
7ebf9dc
fix: fix refine bug for post_process of Gamma.py
ZLI-afk Dec 9, 2023
b070af4
Chore: Update README.md for v1.2.0
ZLI-afk Dec 10, 2023
00bda7f
Chore: Update README.md for v1.2.0
ZLI-afk Dec 10, 2023
b3bcb4d
Chore: Update README.md for v1.2.0
ZLI-afk Dec 10, 2023
d98147d
Chore: Update README.md for v1.2.0
ZLI-afk Dec 10, 2023
6f42e1d
feat: add update dropdown list callback in DashReportApp.py
ZLI-afk Dec 12, 2023
9df4857
feat: add update dropdown list callback in DashReportApp.py
ZLI-afk Dec 12, 2023
2f94869
fix: functional clipboards
ZLI-afk Dec 12, 2023
740dd71
chore: print NOTE for abnormal reload error of the dash app
ZLI-afk Dec 13, 2023
781af11
feat: support archive result json files directly in archive.py
ZLI-afk Dec 14, 2023
5cc315c
fix: inappropriate indentification of lattice structure for alloy
ZLI-afk Dec 18, 2023
f9ea6e5
fix: delete breakpoint
ZLI-afk Dec 18, 2023
58427cf
fix: delete breakpoint
ZLI-afk Dec 18, 2023
2ae352c
chore: revise label and table tile context in report app
ZLI-afk Dec 29, 2023
5a3d2ae
chore: adjust report APP UI frontsize
ZLI-afk Dec 30, 2023
7f25d09
feat: support eight SIA structure for HCP in Interstitial.py
ZLI-afk Jan 3, 2024
63d9918
feat: support eight SIA structure for HCP in Interstitial.py
ZLI-afk Jan 3, 2024
701fc53
feat: support MEAM-spline type interaction for LAMMPS
ZLI-afk Jan 4, 2024
b2e03e2
feat: support MEAM-spline type interaction for LAMMPS
ZLI-afk Jan 4, 2024
6942a48
feat: add structure info into relaxation results and final reporter; …
ZLI-afk Jan 4, 2024
1214ae6
feat: add structure info into relaxation results and final reporter; …
ZLI-afk Jan 4, 2024
429f3c5
fix: skip task.000000 POSCAR structure
ZLI-afk Jan 4, 2024
ce3006e
fix: skip task.000000 POSCAR structure
ZLI-afk Jan 4, 2024
710f211
feat: add slip length information to post of Gamma.py
ZLI-afk Jan 4, 2024
bbe0e29
feat: support seekpath for automatic band path seek for Phonon.py
ZLI-afk Jan 5, 2024
bea20ae
feat: support seekpath for automatic band path seek for Phonon.py
ZLI-afk Jan 7, 2024
0842083
feat: support seekpath for automatic band path seek for Phonon.py
ZLI-afk Jan 7, 2024
07fd538
feat: support seekpath for automatic band path seek for Phonon.py
ZLI-afk Jan 7, 2024
0bf9801
feat: support seekpath for automatic band path seek for Phonon.py and…
ZLI-afk Jan 7, 2024
99d1c54
feat: support seekpath for automatic band path seek for Phonon.py and…
ZLI-afk Jan 7, 2024
08d851f
fix: false reading of BAND_LABELS by input in Phonon.py
ZLI-afk Jan 8, 2024
2c834cb
fix: false reading of BAND_LABELS by input in Phonon.py
ZLI-afk Jan 8, 2024
d4a2c5e
fix: bug of missing link for the meam lib file in meam in Lammps.py
ZLI-afk Jan 8, 2024
f846e24
fix: bug of missing link for the meam lib file in meam in Lammps.py
ZLI-afk Jan 8, 2024
54ca345
feat: unify the color list for line plot of all properties in reporte…
ZLI-afk Jan 8, 2024
100ab0c
feat: unify the color list for line plot of all properties in reporte…
ZLI-afk Jan 8, 2024
969e048
feat: add atomic type map to pair_style in deepmd in.lammps template
ZLI-afk Jan 9, 2024
7a820e8
feat: support snap type of Ml interation for md calculation
ZLI-afk Jan 9, 2024
07321be
feat: support gap type of Ml interation for md calculation
ZLI-afk Jan 9, 2024
119b1d7
feat: support gap type of Ml interation for md calculation
ZLI-afk Jan 9, 2024
313f90b
feat: support rann type of Ml interation for md calculation
ZLI-afk Jan 9, 2024
1c1339e
feat: expose parameters of VoronoiInterstitialGenerator
ZLI-afk Jan 11, 2024
f7c30c1
fix: unstable pseudo interstitial structure that may be filtered by p…
ZLI-afk Jan 12, 2024
24bc85f
fix: remove all tmp potential model files
ZLI-afk Jan 13, 2024
be1522c
fix: remove all tmp potential model files
ZLI-afk Jan 15, 2024
3d09529
fix: remove all POTCAR in vasp tasks
ZLI-afk Jan 15, 2024
a865c0a
fix: remove all POTCAR in vasp tasks
ZLI-afk Jan 15, 2024
e7addbd
fix: set default incar value of ISMEAR=0, SIGMA=0.01 for finite displ…
ZLI-afk Jan 17, 2024
9c5b210
fix: set default incar value of ISMEAR=0, SIGMA=0.01 for finite displ…
ZLI-afk Jan 18, 2024
227bc62
fix: set default incar value of ISMEAR=0, SIGMA=0.01 for finite displ…
ZLI-afk Jan 19, 2024
1ee1dab
feat: 1. only upload necessary files and path onto dflow instead of a…
ZLI-afk Jan 21, 2024
4dbe5f7
feat: 1. only upload necessary files and path onto dflow instead of a…
ZLI-afk Jan 21, 2024
3101d10
fix: robust of temp upload function regards to one type of json file …
ZLI-afk Jan 22, 2024
1b4e10e
fix: bug of missing refine init directory in tmp upload path
ZLI-afk Jan 26, 2024
5e3eb36
feat(BREAK!): abandon PropertyFlow.py with parallelled SimpleProperty…
ZLI-afk Jan 26, 2024
60a8db1
chore: simplify process monitoring codes in flow.py
ZLI-afk Jan 27, 2024
cebabd0
fix: bug related to wrong parameter files transfer in submit.py
ZLI-afk Jan 27, 2024
d019c66
fix: bug related to wrong dead loop when sub-flow failed in flow.py
ZLI-afk Jan 27, 2024
94995cd
fix: reformat sub-props flows key string
ZLI-afk Jan 30, 2024
af2a1a5
feat: add download.py for results retrieving manually.
ZLI-afk Feb 1, 2024
e810c4f
Update README.md
ZLI-afk Feb 2, 2024
d8a5bba
feat: change plot style to white background in DashReportApp.py
ZLI-afk Feb 16, 2024
180b2cb
feat(fix): add MACE type of interation for Lammps.py; fix potential u…
ZLI-afk Feb 22, 2024
131618b
feat(fix): add MACE type of interation for Lammps.py; fix potential u…
ZLI-afk Feb 22, 2024
92b8275
chore: change download cmd string to retrieve
ZLI-afk Feb 23, 2024
ccd2798
chore: remove phonoLAMMPS from local dependency in setup.py
ZLI-afk Feb 25, 2024
a43a7ac
feat: remove all potential files in relaxation_ops.py
ZLI-afk Feb 25, 2024
ca2408b
fix: detour mismatch issue of lammps minimization output with deepmd-…
ZLI-afk Feb 26, 2024
74c4f28
feat: support customized tag for all_result.json in report.py
ZLI-afk Feb 26, 2024
334fa13
fix: fix bug of relaxation json provided only submission in submit.py
ZLI-afk Feb 26, 2024
f671534
chore: change webbrowser.open_new to webbrowser.open in DashReportApp.py
ZLI-afk Feb 26, 2024
2bd3a87
fix: clean potential files under configuration directories when do po…
ZLI-afk Feb 27, 2024
c739d4f
chore: revise phonon label position in property_report.py
ZLI-afk Feb 27, 2024
8c531df
chore: revise confusing codes
ZLI-afk Feb 29, 2024
533f890
Change!: change 'test' cmd to 'run'
ZLI-afk Mar 2, 2024
095c371
change: remove python3.8 from test list in main.yml
ZLI-afk Mar 2, 2024
d30dfe9
fix: fix unnecessary config file FileNotFoundError for run.py
ZLI-afk Mar 6, 2024
bbae84d
fix: fix bug of SameFileError of copy POSCAR-unit in run mode of post…
ZLI-afk Mar 6, 2024
eb81c3c
fix: fix bug of single step run not retrieve of vasprun.xml during ph…
ZLI-afk Mar 7, 2024
ed1c5a7
fix: fix bug of single step run not retrieve of vasprun.xml during ph…
ZLI-afk Mar 7, 2024
54c9b0e
fix: fix bug of single step run not retrieve of FORCE_CONSTANTS durin…
ZLI-afk Mar 7, 2024
c542eb6
chore: Update README.md
ZLI-afk Mar 7, 2024
a43a876
fix dependencies
ZLI-afk Mar 15, 2024
d6ce9a8
revise dependencies
ZLI-afk Mar 15, 2024
1964e09
revise dependencies
ZLI-afk Mar 15, 2024
5a0d08c
revise python dependencies to >=3.8
ZLI-afk Mar 15, 2024
dabc7c4
revise python dependencies to >=3.8
ZLI-afk Mar 15, 2024
fcee0b5
revise python dependencies to >=3.8
ZLI-afk Mar 15, 2024
083d6fe
revise python dependencies to >=3.8
ZLI-afk Mar 15, 2024
25decaf
revise python dependencies to >=3.8
ZLI-afk Mar 15, 2024
47a4014
revise python dependencies to >=3.8
ZLI-afk Mar 15, 2024
bd66b67
revise python dependencies to >=3.8
ZLI-afk Mar 15, 2024
e07721c
feats: support dflow operations of subcommands: list; get; getsteps; …
ZLI-afk Mar 20, 2024
194fbf0
update README.md
ZLI-afk Mar 20, 2024
9953703
fix: Kpoint.from_string to from_str
ZLI-afk Mar 21, 2024
6918f47
feat: add .workflow.log to record dflow operations and workflow ID
ZLI-afk Mar 21, 2024
9a14cfc
feat: add .workflow.log to record dflow operations and workflow ID
ZLI-afk Mar 21, 2024
ce1c39d
feat: add .workflow.log to record dflow operations and workflow ID
ZLI-afk Mar 21, 2024
9f0a928
update README.md
ZLI-afk Mar 21, 2024
6b22fc7
chore: integrate retrieve.py into main.py and delete retrieve.py
ZLI-afk Mar 21, 2024
c2c15aa
chore: revise print out help in DashReportApp.py
ZLI-afk Mar 22, 2024
c60068e
update README.md for v1.2.0
ZLI-afk Mar 22, 2024
04f321c
update README.md for v1.2.0
ZLI-afk Mar 22, 2024
0468cb8
update README.md for v1.2.0
ZLI-afk Mar 22, 2024
b0c4720
fix: detour lammps dump synchronizing problem when deepmd-kit version…
ZLI-afk Mar 22, 2024
bc4ea77
Merge branch 'devel-1.2.0' into v1.2
ZLI-afk Mar 27, 2024
12b5922
update README.md
ZLI-afk Mar 27, 2024
d9e17aa
Merge remote-tracking branch 'origin/v1.2' into v1.2
ZLI-afk Mar 27, 2024
17d9be3
Merge pull request #54 from deepmodeling/main
kevinwenminion Mar 27, 2024
623e1c7
Merge pull request #53 from ZLI-afk/v1.2
kevinwenminion Mar 27, 2024
1210b78
add logo.png & update README.md
ZLI-afk Mar 28, 2024
f460b2a
update README.md
ZLI-afk Mar 28, 2024
3549d8e
update README.md
ZLI-afk Mar 28, 2024
f6681c8
update README.md and Dockerfile
ZLI-afk Mar 28, 2024
43fe778
chore: revise example data
ZLI-afk Mar 28, 2024
d39de67
Merge pull request #55 from ZLI-afk/v1.2
kevinwenminion Mar 28, 2024
102230b
fix: fix wrong command in README.md
ZLI-afk Mar 28, 2024
82a4fe9
Merge pull request #5 from deepmodeling/devel-1.2.0
kevinwenminion Mar 28, 2024
cfbbeaa
refine core/calculator
kevinwenminion Mar 28, 2024
db04400
refine Lammps.py
kevinwenminion Mar 29, 2024
6a68fcb
refine VASP.py
kevinwenminion Mar 30, 2024
c6453ea
refine core/lib/ common_equi.py submit.py
kevinwenminion Mar 31, 2024
f789569
fix: fix missing copy of STRU into tmp upload directory
ZLI-afk Mar 31, 2024
bac5c0d
fix: fix missing copy of STRU into tmp upload directory
ZLI-afk Mar 31, 2024
19e1ff2
refine common_prop.py
kevinwenminion Mar 31, 2024
89a542f
update common_equi and refine.py
kevinwenminion Apr 1, 2024
710fcc4
refine reproduce
kevinwenminion Apr 1, 2024
40b7825
refine EOS
kevinwenminion Apr 2, 2024
eb56616
fix: fail to inject run command of phonolammps under single step run …
ZLI-afk Apr 3, 2024
a7d270b
change: change `run` subcommand name into `do`
ZLI-afk Apr 3, 2024
145fe01
Update README.md
ZLI-afk Apr 3, 2024
d4ed962
update elastic
kevinwenminion Apr 4, 2024
594daec
refine vacancy
kevinwenminion Apr 4, 2024
e4549c6
refine interstitial
kevinwenminion Apr 4, 2024
1242443
refine surface
kevinwenminion Apr 4, 2024
6fc2093
refine gamma line
kevinwenminion Apr 4, 2024
bdbf229
refine phonon
kevinwenminion Apr 5, 2024
164a8f1
refine op directory
kevinwenminion Apr 5, 2024
59b8c30
default value of skip is false in property
kevinwenminion Apr 5, 2024
04a4512
update readme
kevinwenminion Apr 5, 2024
a57dce6
minor issues
kevinwenminion Apr 5, 2024
275dc4a
fix: error related to indication of two calculation parameter json
ZLI-afk Apr 6, 2024
5765d13
update examples
kevinwenminion Apr 6, 2024
2838712
update examples
kevinwenminion Apr 6, 2024
d11ec01
Merge pull request #60 from kevinwenminion/devel-1.2.0
kevinwenminion Apr 6, 2024
efd89c4
fix: fix missing copy of STRU into tmp upload directory
ZLI-afk Mar 31, 2024
1e10109
fix: fix missing copy of STRU into tmp upload directory
ZLI-afk Mar 31, 2024
2d68bb4
fix: fail to inject run command of phonolammps under single step run …
ZLI-afk Apr 3, 2024
7e1e7a0
change: change `run` subcommand name into `do`
ZLI-afk Apr 3, 2024
92eaf73
Update README.md
ZLI-afk Apr 3, 2024
a87a1c7
resolve merge from tongqi
ZLI-afk Apr 6, 2024
794c80a
Merge branch 'devel-1.2-resolve' into v1.2 (resolved)
ZLI-afk Apr 6, 2024
6ae8911
change logo pic
ZLI-afk Apr 6, 2024
1980abc
update README.md
ZLI-afk Apr 6, 2024
4dfb43e
chore: remove dpgen from labelling
ZLI-afk Apr 8, 2024
cd8c79b
chore: remove dpgen from labelling
ZLI-afk Apr 9, 2024
80f05ed
Merge pull request #56 from ZLI-afk/v1.2
kevinwenminion Apr 10, 2024
9f27c44
Merge pull request #38 from deepmodeling/devel-1.2.0
ZLI-afk Apr 10, 2024
13094f3
chore: update reporter_ui.png
ZLI-afk Apr 10, 2024
6216a3e
Merge pull request #61 from ZLI-afk/v1.2
kevinwenminion Apr 10, 2024
809dbfa
feats(ABACUS): auto convert POSCAR to STRU; auto fill pp_file name to…
ZLI-afk Apr 11, 2024
2264e8b
chore: print `header` only before `submit` and `do` sub-commands
ZLI-afk Apr 15, 2024
2c8cb06
feat(submit): support workflow submit only without result hearing and…
ZLI-afk Apr 15, 2024
f891e70
chore: enhance readability
ZLI-afk Apr 16, 2024
89657f7
feat(archive): set random string as key id when archive to NoSQL data…
ZLI-afk Apr 16, 2024
2c7a191
fix: POTCAR disorder in VASP.py
ZLI-afk Apr 16, 2024
e6752ef
fix: None key value of empty all_result.json
ZLI-afk Apr 16, 2024
a6124c4
feat(elastic): support auto adoption of conventional cell for given c…
ZLI-afk Apr 17, 2024
7dd9133
Merge pull request #63 from ZLI-afk/v1.2
kevinwenminion Apr 17, 2024
78d066d
Merge pull request #6 from deepmodeling/devel-1.2.0
kevinwenminion Apr 17, 2024
6652fa2
refine information print
kevinwenminion Apr 17, 2024
bbfbbe1
fix: minor error
ZLI-afk Apr 17, 2024
6ed6522
feat(elastic): support auto modification of input relaxed POSCAR-stru…
ZLI-afk Apr 17, 2024
13671ec
feat(elastic): support auto modification of input relaxed POSCAR-stru…
ZLI-afk Apr 17, 2024
fb25a9f
feat(elastic): support auto modification of input relaxed POSCAR-stru…
ZLI-afk Apr 17, 2024
74eeede
test only
ZLI-afk Apr 18, 2024
d0c2967
test only
ZLI-afk Apr 18, 2024
cf2f432
undo test commit
ZLI-afk Apr 18, 2024
109af0d
Merge pull request #65 from kevinwenminion/devel-1.2.0
kevinwenminion Apr 20, 2024
037ae19
change: set default of ieee to be False in Elastic.py
ZLI-afk Apr 21, 2024
8250da4
fix: unexpect termination of relaxation monitoring loop
ZLI-afk Apr 22, 2024
d0e2904
change: turn on default ieee translation
ZLI-afk Apr 22, 2024
0ca18b8
feat(change): add `flow_name` to submit sub-mode for specification of…
ZLI-afk Apr 24, 2024
0699617
change: change default of `ieee` to False in Elastic.py
ZLI-afk Apr 24, 2024
37f793c
Update README.md
ZLI-afk Apr 24, 2024
0ec7455
change(minor): add `flow_type` to default `flow_name`
ZLI-afk Apr 24, 2024
be475c5
change(minor): turn of defult `ieee` correction in Elastic.py
ZLI-afk Apr 26, 2024
d5106b4
fix: reporter AttributeError by popping out `archive_key` from load d…
ZLI-afk Apr 26, 2024
85415cf
feat: simplify tmp upload dirs
ZLI-afk Apr 27, 2024
cdc0e2b
feat: simplify tmp upload dirs
ZLI-afk Apr 27, 2024
9d30174
add nightly version tag
ZLI-afk Apr 28, 2024
b33c8fc
add doi badge
ZLI-afk Apr 30, 2024
8826c09
add doi badge
ZLI-afk Apr 30, 2024
16ff500
add doi badge
ZLI-afk Apr 30, 2024
74a624c
add doi badge
ZLI-afk Apr 30, 2024
af7dd43
add doi badge
ZLI-afk Apr 30, 2024
f84068d
add citation to header and README.md
ZLI-afk Apr 30, 2024
8c280fb
add citation to header and README.md
ZLI-afk Apr 30, 2024
b5ade62
add citation to header and README.md
ZLI-afk Apr 30, 2024
480c6d6
add citation to header and README.md
ZLI-afk Apr 30, 2024
04d45e2
add app link to header and README.md
ZLI-afk May 6, 2024
1dc0113
add app link to header and README.md
ZLI-afk May 6, 2024
62c2370
add app link to header and README.md
ZLI-afk May 6, 2024
48fcc94
add app link to header and README.md
ZLI-afk May 6, 2024
fdfdca8
add app link to header and README.md
ZLI-afk May 6, 2024
1ab7ddd
update README.md
ZLI-afk May 6, 2024
92b9ea6
update README.md
ZLI-afk May 6, 2024
f2afb74
Merge pull request #64 from ZLI-afk/v1.2
kevinwenminion May 6, 2024
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
247 changes: 182 additions & 65 deletions README.md

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion apex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
__version__ = '1.1.1'
__version__ = '1.2.0'
LOCAL_PATH = os.getcwd()


Expand Down Expand Up @@ -27,5 +27,9 @@ def header():
header_str += " AAA AAA PPP EEEEEEEEEE XXX XXX\n"
header_str += "---------------------------------------------------------------\n"
header_str += f"==>> Alloy Property EXplorer using simulations (v{__version__})\n"
header_str += "Please cite DOI: 10.48550/arXiv.2404.17330\n"
header_str += "Li et al, An extendable cloud-native alloy property explorer (2024).\n"
header_str += "See https://github.com/deepmodeling/APEX for more information.\n"
header_str += "---------------------------------------------------------------\n"
header_str += "Checking input files..."
print(header_str)
273 changes: 273 additions & 0 deletions apex/archive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
import glob
import logging
import json
import os
from typing import List
from pathlib import Path
from monty.json import MontyEncoder
from monty.serialization import loadfn, dumpfn
from apex.utils import (
judge_flow,
json2dict,
update_dict,
return_prop_list,
load_config_file,
generate_random_string
)
from apex.database.DatabaseFactory import DatabaseFactory
from apex.config import Config


class ResultStorage:
def __init__(self, work_dir):
self.work_dir = Path(work_dir).absolute()
self.result_dict = {'work_path': str(self.work_dir)}

@property
def result_data(self):
return self.result_dict

@property
def work_dir_path(self):
return str(self.work_dir)

@json2dict
def sync_relax(self, relax_param: dict):
# sync results from relaxation task
confs = relax_param["structures"]
interaction = relax_param["interaction"]
conf_dirs = []
for conf in confs:
conf_dirs.extend(glob.glob(str(self.work_dir / conf)))
conf_dirs.sort()
for ii in conf_dirs:
relax_task = os.path.join(ii, 'relaxation/relax_task')
inter,task,structure,result=[os.path.join(relax_task,ii) for ii in
['inter.json','task.json','structure.json','result.json']]
if not (
os.path.isfile(inter)
and os.path.isfile(task)
and os.path.isfile(result)
):
logging.warning(
f"relaxation result path is not complete, will skip result extraction from {relax_task}"
)
continue
logging.info(msg=f"extract results from {relax_task}")
conf_key = os.path.relpath(ii, self.work_dir)
conf_dict = {"interaction": loadfn(inter),
"parameter": loadfn(task),
"structure_info": loadfn(structure),
"result": loadfn(result)}
new_dict = {conf_key: {"relaxation": conf_dict}}
update_dict(self.result_dict, new_dict)

@json2dict
def sync_props(self, props_param: dict, archive_tasks: bool = False):
# sync results from property test
confs = props_param["structures"]
interaction = props_param["interaction"]
properties = props_param["properties"]
prop_list = return_prop_list(properties)
conf_dirs = []
for conf in confs:
conf_dirs.extend(glob.glob(str(self.work_dir / conf)))
conf_dirs.sort()
for ii in conf_dirs:
for jj in prop_list:
prop_dir = os.path.join(ii, jj)
result = os.path.join(prop_dir, 'result.json')
param = os.path.join(prop_dir, 'param.json')
task_list_path = os.path.join(prop_dir, 'task_list.json')
if not os.path.isfile(result):
logging.warning(
f"Property post-process is not complete, will skip result extraction from {prop_dir}"
)
continue
logging.info(msg=f"extract results from {prop_dir}")
conf_key = os.path.relpath(ii, self.work_dir)
result_dict = loadfn(result)
try:
param_dict = loadfn(param)
except FileNotFoundError:
logging.warning(f'{param} file not found')
param_dict = None
prop_dict = {"parameter": param_dict, "result": result_dict}
# extract running details of each task
if archive_tasks:
logging.debug(msg='Archive running details of tasks...')
logging.warning(
msg='You are trying to archive detailed running log of each task into database,'
'which may exceed the limitation of database allowance.'
'Please consider spliting the data or only archiving details of the most important property.'
)
try:
task_list = loadfn(task_list_path)
result_task_path = [os.path.join(prop_dir, task, 'result_task.json') for task in task_list]
except FileNotFoundError:
logging.warning(f'{task_list_path} file not found, will track all tasks listed {prop_dir}')
result_task_path = glob.glob(os.path.join(prop_dir, 'task.*', 'result_task.json'))
task_result_list = [loadfn(kk) for kk in sorted(result_task_path)]
prop_dict["tasks"] = task_result_list

new_dict = {conf_key: {jj: prop_dict}}
update_dict(self.result_dict, new_dict)


def connect_database(config):
# connect to database
if config.database_type == 'mongodb':
logging.info(msg='Use database type: MongoDB')
database = DatabaseFactory.create_database(
'mongodb',
'mongodb',
config.mongodb_database,
config.mongodb_collection,
**config.mongodb_config_dict
)
elif config.database_type == 'dynamodb':
logging.info(msg='Use database type: DynamoDB')
database = DatabaseFactory.create_database(
'dynamodb',
'dynamodb',
config.dynamodb_table_name,
**config.dynamodb_config_dict
)
else:
raise RuntimeError(f'unsupported database type: {config.database_type}')
return database


def archive2db(config, data: dict, data_id: str):
database = connect_database(config)
# archive results database
if config.archive_method == 'sync':
logging.debug(msg='Archive method: sync')
database.sync(data, data_id, depth=2)
elif config.archive_method == 'record':
logging.debug(msg='Archive method: record')
database.record(data, data_id)
else:
raise TypeError(
f'Unrecognized archive method: {config.archive_method}. '
f"Should select from 'sync' and 'record'."
)


def archive_workdir(relax_param, props_param, config, work_dir, flow_type):
print(f'=> Begin archiving {work_dir}')
# extract results json
store = ResultStorage(work_dir)
if relax_param and flow_type != 'props':
store.sync_relax(relax_param)
if props_param and flow_type != 'relax':
store.sync_props(props_param, config.archive_tasks)

dump_file = os.path.join(store.work_dir_path, 'all_result.json')
default_id = generate_random_string(10)
if os.path.isfile(dump_file):
logging.info(msg='all_result.json exists, and will be updated.')
orig_data = loadfn(dump_file)
try:
default_id = orig_data['archive_key']
except KeyError:
store.result_data['archive_key'] = default_id
update_dict(orig_data, store.result_data, depth=2)
dumpfn(orig_data, dump_file, indent=4)
else:
store.result_data['archive_key'] = default_id
dumpfn(store.result_data, dump_file, indent=4)

# try to get documented key id from all_result.json
# define archive key
data_id = config.archive_key if config.archive_key else default_id

if config.database_type != 'local':
data_json_str = json.dumps(store.result_data, cls=MontyEncoder, indent=4)
data_dict = json.loads(data_json_str)
data_dict['_id'] = data_id

archive2db(config, data_dict, data_id)


def archive2db_from_json(config, json_file):
logging.info(msg=f'Archive from local json file: {json_file}')
data_dict = loadfn(json_file)
data_json_str = json.dumps(data_dict, cls=MontyEncoder, indent=4)
data_dict = json.loads(data_json_str)
# define archive key
if config.archive_key:
data_id = config.archive_key
else:
data_id = data_dict['archive_key']
data_dict['_id'] = data_id

archive2db(config, data_dict, data_id)


def archive_result(
parameters: List[os.PathLike],
config_dict: dict,
work_dir: List[os.PathLike],
indicated_flow_type: str,
database_type,
method,
archive_tasks,
is_result
):
global_config = Config(**config_dict)
# re-specify args
if database_type:
global_config.database_type = database_type
if method:
global_config.archive_method = method
if archive_tasks:
global_config.archive_tasks = archive_tasks

if is_result:
# archive local results json file
json_file_list = []
# Parameter here stands for json files that store test results and be archived directly
for ii in parameters:
glob_list = glob.glob(os.path.abspath(ii))
json_file_list.extend(glob_list)
json_file_list.sort()
for ii in json_file_list:
archive2db_from_json(global_config, ii)
else:
_, _, flow_type, relax_param, props_param = judge_flow(
[loadfn(jj) for jj in parameters],
indicated_flow_type
)
# archive work directories
work_dir_list = []
for ii in work_dir:
glob_list = glob.glob(os.path.abspath(ii))
work_dir_list.extend(glob_list)
work_dir_list.sort()
for ii in work_dir_list:
archive_workdir(relax_param, props_param, global_config, ii, flow_type)


def archive_from_args(
parameters: List[os.PathLike],
config_file: os.PathLike,
work_dirs: List[os.PathLike],
indicated_flow_type: str,
database_type,
method,
archive_tasks,
is_result
):
print('-------Archive result Mode-------')
archive_result(
parameters=parameters,
config_dict=load_config_file(config_file),
work_dir=work_dirs,
indicated_flow_type=indicated_flow_type,
database_type=database_type,
method=method,
archive_tasks=archive_tasks,
is_result=is_result
)
print('Complete!')
Loading