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

ban print #3415

Merged
merged 2 commits into from
Mar 5, 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 data/raw/copy_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _main():
)
args = parser.parse_args()

print("# copy the system by %s copies" % args.ncopies)
print("# copy the system by %s copies" % args.ncopies) # noqa: T201
assert np.all(
np.array(args.ncopies, dtype=int) >= np.array([1, 1, 1], dtype=int)
), "number of copies should be larger than or equal to 1"
Expand Down
8 changes: 4 additions & 4 deletions data/raw/shuffle_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _main():
outpath = args.OUTPUT

if not os.path.isdir(inpath):
print("# no input dir " + inpath + ", exit")
print("# no input dir " + inpath + ", exit") # noqa: T201
return

if not os.path.isdir(outpath):
Expand All @@ -47,16 +47,16 @@ def _main():
raws = detect_raw(inpath)

if len(raws) == 0:
print("# no file to shuffle, exit")
print("# no file to shuffle, exit") # noqa: T201
return

assert "box.raw" in raws
tmp = np.loadtxt(os.path.join(inpath, "box.raw"))
tmp = np.reshape(tmp, [-1, 9])
nframe = tmp.shape[0]
print(nframe)
print(nframe) # noqa: T201

print(
print( # noqa: T201
"# will shuffle raw files "
+ str(raws)
+ " in dir "
Expand Down
2 changes: 1 addition & 1 deletion deepmd/entrypoints/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
doc_str = gen_json()
else:
raise RuntimeError("Unsupported out type %s" % out_type)
print(doc_str)
print(doc_str) # noqa: T201

Check warning on line 20 in deepmd/entrypoints/doc.py

View check run for this annotation

Codecov / codecov/patch

deepmd/entrypoints/doc.py#L20

Added line #L20 was not covered by tests
10 changes: 5 additions & 5 deletions doc/sphinx_contrib_exhale_multiproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ def exhale_environment_ready(app):
app.config.exhale_args["containmentFolder"] = os.path.realpath(
app.config.exhale_args["containmentFolder"]
)
print("=" * 75)
print(project)
print("-" * 50)
pprint(app.config.exhale_args)
print("=" * 75)
print("=" * 75) # noqa: T201
print(project) # noqa: T201
print("-" * 50) # noqa: T201
pprint(app.config.exhale_args) # noqa: T203
print("=" * 75) # noqa: T201

# First, setup the extension and verify all of the configurations.
exhale.configs.apply_sphinx_configurations(app)
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ select = [
"NPY", # numpy
"TID251", # banned-api
"TID253", # banned-module-level-imports
"T20", # ban print
]

ignore = [
Expand Down Expand Up @@ -283,6 +284,7 @@ banned-module-level-imports = [
"source/tests/pt/**" = ["TID253"]
"source/ipi/tests/**" = ["TID253"]
"source/lmp/tests/**" = ["TID253"]
"**/*.ipynb" = ["T20"] # printing in a nb file is expected

[tool.pytest.ini_options]
markers = "run"
Expand Down
2 changes: 0 additions & 2 deletions source/tests/pt/model/test_unused_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ def get_contributing_params(y, top_level=True):
contributing_parameters = set(get_contributing_params(ret0["energy"]))
all_parameters = set(self.model.parameters())
non_contributing = all_parameters - contributing_parameters
for ii in non_contributing:
print(ii.shape)
self.assertEqual(len(non_contributing), 0)


Expand Down
3 changes: 1 addition & 2 deletions source/tests/pt/test_dp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ def test_dp_test(self):
try:
res = tester.run()
except StopIteration:
print("Unexpected stop iteration.(test step < total batch)")
raise StopIteration
raise StopIteration("Unexpected stop iteration.(test step < total batch)")
for k, v in res.items():
if k == "rmse" or "mae" in k or k not in more_loss:
continue
Expand Down
3 changes: 2 additions & 1 deletion source/tests/tf/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import pathlib
import shutil
import warnings

import dpdata
import numpy as np
Expand Down Expand Up @@ -969,7 +970,7 @@ def __init__(self, systems, set_prefix, batch_size, test_size, rcut, run_opt=Non
)
chk_ret = self.data_systems[ii].check_test_size(test_size)
if chk_ret is not None:
print(
warnings.warn(
"WARNNING: system %s required test size %d is larger than the size %d of the dataset %s"
% (self.system_dirs[ii], test_size, chk_ret[1], chk_ret[0])
)
Expand Down
12 changes: 0 additions & 12 deletions source/tests/tf/test_adjust_sel.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import os
import subprocess as sp
import unittest

import numpy as np
Expand Down Expand Up @@ -33,17 +32,6 @@ def _file_delete(file):
os.remove(file)


def _subprocess_run(command):
popen = sp.Popen(command.split(), shell=False, stdout=sp.PIPE, stderr=sp.STDOUT)
for line in iter(popen.stdout.readline, b""):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
return popen.returncode


def _init_models():
# we use the setting for model compression
data_file = str(tests_path / os.path.join("model_compression", "data"))
Expand Down
12 changes: 0 additions & 12 deletions source/tests/tf/test_finetune_se_atten.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import os
import subprocess as sp
import unittest

import numpy as np
Expand Down Expand Up @@ -46,17 +45,6 @@ def _file_delete(file):
os.remove(file)


def _subprocess_run(command):
popen = sp.Popen(command.split(), shell=False, stdout=sp.PIPE, stderr=sp.STDOUT)
for line in iter(popen.stdout.readline, b""):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
return popen.returncode


def _init_models(setup_model, i):
data_file = str(tests_path / os.path.join("finetune", "data"))
data_file_mixed_type = str(tests_path / os.path.join("finetune", "data_mixed_type"))
Expand Down
12 changes: 0 additions & 12 deletions source/tests/tf/test_mixed_prec_training.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import os
import subprocess as sp
import unittest

import numpy as np
Expand All @@ -28,17 +27,6 @@ def _file_delete(file):
os.remove(file)


def _subprocess_run(command):
popen = sp.Popen(command.split(), shell=False, stdout=sp.PIPE, stderr=sp.STDOUT)
for line in iter(popen.stdout.readline, b""):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
return popen.returncode


class TestMixedPrecTraining(unittest.TestCase):
def setUp(self):
data_file = str(tests_path / os.path.join("model_compression", "data"))
Expand Down
12 changes: 0 additions & 12 deletions source/tests/tf/test_model_compression_se_a.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import os
import subprocess as sp
import unittest

import numpy as np
Expand Down Expand Up @@ -33,17 +32,6 @@ def _file_delete(file):
os.remove(file)


def _subprocess_run(command):
popen = sp.Popen(command.split(), shell=False, stdout=sp.PIPE, stderr=sp.STDOUT)
for line in iter(popen.stdout.readline, b""):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
return popen.returncode


def _init_models():
data_file = str(tests_path / os.path.join("model_compression", "data"))
frozen_model = str(tests_path / "dp-original.pb")
Expand Down
12 changes: 0 additions & 12 deletions source/tests/tf/test_model_compression_se_a_ebd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import os
import subprocess as sp
import unittest

import numpy as np
Expand Down Expand Up @@ -33,17 +32,6 @@ def _file_delete(file):
os.remove(file)


def _subprocess_run(command):
popen = sp.Popen(command.split(), shell=False, stdout=sp.PIPE, stderr=sp.STDOUT)
for line in iter(popen.stdout.readline, b""):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
return popen.returncode


def _init_models():
data_file = str(tests_path / os.path.join("model_compression", "data"))
frozen_model = str(tests_path / "dp-original-se-e2-a-v2.pb")
Expand Down
12 changes: 0 additions & 12 deletions source/tests/tf/test_model_compression_se_a_ebd_type_one_side.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import os
import subprocess as sp
import unittest

import numpy as np
Expand Down Expand Up @@ -33,17 +32,6 @@ def _file_delete(file):
os.remove(file)


def _subprocess_run(command):
popen = sp.Popen(command.split(), shell=False, stdout=sp.PIPE, stderr=sp.STDOUT)
for line in iter(popen.stdout.readline, b""):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
return popen.returncode


def _init_models():
data_file = str(tests_path / os.path.join("model_compression", "data"))
frozen_model = str(tests_path / "dp-original-se-e2-a-v2-one-side.pb")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import os
import subprocess as sp
import unittest

import numpy as np
Expand Down Expand Up @@ -33,17 +32,6 @@ def _file_delete(file):
os.remove(file)


def _subprocess_run(command):
popen = sp.Popen(command.split(), shell=False, stdout=sp.PIPE, stderr=sp.STDOUT)
for line in iter(popen.stdout.readline, b""):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
return popen.returncode


def _init_models():
data_file = str(tests_path / os.path.join("model_compression", "data"))
frozen_model = str(tests_path / "dp-original-type-one-side-exclude-types.pb")
Expand Down
12 changes: 0 additions & 12 deletions source/tests/tf/test_model_compression_se_atten.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import os
import subprocess as sp
import unittest

import numpy as np
Expand Down Expand Up @@ -29,17 +28,6 @@ def _file_delete(file):
os.remove(file)


def _subprocess_run(command):
popen = sp.Popen(command.split(), shell=False, stdout=sp.PIPE, stderr=sp.STDOUT)
for line in iter(popen.stdout.readline, b""):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
return popen.returncode


# 4 tests:
# - type embedding FP64, se_atten FP64
# - type embedding FP64, se_atten FP32
Expand Down
12 changes: 0 additions & 12 deletions source/tests/tf/test_model_compression_se_r.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import os
import subprocess as sp
import unittest

import numpy as np
Expand Down Expand Up @@ -33,17 +32,6 @@ def _file_delete(file):
os.remove(file)


def _subprocess_run(command):
popen = sp.Popen(command.split(), shell=False, stdout=sp.PIPE, stderr=sp.STDOUT)
for line in iter(popen.stdout.readline, b""):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
return popen.returncode


def _init_models():
data_file = str(tests_path / os.path.join("model_compression", "data"))
frozen_model = str(tests_path / "dp-original-se-r.pb")
Expand Down
12 changes: 0 additions & 12 deletions source/tests/tf/test_model_compression_se_t.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import json
import os
import subprocess as sp
import unittest

import numpy as np
Expand Down Expand Up @@ -33,17 +32,6 @@ def _file_delete(file):
os.remove(file)


def _subprocess_run(command):
popen = sp.Popen(command.split(), shell=False, stdout=sp.PIPE, stderr=sp.STDOUT)
for line in iter(popen.stdout.readline, b""):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
return popen.returncode


def _init_models():
data_file = str(tests_path / os.path.join("model_compression", "data"))
frozen_model = str(tests_path / "dp-original-se-t.pb")
Expand Down
1 change: 0 additions & 1 deletion source/tests/tf/test_parallel_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def test_two_workers(self):
if hasattr(line, "decode"):
line = line.decode("utf-8")
line = line.rstrip()
print(line)
popen.wait()
self.assertEqual(0, popen.returncode, "Parallel training failed!")

Expand Down
Loading