From 1891f8f4b91670330de0d0687cfce0b394fb5a11 Mon Sep 17 00:00:00 2001 From: "Micah D. Gale" Date: Fri, 5 Jan 2024 10:22:47 -0600 Subject: [PATCH 1/5] Replicated the error in #163. --- tests/test_edge_cases.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_edge_cases.py b/tests/test_edge_cases.py index ba4c6609..9285e4e7 100644 --- a/tests/test_edge_cases.py +++ b/tests/test_edge_cases.py @@ -160,3 +160,19 @@ def test_void_cell_set_material(self): print(output) parts = output[0].split() self.assertAlmostEqual(float(parts[2]), -dens_value, places=9) + + def test_geometry_comments(self): + in_strs = """21073 130 0.010000 (-11516 97 -401 ) $ C 1 Lower water + :(-11526 97 -401 ) $ C 2 Lower water + :(-11536 97 -401 ) $ C 3 Lower water + :(-11546 97 -401 ) $ C 4 Lower water + :(-11556 97 -401 ) $ C 5 Lower water + :(-11576 97 -401 ) imp:n=1 $ C 7 Lower water""".split( + "\n" + ) + input = montepy.input_parser.mcnp_input.Input( + in_strs, montepy.input_parser.block_type.BlockType.CELL + ) + cell = montepy.Cell(input) + # this step caused an error for #163 + cell.comments From d0f5f9d7e05d0a7b1233f70efd4307dde331c7ee Mon Sep 17 00:00:00 2001 From: "Micah D. Gale" Date: Fri, 5 Jan 2024 15:46:54 -0600 Subject: [PATCH 2/5] Defined recursive GeometryTree Comments function for nested dicts. --- montepy/__init__.py | 2 +- montepy/input_parser/syntax_node.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/montepy/__init__.py b/montepy/__init__.py index e8efe667..22a95eaa 100644 --- a/montepy/__init__.py +++ b/montepy/__init__.py @@ -23,7 +23,7 @@ from montepy.universe import Universe import sys -__version__ = "0.2.4dev1" +__version__ = "0.2.4dev2" # enable deprecated warnings for users if not sys.warnoptions: import os, warnings diff --git a/montepy/input_parser/syntax_node.py b/montepy/input_parser/syntax_node.py index ff301500..a7e83cc4 100644 --- a/montepy/input_parser/syntax_node.py +++ b/montepy/input_parser/syntax_node.py @@ -223,6 +223,7 @@ class GeometryTree(SyntaxNodeBase): def __init__(self, name, tokens, op, left, right=None): super().__init__(name) self._nodes = tokens + print(tokens) self._operator = Operator(op) self._left_side = left self._right_side = right @@ -241,8 +242,19 @@ def format(self): @property def comments(self): - for node in self.nodes.values(): - yield from node.comments + for key, node in self.nodes.items(): + if isinstance(node, SyntaxNodeBase): + yield from node.comments + elif isinstance(node, dict): + yield from GeometryTree._recurse_comments(node) + + @staticmethod + def _recurse_comments(tree): + for node in tree.values(): + if isinstance(node, SyntaxNodeBase): + yield from node.comments + elif isinstance(node, dict): + yield from GeometryTree._recurse_comments(node) @property def left(self): From dd2e914acd394a28c4e200b1c3f3e42eff76a1a4 Mon Sep 17 00:00:00 2001 From: "Micah D. Gale" Date: Mon, 8 Jan 2024 10:35:33 -0600 Subject: [PATCH 3/5] Deleted accidental debug statement. --- montepy/input_parser/syntax_node.py | 1 - 1 file changed, 1 deletion(-) diff --git a/montepy/input_parser/syntax_node.py b/montepy/input_parser/syntax_node.py index a7e83cc4..b6c1b6d1 100644 --- a/montepy/input_parser/syntax_node.py +++ b/montepy/input_parser/syntax_node.py @@ -223,7 +223,6 @@ class GeometryTree(SyntaxNodeBase): def __init__(self, name, tokens, op, left, right=None): super().__init__(name) self._nodes = tokens - print(tokens) self._operator = Operator(op) self._left_side = left self._right_side = right From c7b020a7256bf80a746e3ba7f64c2fc66359eff6 Mon Sep 17 00:00:00 2001 From: Micah Gale Date: Thu, 11 Jan 2024 07:40:09 -0600 Subject: [PATCH 4/5] Create Github Actions (#2) This just took ... so ... many tries. --- .github/workflows/deploy.yml | 107 +++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 91 +++++++++++++++++++++++++++++ montepy/errors.py | 3 +- 3 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..893a831a --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,107 @@ +name: Deploy + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + last-minute-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: set up python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - run: pip install --user -r requirements/dev.txt + - run: python -m pytest + + build-pages: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Configure git + env: + TOKEN: ${{ secrets.ACCESS_TOKEN }} + run: git config --global url."https://${TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/" + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: 3.8 + - run: pip install --user montepy[doc] + - run: cd doc && make html + - uses: actions/configure-pages@v4 + - uses: actions/upload-pages-artifact@v3 + with: + name: deploy-pages + path: doc/build/html/ + + deploy-pages: + permissions: + contents: read + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + needs: [build-pages, last-minute-test] + runs-on: ubuntu-latest + steps: + - run: ls -l + - uses: actions/download-artifact@v4 + with: + name: deploy-pages + - run: ls -l + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + with: + artifact_name: deploy-pages + + + deploy-test-pypi: + environment: + name: test-pypi + url: https://test.pypi.org/p/montepy # Replace with your PyPI project name + needs: [deploy-pages] + permissions: + contents: read + id-token: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: 3.8 + - run: python -m pip install build + - run: python -m build --sdist --wheel + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + deploy-pypi: + environment: + name: pypi + url: https://pypi.org/p/montepy # Replace with your PyPI project name + needs: [deploy-pages, deploy-test-pypi] + permissions: + contents: read + id-token: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: 3.8 + - run: python -m pip install build + - run: python -m build --sdist --wheel + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..d635a22b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,91 @@ +name: Test package + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: set up python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - run: pip install --upgrade pip build + - run: pip install -r requirements/common.txt + - run: python -m build --sdist --wheel + - run: pip install . + - run: pip uninstall -y montepy + - run: pip install --user dist/*.whl + - run: pip uninstall -y montepy + - run: pip install --user dist/*.tar.gz + - run: pip install --user montepy[test] + - run: pip install --user montepy[doc] + - run: pip freeze + - name: Upload build artifacts + uses: actions/upload-artifact@v3 + with: + name: build + path: dist/* + + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + + steps: + - uses: actions/checkout@v4 + - name: set up python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - run: pip install --user -r requirements/dev.txt + - run: coverage run -m pytest --junitxml=test_report.xml + - run: coverage report + - run: coverage xml + - name: Upload test report + uses: actions/upload-artifact@v3 + with: + name: test + path: test_report.xml + - name: Upload coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage + path: coverage.xml + + doc-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: set up python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - run: pip install montepy[doc] + - run: sphinx-build doc/source/ doc/build/ -W --keep-going -E + - run: sphinx-build -b html doc/source/ doc/build/html + - uses: actions/upload-artifact@v3 + with: + name: website + path: doc/build/html + + format-test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: set up python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - run: pip install --user -r requirements/dev.txt + - run: black --check montepy/ tests/ + + diff --git a/montepy/errors.py b/montepy/errors.py index a61b73b3..f0c2464d 100644 --- a/montepy/errors.py +++ b/montepy/errors.py @@ -10,8 +10,7 @@ def __init__(self, message): class MalformedInputError(ValueError): """ - <<<<<<< HEAD - Raised when there is an error with the MCNP input not related to the parser. + Raised when there is an error with the MCNP input not related to the parser. """ def __init__(self, input, message): From 790538ed21c6c488f8952f8d96b5c9d28a4a8859 Mon Sep 17 00:00:00 2001 From: "Micah D. Gale" Date: Thu, 11 Jan 2024 14:09:46 -0600 Subject: [PATCH 5/5] Reved version for release. --- montepy/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/montepy/__init__.py b/montepy/__init__.py index 5f35202d..39781239 100644 --- a/montepy/__init__.py +++ b/montepy/__init__.py @@ -23,7 +23,7 @@ from montepy.universe import Universe import sys -__version__ = "0.2.5dev1" +__version__ = "0.2.5" # enable deprecated warnings for users if not sys.warnoptions: import os, warnings