Skip to content

Commit

Permalink
add isort to sort imports (#126)
Browse files Browse the repository at this point in the history
This is an automatic tool to format and sort imports. See
https://github.com/PyCQA/isort for details.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Han Wang <92130845+wanghan-iapcm@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 4, 2023
1 parent 4d517c5 commit b35becb
Show file tree
Hide file tree
Showing 120 changed files with 2,142 additions and 1,067 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ repos:
rev: 22.12.0
hooks:
- id: black-jupyter
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
files: \.py$
9 changes: 6 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
#
import os
import sys
from datetime import date

from datetime import (
date,
)

# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -67,7 +68,9 @@


def run_apidoc(_):
from sphinx.ext.apidoc import main
from sphinx.ext.apidoc import (
main,
)

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
cur_dir = os.path.abspath(os.path.dirname(__file__))
Expand Down
4 changes: 3 additions & 1 deletion dpgen2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
try:
from ._version import version as __version__
except ImportError:
from .__about__ import __version__
from .__about__ import (
__version__,
)
4 changes: 3 additions & 1 deletion dpgen2/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from .entrypoint.main import main
from .entrypoint.main import (
main,
)

if __name__ == "__main__":
main()
6 changes: 3 additions & 3 deletions dpgen2/conf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .conf_generator import (
ConfGenerator,
)
from .alloy_conf import (
AlloyConfGenerator,
)
from .conf_generator import (
ConfGenerator,
)
from .file_conf import (
FileConfGenerator,
)
Expand Down
23 changes: 18 additions & 5 deletions dpgen2/conf/alloy_conf.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
import random
import dpdata
import tempfile
from pathlib import (
Path,
)
from typing import (
List,
Optional,
Tuple,
Union,
)

import dpdata
import numpy as np
from pathlib import Path
from typing import Optional, Union, List, Tuple
from dargs import (
Argument,
Variant,
)
from .unit_cells import generate_unit_cell
from .conf_generator import ConfGenerator

from .conf_generator import (
ConfGenerator,
)
from .unit_cells import (
generate_unit_cell,
)


class AlloyConfGenerator(ConfGenerator):
Expand Down
17 changes: 10 additions & 7 deletions dpgen2/conf/conf_generator.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import dpdata
import dargs
import tempfile
from pathlib import Path
from typing import (
List,
Dict,
)
from abc import (
ABC,
abstractmethod,
)
from pathlib import (
Path,
)
from typing import (
Dict,
List,
)

import dargs
import dpdata


class ConfGenerator(ABC):
Expand Down
19 changes: 15 additions & 4 deletions dpgen2/conf/file_conf.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import glob
import os
from pathlib import (
Path,
)
from typing import (
List,
Optional,
Tuple,
Union,
)

import dpdata
import glob
from pathlib import Path
from .conf_generator import ConfGenerator
from typing import Optional, Union, List, Tuple
from dargs import (
Argument,
Variant,
)

from .conf_generator import (
ConfGenerator,
)


class FileConfGenerator(ConfGenerator):
def __init__(
Expand Down
7 changes: 5 additions & 2 deletions dpgen2/conf/unit_cells.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import tempfile
from pathlib import (
Path,
)

import dpdata
import numpy as np
from pathlib import Path
import tempfile


def generate_unit_cell(
Expand Down
31 changes: 23 additions & 8 deletions dpgen2/entrypoint/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@
Argument,
Variant,
)
from dflow.plugins.lebesgue import (
LebesgueExecutor,
)

import dpgen2
from dpgen2.constants import default_image
from dflow.plugins.lebesgue import LebesgueExecutor
from dpgen2.op.run_dp_train import RunDPTrain
from dpgen2.op.run_lmp import RunLmp
from dpgen2.conf import (
conf_styles,
)
from dpgen2.constants import (
default_image,
)
from dpgen2.exploration.report import (
conv_styles,
)
from dpgen2.fp import (
fp_styles,
)
from dpgen2.op.run_dp_train import (
RunDPTrain,
)
from dpgen2.op.run_lmp import (
RunLmp,
)
from dpgen2.utils import (
step_conf_args,
normalize_step_dict,
step_conf_args,
)
from dpgen2.fp import fp_styles
from dpgen2.conf import conf_styles
from dpgen2.exploration.report import conv_styles


def dp_dist_train_args():
Expand Down
30 changes: 18 additions & 12 deletions dpgen2/entrypoint/common.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
import dflow
from pathlib import Path
import os
from pathlib import (
Path,
)
from typing import (
Dict,
List,
Optional,
Union,
)

import dflow

from dpgen2.utils import (
bohrium_config_from_dict,
dump_object_to_file,
load_object_from_file,
sort_slice_ops,
matched_step_key,
print_keys_in_nice_format,
sort_slice_ops,
workflow_config_from_dict,
matched_step_key,
bohrium_config_from_dict,
)
from dpgen2.utils.step_config import normalize as normalize_step_dict
from typing import (
Union,
List,
Dict,
Optional,
)


def global_config_workflow(
Expand All @@ -33,7 +37,9 @@ def global_config_workflow(
# lebesgue context
lebesgue_context = None
if do_lebesgue:
from dflow.plugins.lebesgue import LebesgueContext
from dflow.plugins.lebesgue import (
LebesgueContext,
)

lb_context_config = wf_config.get("lebesgue_context_config", None)
if lb_context_config:
Expand Down
24 changes: 12 additions & 12 deletions dpgen2/entrypoint/download.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import logging
from typing import (
Dict,
List,
Optional,
Union,
)

from dflow import (
Workflow,
)

from dpgen2.entrypoint.args import normalize as normalize_args
from dpgen2.entrypoint.common import (
global_config_workflow,
)
from dpgen2.utils.dflow_query import (
matched_step_key,
)
from dpgen2.utils.download_dpgen2_artifacts import (
download_dpgen2_artifacts,
)
from typing import (
Optional,
Dict,
Union,
List,
)
from dpgen2.entrypoint.common import (
global_config_workflow,
)
from dpgen2.entrypoint.args import (
normalize as normalize_args,
)


def download(
Expand Down
47 changes: 27 additions & 20 deletions dpgen2/entrypoint/main.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
import argparse, os, json, logging
import argparse
import json
import logging
import os
from typing import (
List,
Optional,
)

from dflow import (
Workflow,
Step,
Steps,
upload_artifact,
Workflow,
download_artifact,
upload_artifact,
)
from typing import (
Optional,
List,
)
from .submit import (
make_concurrent_learning_op,
make_naive_exploration_scheduler,
workflow_concurrent_learning,
submit_concurrent_learning,
resubmit_concurrent_learning,

from dpgen2 import (
__version__,
)
from .status import (
status,

from .download import (
download,
)
from .showkey import (
showkey,
)
from .download import (
download,
from .status import (
status,
)
from .submit import (
make_concurrent_learning_op,
make_naive_exploration_scheduler,
resubmit_concurrent_learning,
submit_concurrent_learning,
workflow_concurrent_learning,
)
from .watch import (
watch,
default_watching_keys,
watch,
)
from .workflow import (
workflow_subcommands,
add_subparser_workflow_subcommand,
execute_workflow_subcommand,
workflow_subcommands,
)
from dpgen2 import __version__


def main_parser() -> argparse.ArgumentParser:
Expand Down
23 changes: 15 additions & 8 deletions dpgen2/entrypoint/showkey.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import glob, dpdata, os, pickle
from pathlib import Path
import glob
import os
import pickle
from pathlib import (
Path,
)

import dpdata
from dflow import (
Workflow,
)
from dpgen2.entrypoint.submit import get_resubmit_keys
from dpgen2.utils import (
print_keys_in_nice_format,
)

from dpgen2.entrypoint.args import normalize as normalize_args
from dpgen2.entrypoint.common import (
global_config_workflow,
)
from dpgen2.entrypoint.args import (
normalize as normalize_args,
from dpgen2.entrypoint.submit import (
get_resubmit_keys,
)
from dpgen2.utils import (
print_keys_in_nice_format,
)


Expand Down

0 comments on commit b35becb

Please sign in to comment.