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

fix: prevent deepmd.tf be imported globally #3382

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion deepmd/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import numpy as np

from deepmd.tf.common import (
from deepmd.common import (

Check warning on line 19 in deepmd/utils/compat.py

View check run for this annotation

Codecov / codecov/patch

deepmd/utils/compat.py#L19

Added line #L19 was not covered by tests
j_must_have,
)

Expand Down
4 changes: 1 addition & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
date,
)

from deepmd.tf.common import (
from deepmd.utils.argcheck import (
ACTIVATION_FN_DICT,
PRECISION_DICT,
)
from deepmd.tf.utils.argcheck import (
list_to_doc,
)

Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ select = [
"C4", # flake8-comprehensions
"RUF", # ruff
"NPY", # numpy
"TID253", # banned-module-level-imports
]

ignore = [
Expand All @@ -256,9 +257,30 @@ ignore = [
]
ignore-init-module-imports = true

exclude = [
"source/3rdparty/**",
]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

[tool.ruff.lint.flake8-tidy-imports]
banned-module-level-imports = [
"deepmd.tf",
"deepmd.pt",
"tensorflow",
"torch",
]

[tool.ruff.lint.extend-per-file-ignores]
# Also ignore `E402` in all `__init__.py` files.
"deepmd/tf/**" = ["TID253"]
"deepmd/pt/**" = ["TID253"]
"source/tests/tf/**" = ["TID253"]
"source/tests/pt/**" = ["TID253"]
"source/ipi/tests/**" = ["TID253"]
"source/lmp/tests/**" = ["TID253"]

[tool.pytest.ini_options]
markers = "run"

Expand Down
27 changes: 0 additions & 27 deletions source/tests/common/test_uni_infer.py

This file was deleted.