Skip to content

Commit

Permalink
correct the position of import dpgen2, try to skip isort when the rel…
Browse files Browse the repository at this point in the history
…ative order of import is critical
  • Loading branch information
Han Wang committed Sep 29, 2023
1 parent 66910be commit c0ee9a2
Show file tree
Hide file tree
Showing 26 changed files with 130 additions and 56 deletions.
2 changes: 2 additions & 0 deletions tests/conf/test_alloy_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
normalize,
)

# isort: on


ofc0 = "\n1 atoms\n2 atom types\n 0.0000000000 2.0000000000 xlo xhi\n 0.0000000000 2.0000000000 ylo yhi\n 0.0000000000 2.0000000000 zlo zhi\n 0.0000000000 0.0000000000 0.0000000000 xy xz yz\n\nAtoms # atomic\n\n 1 1 0.0000000000 0.0000000000 0.0000000000\n"
ofc1 = "\n1 atoms\n2 atom types\n 0.0000000000 3.0000000000 xlo xhi\n 0.0000000000 3.0000000000 ylo yhi\n 0.0000000000 3.0000000000 zlo zhi\n 0.0000000000 0.0000000000 0.0000000000 xy xz yz\n\nAtoms # atomic\n\n 1 2 0.0000000000 0.0000000000 0.0000000000\n"
Expand Down
8 changes: 5 additions & 3 deletions tests/conf/test_file_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
import dpdata
import numpy as np

# isort: off
from .context import (
dpgen2,
)
from dpgen2.conf.file_conf import (
FileConfGenerator,
)

from .context import (
dpgen2,
)
# isort: on

pos0 = textwrap.dedent(
"""POSCAR file written by OVITO
Expand Down
8 changes: 5 additions & 3 deletions tests/conf/test_unit_cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

import numpy as np

# isort: off
from .context import (
dpgen2,
)
from dpgen2.conf.unit_cells import (
generate_unit_cell,
)

from .context import (
dpgen2,
)
# isort: on


class TestGenerateUnitCell(unittest.TestCase):
Expand Down
6 changes: 6 additions & 0 deletions tests/entrypoint/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
import shutil
import unittest

# isort: off
from .context import (
dpgen2,
)
from dpgen2.entrypoint.main import (
main_parser,
parse_args,
workflow_subcommands,
)

# isort: off


class ParserTest(unittest.TestCase):
def setUp(self):
Expand Down
10 changes: 5 additions & 5 deletions tests/entrypoint/test_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import dpdata
import numpy as np

# isort: off
from .context import (
dpgen2,
)
from dpgen2.entrypoint.submit import (
copy_scheduler_plans,
expand_idx,
Expand All @@ -37,11 +41,6 @@
ExplorationStage,
ExplorationTaskGroup,
)

# isort: off
from .context import (
dpgen2,
)
from mocked_ops import (
MockedExplorationReport,
MockedExplorationTaskGroup,
Expand All @@ -52,6 +51,7 @@

# isort: on


ifc0 = """Al1
1.0
2.0 0.0 0.0
Expand Down
8 changes: 5 additions & 3 deletions tests/entrypoint/test_submit_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import dpdata
import numpy as np

# isort: off
from .context import (
dpgen2,
)
from dpgen2.entrypoint.args import (
normalize,
)
Expand All @@ -23,9 +27,7 @@
normalize_step_dict,
)

from .context import (
dpgen2,
)
# isort: on


class TestArgs(unittest.TestCase):
Expand Down
4 changes: 4 additions & 0 deletions tests/entrypoint/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
Workflow,
)

# isort: off
from .context import (
dpgen2,
)
from dpgen2.entrypoint.workflow import (
execute_workflow_subcommand,
)
Expand Down
8 changes: 5 additions & 3 deletions tests/exploration/test_conf_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
patch,
)

# isort: off
from .context import (
dpgen2,
)
from dpgen2.exploration.selector import (
ConfFilter,
ConfFilters,
)

from .context import (
dpgen2,
)
# isort: on


class FooFilter(ConfFilter):
Expand Down
7 changes: 5 additions & 2 deletions tests/exploration/test_conf_selector_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

import dpdata
import numpy as np
from context import (

# isort: off
from .context import (
dpgen2,
)

from dpgen2.exploration.render import (
TrajRenderLammps,
)
Expand All @@ -22,6 +23,8 @@
ConfSelectorFrames,
)

# isort: on


class TestConfSelectorFrames(unittest.TestCase):
def setUp(self):
Expand Down
7 changes: 5 additions & 2 deletions tests/exploration/test_devi_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
)

import numpy as np
from context import (

# isort: off
from .context import (
dpgen2,
)

from dpgen2.exploration.deviation import (
DeviManager,
DeviManagerStd,
)

# isort: on


class TestDeviManagerStd(unittest.TestCase):
def test_success(self):
Expand Down
9 changes: 6 additions & 3 deletions tests/exploration/test_report_adaptive_lower.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

import mock
import numpy as np
from context import (
dpgen2,
)
from dargs import (
Argument,
)

# isort: off
from .context import (
dpgen2,
)
from dpgen2.exploration.deviation import (
DeviManager,
DeviManagerStd,
Expand All @@ -22,6 +23,8 @@
ExplorationReportAdaptiveLower,
)

# isort: on


class TestTrajsExplorationReport(unittest.TestCase):
def test_fv(self):
Expand Down
9 changes: 6 additions & 3 deletions tests/exploration/test_report_trust_levels.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
)

import numpy as np
from context import (
dpgen2,
)
from dargs import (
Argument,
)

# isort: off
from context import (
dpgen2,
)
from dpgen2.exploration.deviation import (
DeviManager,
DeviManagerStd,
Expand All @@ -25,6 +26,8 @@
ExplorationReportTrustLevels,
)

# isort: on


class TestTrajsExplorationReport(unittest.TestCase):
def test_exploration_report_trust_levels(self):
Expand Down
8 changes: 5 additions & 3 deletions tests/fp/test_prep_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
fake_system,
)

# isort: off
from .context import (
dpgen2,
)
from dpgen2.constants import (
fp_task_pattern,
)
Expand All @@ -39,9 +43,7 @@
dump_object_to_file,
)

from .context import (
dpgen2,
)
# isort: on


class TestPrepVasp(unittest.TestCase):
Expand Down
8 changes: 5 additions & 3 deletions tests/fp/test_run_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
patch,
)

# isort: off
from .context import (
dpgen2,
)
from dpgen2.constants import (
fp_default_log_name,
fp_default_out_data_name,
Expand All @@ -33,9 +37,7 @@
vasp_pot_name,
)

from .context import (
dpgen2,
)
# isort: on


class TestRunVasp(unittest.TestCase):
Expand Down
8 changes: 5 additions & 3 deletions tests/fp/test_vasp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
import dpdata
import numpy as np

# isort: off
from .context import (
dpgen2,
)
from dpgen2.fp.vasp import (
VaspInputs,
make_kspacing_kpoints,
)

from .context import (
dpgen2,
)
# isort: on


class TestVASPInputs(unittest.TestCase):
Expand Down
7 changes: 5 additions & 2 deletions tests/op/test_collect_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
mock,
patch,
)
from op.context import (

# isort: off
from .context import (
dpgen2,
)

from dpgen2.constants import (
lmp_conf_name,
lmp_input_name,
Expand All @@ -38,6 +39,8 @@
CollectData,
)

# isort: on


class TestRunLmp(unittest.TestCase):
def setUp(self):
Expand Down
7 changes: 5 additions & 2 deletions tests/op/test_prep_dp_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
from mock import (
mock,
)
from op.context import (

# isort: off
from .context import (
dpgen2,
)

from dpgen2.constants import (
train_script_name,
train_task_pattern,
Expand All @@ -27,6 +28,8 @@
PrepDPTrain,
)

# isort: on

template_script_se_e2_a = {
"model": {"descriptor": {"type": "se_e2_a", "seed": 1}, "fitting_net": {"seed": 1}},
"training": {
Expand Down
7 changes: 5 additions & 2 deletions tests/op/test_run_dp_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
call,
patch,
)
from op.context import (

# isort: off
from .context import (
dpgen2,
)

from dpgen2.constants import (
train_script_name,
train_task_pattern,
Expand All @@ -36,6 +37,8 @@
_get_data_size_of_all_mult_sys,
)

# isort: on


class TestRunDPTrain(unittest.TestCase):
def setUp(self):
Expand Down
Loading

0 comments on commit c0ee9a2

Please sign in to comment.