forked from dptech-corp/dpgen2
-
Notifications
You must be signed in to change notification settings - Fork 35
feat: merged mode for caly evo step #224
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
Merged
zjgemi
merged 20 commits into
deepmodeling:master
from
wangzyphysics:wrap-caly-evo-step
May 29, 2024
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
261c880
feat: wrap caly_evo_step into normal op
wangzyphysics b12b8c0
fix: merge_caly_evo_step ut
wangzyphysics 29e00d3
fix: merge op output error
wangzyphysics e65147b
fix: make executor flexible accorind to expl_mode (debug or default)
wangzyphysics ba1e85f
fix: init_executor has been wrapped into func
wangzyphysics ccbadd1
fix: split merge and default op
wangzyphysics 2186693
fix: ut random failed
wangzyphysics a912324
fix: ut
wangzyphysics bcc0945
feat: add ntasks in prep_caly_input outputs
wangzyphysics fa3558c
fix: change range(1) into [0]
wangzyphysics 0628717
fix: ut
wangzyphysics 3ba9ece
fix: ut
wangzyphysics dcb76b2
refactor: rename executor into executor_config
wangzyphysics 2651013
refactor: if branch only on template rather than superop
wangzyphysics 8214f94
fix: add type hint
wangzyphysics cc1ce6e
fix: collruncaly taskname now is a BigParameter
wangzyphysics a126019
fix: add executor in superop
wangzyphysics 5069cad
docs: update example input
wangzyphysics b96af7a
change task_name to BigParameter
zjgemi f82334d
change task_name to BigParameter
wangzyphysics File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,129 @@ | ||||||||||
import json | ||||||||||
import logging | ||||||||||
import pickle | ||||||||||
import shutil | ||||||||||
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused imports to clean up the code. - import json
- import logging
- import pickle
- import shutil
- from typing import Tuple
- from dflow.python.TransientError import TransientError
- from dpgen2.constants import calypso_check_opt_file, calypso_run_opt_file
- from dpgen2.exploration.task import ExplorationTaskGroup
- from dpgen2.utils import BinaryFileInput, set_directory
- from dpgen2.utils.run_command import run_command Also applies to: 10-10, 27-27, 34-35, 38-38, 44-45, 48-48 Committable suggestion
Suggested change
|
||||||||||
from pathlib import ( | ||||||||||
Path, | ||||||||||
) | ||||||||||
from typing import ( | ||||||||||
List, | ||||||||||
Tuple, | ||||||||||
) | ||||||||||
|
||||||||||
from dflow import ( | ||||||||||
Step, | ||||||||||
Workflow, | ||||||||||
download_artifact, | ||||||||||
upload_artifact, | ||||||||||
) | ||||||||||
from dflow.python import ( | ||||||||||
OP, | ||||||||||
OPIO, | ||||||||||
Artifact, | ||||||||||
BigParameter, | ||||||||||
OPIOSign, | ||||||||||
Parameter, | ||||||||||
Slices, | ||||||||||
TransientError, | ||||||||||
) | ||||||||||
from dflow.utils import ( | ||||||||||
flatten, | ||||||||||
) | ||||||||||
|
||||||||||
from dpgen2.constants import ( | ||||||||||
calypso_check_opt_file, | ||||||||||
calypso_run_opt_file, | ||||||||||
) | ||||||||||
from dpgen2.exploration.task import ( | ||||||||||
ExplorationTaskGroup, | ||||||||||
) | ||||||||||
from dpgen2.superop.caly_evo_step import ( | ||||||||||
CalyEvoStep, | ||||||||||
) | ||||||||||
from dpgen2.utils import ( | ||||||||||
BinaryFileInput, | ||||||||||
set_directory, | ||||||||||
) | ||||||||||
from dpgen2.utils.run_command import ( | ||||||||||
run_command, | ||||||||||
) | ||||||||||
|
||||||||||
|
||||||||||
class CalyEvoStepMerge(OP): | ||||||||||
def __init__(self, mode="debug", *args, **kwargs): | ||||||||||
self.mode = mode | ||||||||||
self.args = args | ||||||||||
self.kwargs = kwargs | ||||||||||
|
||||||||||
@classmethod | ||||||||||
def get_input_sign(cls): | ||||||||||
return OPIOSign( | ||||||||||
{ | ||||||||||
"iter_num": int, | ||||||||||
"cnt_num": Parameter(int, default=0), | ||||||||||
"block_id": Parameter(str, default=""), | ||||||||||
"task_name": BigParameter(str), | ||||||||||
"expl_config": BigParameter(dict), | ||||||||||
"models": Artifact(Path), | ||||||||||
"input_file": Artifact(Path), | ||||||||||
"caly_run_opt_file": Artifact(Path), | ||||||||||
"caly_check_opt_file": Artifact(Path), | ||||||||||
"results": Artifact(Path, optional=True), | ||||||||||
"step": Artifact(Path, optional=True), | ||||||||||
"opt_results_dir": Artifact(List[Path], optional=True), | ||||||||||
"qhull_input": Artifact(Path, optional=True), | ||||||||||
} | ||||||||||
) | ||||||||||
|
||||||||||
@classmethod | ||||||||||
def get_output_sign(cls): | ||||||||||
return OPIOSign( | ||||||||||
{ | ||||||||||
"traj_results": Artifact(List[Path]), | ||||||||||
} | ||||||||||
) | ||||||||||
|
||||||||||
@OP.exec_sign_check | ||||||||||
def execute( | ||||||||||
self, | ||||||||||
ip: OPIO, | ||||||||||
) -> OPIO: | ||||||||||
from dflow import ( | ||||||||||
config, | ||||||||||
) | ||||||||||
|
||||||||||
config["mode"] = self.mode | ||||||||||
wf = Workflow("caly-evo-workflow") | ||||||||||
steps = CalyEvoStep(*self.args, **self.kwargs) | ||||||||||
step = Step( | ||||||||||
"caly-evo-step", | ||||||||||
template=steps, | ||||||||||
slices=Slices(output_artifact=["traj_results"]), | ||||||||||
parameters={k: ip[k] for k in steps.inputs.parameters}, | ||||||||||
artifacts={ | ||||||||||
k: upload_artifact(ip[k]) if ip[k] is not None else None | ||||||||||
for k in steps.inputs.artifacts | ||||||||||
}, | ||||||||||
with_param=[0], | ||||||||||
) | ||||||||||
wf.add(step) | ||||||||||
wf.submit() | ||||||||||
wf.wait() | ||||||||||
assert wf.query_status() == "Succeeded" | ||||||||||
out = OPIO() | ||||||||||
step = wf.query_step("caly-evo-step")[0] | ||||||||||
for k in step.outputs.parameters: | ||||||||||
out[k] = step.outputs.parameters[k].value | ||||||||||
output_sign = self.get_output_sign() | ||||||||||
for k in step.outputs.artifacts: | ||||||||||
path_list = download_artifact(step.outputs.artifacts[k]) | ||||||||||
if output_sign[k].type == List[Path]: | ||||||||||
if not isinstance(path_list, list) or any( | ||||||||||
[p is not None and not isinstance(p, str) for p in path_list] | ||||||||||
): | ||||||||||
path_list = list(flatten(path_list).values()) | ||||||||||
out[k] = [Path(p) for p in path_list] | ||||||||||
elif output_sign[k].type == Path: | ||||||||||
assert len(path_list) == 1 | ||||||||||
out[k] = Path(path_list[0]) | ||||||||||
return out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused imports to clean up the code.
Also applies to: 2-2, 3-3, 4-4, 10-10, 27-27, 34-34, 35-35, 38-38, 44-44, 45-45, 48-48
Committable suggestion