From dda5d18447e44a86e0d93c0749df49aea2fef1e9 Mon Sep 17 00:00:00 2001 From: Prakhar Bhatnagar <42675093+prakharb10@users.noreply.github.com> Date: Tue, 4 Oct 2022 20:06:15 +0530 Subject: [PATCH 1/4] fixed stray reno --- .../notes/0.11/prepare-0.11-af688e532712c830.yaml | 11 +++++++++++ .../notes/d-1-heavy-hex-e2e44861dc75009a.yaml | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 tests/rustworkx_tests/generators/releasenotes/notes/d-1-heavy-hex-e2e44861dc75009a.yaml diff --git a/releasenotes/notes/0.11/prepare-0.11-af688e532712c830.yaml b/releasenotes/notes/0.11/prepare-0.11-af688e532712c830.yaml index 57bb0acada..3d07b3068a 100644 --- a/releasenotes/notes/0.11/prepare-0.11-af688e532712c830.yaml +++ b/releasenotes/notes/0.11/prepare-0.11-af688e532712c830.yaml @@ -67,3 +67,14 @@ features: [{'color': 'turquoise', 'size': 'extra large', '__networkx_node__': 'A'}, {'color': 'fuschia', 'size': 'tiny', '__networkx_node__': 'B'}] WeightedEdgeList[(0, 1, {})] + +fixes: + - | + Fixed an issue with the :func:`~retworkx.generators.heavy_hex_graph`, + :func:`~retworkx.generators.directed_heavy_hex_graph`, + :func:`~retworkx.generators.heavy_square_graph`, + and :func:`~retworkx.generators.directed_heavy_square_graph` generator + functions. When the input parameter ``d`` was set to 1 these functions + would previously raise a ``pyo3_runtime.PanicException`` instead of + returning the expected graph (a single node). + Fixed `#452 `__ diff --git a/tests/rustworkx_tests/generators/releasenotes/notes/d-1-heavy-hex-e2e44861dc75009a.yaml b/tests/rustworkx_tests/generators/releasenotes/notes/d-1-heavy-hex-e2e44861dc75009a.yaml deleted file mode 100644 index 6b89e75936..0000000000 --- a/tests/rustworkx_tests/generators/releasenotes/notes/d-1-heavy-hex-e2e44861dc75009a.yaml +++ /dev/null @@ -1,11 +0,0 @@ ---- -fixes: - - | - Fixed an issue with the :func:`~retworkx.generators.heavy_hex_graph`, - :func:`~retworkx.generators.directed_heavy_hex_graph`, - :func:`~retworkx.generators.heavy_square_graph`, - and :func:`~retworkx.generators.directed_heavy_square_graph` generator - functions. When the input parameter ``d`` was set to 1 these functions - would previously raise a ``pyo3_runtime.PanicException`` instead of - returning the expected graph (a single node). - Fixed `#452 `__ From d832469ad061e1600eed9d2054cd7f6a8e843d08 Mon Sep 17 00:00:00 2001 From: Prakhar Bhatnagar <42675093+prakharb10@users.noreply.github.com> Date: Tue, 4 Oct 2022 20:07:32 +0530 Subject: [PATCH 2/4] added script to block stray renos --- .github/workflows/main.yml | 2 ++ tools/find_stray_release_notes.py | 58 +++++++++++++++++++++++++++++++ tox.ini | 1 + 3 files changed, 61 insertions(+) create mode 100644 tools/find_stray_release_notes.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b73ede618e..ffd146a1a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,6 +40,8 @@ jobs: run: black --check --diff retworkx rustworkx retworkx tests - name: Python Lint run: flake8 --per-file-ignores='retworkx/__init__.py:F405,F403' setup.py retworkx tests rustworkx + - name: Check stray release notes + run: python3 tools/find_stray_release_notes.py - name: rustworkx-core Rust Tests run: pushd rustworkx-core && cargo test && popd - name: rustworkx-core Docs diff --git a/tools/find_stray_release_notes.py b/tools/find_stray_release_notes.py new file mode 100644 index 0000000000..37ec7e8921 --- /dev/null +++ b/tools/find_stray_release_notes.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +# This code is part of Qiskit. +# +# (C) Copyright IBM 2022 +# +# This code is licensed under the Apache License, Version 2.0. You may +# obtain a copy of this license in the LICENSE.txt file in the root directory +# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. +# +# Any modifications or derivative works of this code must retain this +# copyright notice, and modified files need to carry a notice indicating +# that they have been altered from the originals. + +"""Utility script to find any stray release notes.""" + +import argparse +import multiprocessing +import subprocess +import sys +import re + +# release notes regex +reno = re.compile(r"releasenotes\/notes") +# exact release note regex +exact_reno = re.compile(r"^releasenotes\/notes") + + +def discover_files(): + """Find all .py, .pyx, .pxd files in a list of trees""" + cmd = ["git", "ls-tree", "-r", "--name-only", "HEAD"] + res = subprocess.run(cmd, capture_output=True, check=True, encoding="UTF8") + files = res.stdout.split("\n") + return files + + +def validate_path(file_path): + """Validate a path in the git tree.""" + if reno.search(file_path) and not exact_reno.search(file_path): + return file_path + return None + + +def _main(): + parser = argparse.ArgumentParser(description="Find any stray release notes.") + _args = parser.parse_args() + files = discover_files() + with multiprocessing.Pool() as pool: + res = pool.map(validate_path, files) + failed_files = [x for x in res if x is not None] + if len(failed_files) > 0: + for failed_file in failed_files: + sys.stderr.write("%s is not in the correct location.\n" % failed_file) + sys.exit(1) + sys.exit(0) + + +if __name__ == "__main__": + _main() diff --git a/tox.ini b/tox.ini index 3d2c51ecd8..fcde8971df 100644 --- a/tox.ini +++ b/tox.ini @@ -53,6 +53,7 @@ commands = black --check --diff {posargs} '../rustworkx' '../tests' '../retworkx' flake8 --per-file-ignores='../rustworkx/__init__.py:F405,F403' ../setup.py ../rustworkx ../retworkx . cargo fmt --all -- --check + python3 {toxinidir}/tools/find_stray_release_notes.py [testenv:docs] basepython = python3 From 7d9621ac7ed6565847f7cbed55d1cedd2e1d7d05 Mon Sep 17 00:00:00 2001 From: Prakhar Bhatnagar <42675093+prakharb10@users.noreply.github.com> Date: Tue, 4 Oct 2022 20:12:18 +0530 Subject: [PATCH 3/4] header updated --- tools/find_stray_release_notes.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tools/find_stray_release_notes.py b/tools/find_stray_release_notes.py index 37ec7e8921..08000c399a 100644 --- a/tools/find_stray_release_notes.py +++ b/tools/find_stray_release_notes.py @@ -1,8 +1,3 @@ -#!/usr/bin/env python3 -# This code is part of Qiskit. -# -# (C) Copyright IBM 2022 -# # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. From 56c80583b600a524133c5a0413edd04373539fea Mon Sep 17 00:00:00 2001 From: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com> Date: Tue, 4 Oct 2022 11:14:55 -0700 Subject: [PATCH 4/4] Apply suggestions from code review --- .github/workflows/main.yml | 2 +- tox.ini | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ffd146a1a8..91b66d928d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,7 +41,7 @@ jobs: - name: Python Lint run: flake8 --per-file-ignores='retworkx/__init__.py:F405,F403' setup.py retworkx tests rustworkx - name: Check stray release notes - run: python3 tools/find_stray_release_notes.py + run: python tools/find_stray_release_notes.py - name: rustworkx-core Rust Tests run: pushd rustworkx-core && cargo test && popd - name: rustworkx-core Docs diff --git a/tox.ini b/tox.ini index fcde8971df..097473a009 100644 --- a/tox.ini +++ b/tox.ini @@ -53,7 +53,7 @@ commands = black --check --diff {posargs} '../rustworkx' '../tests' '../retworkx' flake8 --per-file-ignores='../rustworkx/__init__.py:F405,F403' ../setup.py ../rustworkx ../retworkx . cargo fmt --all -- --check - python3 {toxinidir}/tools/find_stray_release_notes.py + python {toxinidir}/tools/find_stray_release_notes.py [testenv:docs] basepython = python3