Skip to content

Commit

Permalink
Merge pull request #507 from idaholab/mat_redesign
Browse files Browse the repository at this point in the history
Mat redesign
  • Loading branch information
MicahGale authored Dec 5, 2024
2 parents 16e4d39 + 3b9476e commit 2184765
Show file tree
Hide file tree
Showing 71 changed files with 5,961 additions and 1,854 deletions.
Empty file modified .github/scripts/check_sitemap.py
100644 → 100755
Empty file.
24 changes: 24 additions & 0 deletions .github/scripts/check_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python

import argparse
import re
import sys
from setuptools_scm import get_version

parser = argparse.ArgumentParser()
parser.add_argument("-a", "--alpha", action="store_true")
DEPLOY_VERSION = r"\d+\.\d+\.\d+"
ALPHA_VERSION = DEPLOY_VERSION + r"a\d+"
args = parser.parse_args()
if args.alpha:
print("checking alpha release")
parser = ALPHA_VERSION
else:
print("checking Final release.")
parser = DEPLOY_VERSION

version = get_version()
print(f"version = {version}")
if not re.fullmatch(parser, version):
exit(1)
exit(0)
6 changes: 0 additions & 6 deletions .github/scripts/check_version.sh

This file was deleted.

107 changes: 107 additions & 0 deletions .github/workflows/deploy-alpha.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Deploy

on:
push:
branches: [alpha-test]


jobs:
last-minute-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- run: pip install . montepy[develop]
- run: python -m pytest

build-packages:
name: Build, sign, and release packages on github
runs-on: ubuntu-latest
needs: [last-minute-test]
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: set up python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- run: pip install . montepy[build]
- name: Get Version
id: get_version
run: echo "version=`python -m setuptools_scm`" >> $GITHUB_OUTPUT
- name: Verify that this is a non-dev alpha release
run: .github/scripts/check_version.py --alpha
- run: python -m build .
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v2.1.1
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.get_version.outputs.version }}
name: Release ${{ steps.get_version.outputs.version }}
draft: true
- run: >-
gh release upload
'v${{ steps.get_version.outputs.version }}' dist/**
--repo '${{ github.repository }}'
- uses: actions/upload-artifact@v4
with:
name: build
path: |
dist/*.tar.gz
dist/*.whl
deploy-test-pypi:
environment:
name: test-pypi
url: https://test.pypi.org/p/montepy # Replace <package-name> with your PyPI project name
needs: [build-packages]
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: build
path: dist/
- 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 <package-name> with your PyPI project name
needs: [deploy-pages, deploy-test-pypi, build-packages]
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: build
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1




2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
id: get_version
run: echo "version=`python -m setuptools_scm`" >> $GITHUB_OUTPUT
- name: Verify that this is a non-dev release
run: .github/scripts/check_version.sh ${{ steps.get_version.outputs.version }}
run: .github/scripts/check_version.py
- run: python -m build .
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v2.1.1
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ doc/build/*
.idea/
.ipynb_checkpoints/
montepy/_version.py

# various testing results
htmlcov
.hypothesis
.mutmut-cache
26 changes: 21 additions & 5 deletions benchmark/benchmark_big_model.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
import gc
import montepy

import time
import tracemalloc

FAIL_THRESHOLD = 30

tracemalloc.start()

import montepy

FAIL_THRESHOLD = 40
MEMORY_FRACTION = 0.50

starting_mem = tracemalloc.get_traced_memory()[0]
print(f"starting memory with montepy. {starting_mem/1024/1024} MB")
start = time.time()

problem = montepy.read_input("benchmark/big_model.imcnp")

stop = time.time()

problem_mem = tracemalloc.get_traced_memory()[0]
print(f"Took {stop - start} seconds")
print(f"Memory usage report: {tracemalloc.get_traced_memory()[0]/1024/1024} MB")
print(f"Memory usage report: {problem_mem/1024/1024} MB")
del problem
gc.collect()
print(f"Memory usage report after GC: {tracemalloc.get_traced_memory()[0]/1024/1024} MB")
ending_mem = tracemalloc.get_traced_memory()[0]
print(f"Memory usage report after GC: {ending_mem/1024/1024} MB")

if (stop - start) > FAIL_THRESHOLD:
raise RuntimeError(
f"Benchmark took too long to complete. It must be faster than: {FAIL_THRESHOLD} s."
)

prob_gc_mem = problem_mem - ending_mem
prob_actual_mem = problem_mem - starting_mem
gc_ratio = prob_gc_mem / prob_actual_mem
print(f"{gc_ratio:.2%} of the problem's memory was garbage collected.")
if (prob_gc_mem / prob_actual_mem) < MEMORY_FRACTION:
raise RuntimeError(
f"Benchmark had too many memory leaks. Only {gc_ratio:.2%} of the memory was collected."
)
3 changes: 2 additions & 1 deletion demo/Pin_cell.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"source": [
"import montepy\n",
"import os\n",
"\n",
"montepy.__version__"
]
},
Expand Down Expand Up @@ -95,7 +96,7 @@
"metadata": {},
"outputs": [],
"source": [
"#make folder\n",
"# make folder\n",
"os.mkdir(\"parametric\")\n",
"\n",
"fuel_wall = problem.surfaces[1]\n",
Expand Down
1 change: 1 addition & 0 deletions doc/source/_test_for_missing_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"_version.py",
"__main__.py",
"_cell_data_control.py",
"_singleton.py"
}

base = os.path.join("..", "..")
Expand Down
10 changes: 10 additions & 0 deletions doc/source/api/montepy.data_inputs.nuclide.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
montepy.data_inputs.nuclide module
==================================


.. automodule:: montepy.data_inputs.nuclide
:members:
:inherited-members:
:undoc-members:
:show-inheritance:

1 change: 1 addition & 0 deletions doc/source/api/montepy.data_inputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ montepy.data\_inputs package
montepy.data_inputs.lattice_input
montepy.data_inputs.material
montepy.data_inputs.material_component
montepy.data_inputs.nuclide
montepy.data_inputs.mode
montepy.data_inputs.thermal_scattering
montepy.data_inputs.transform
Expand Down
9 changes: 9 additions & 0 deletions doc/source/api/montepy.input_parser.material_parser.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
montepy.input\_parser.material\_parser module
==============================================


.. automodule:: montepy.input_parser.material_parser
:members:
:inherited-members:
:undoc-members:
:show-inheritance:
2 changes: 2 additions & 0 deletions doc/source/api/montepy.input_parser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ montepy.input\_parser package
montepy.input_parser.input_file
montepy.input_parser.input_reader
montepy.input_parser.input_syntax_reader
montepy.input_parser.material_parser
montepy.input_parser.mcnp_input
montepy.input_parser.parser_base
montepy.input_parser.read_parser
montepy.input_parser.shortcuts
montepy.input_parser.surface_parser
montepy.input_parser.syntax_node
montepy.input_parser.tally_parser
montepy.input_parser.tally_seg_parser
montepy.input_parser.thermal_parser
montepy.input_parser.tokens
9 changes: 9 additions & 0 deletions doc/source/api/montepy.input_parser.tally_seg_parser.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
montepy.input\_parser.tally\_seg\_parser module
===============================================


.. automodule:: montepy.input_parser.tally_seg_parser
:members:
:inherited-members:
:undoc-members:
:show-inheritance:
57 changes: 56 additions & 1 deletion doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,61 @@
MontePy Changelog
*****************

1.0.0 releases
==============

#Next Version#
--------------

**Features Added**

* Redesigned how Materials hold Material_Components. See :ref:`migrate 0 1` (:pull:`507`).

* Made it easier to create an Isotope, or now Nuclide: ``montepy.Nuclide("H-1.80c")`` (:issue:`505`).
* When a typo in an object attribute is made an Error is raised rather than silently having no effect (:issue:`508`).
* Improved material printing to avoid very long lists of components (:issue:`144`).
* Allow querying for materials by components (:issue:`95`).
* Added support for getting and setting default libraries, e.g., ``nlib``, from a material (:issue:`369`).
*
* Added most objects to the top level so they can be accessed like: ``montepy.Cell``.
* Made ``Material.is_atom_fraction`` settable (:issue:`511`).
* Made NumberedObjectCollections act like a set (:issue:`138`).
* Automatically added children objects, e.g., the surfaces in a cell, to the problem when the cell is added to the problem (:issue:`63`).

**Bugs Fixed**

* Made it so that a material created from scratch can be written to file (:issue:`512`).
* Added support for parsing materials with parameters mixed throughout the definition (:issue:`182`).

**Breaking Changes**

* Removed :func:`~montepy.data_inputs.material.Material.material_components``. See :ref:`migrate 0 1` (:pull:`507`).
* Removed :class:`~montepy.data_inputs.isotope.Isotope` and changed them to :class:`~montepy.data_inputs.nuclide.Nuclide`.
* Removed :func:`~montepy.mcnp_problem.MCNP_Problem.add_cell_children_to_problem` as it is no longer needed.

**Deprecated code Removed**

* ``montepy.Cell.geometry_logic_string``
* ``montepy.data_inputs.cell_modifier.CellModifier.has_changed_print_style``
* ``montepy.data_inputs.data_input.DataInputAbstract``

* ``class_prefix``
* ``has_number``
* ``has_classifier``

* ``montepy.input_parser.mcnp_input.Card``
* ``montepy.input_parser.mcnp_input.ReadCard``
* ``montepy.input_parser.mcnp_input.Input.words``
* ``montepy.input_parser.mcnp_input.Comment``
* ``montepy.input_parser.mcnp_input.parse_card_shortcuts``
* ``montepy.mcnp_object.MCNP_Object``

* ``wrap_words_for_mcnp``
* ``compress_repeat_values``
* ``compress_jump_values``
* ``words``
* ``allowed_keywords``

0.5 releases
============

Expand Down Expand Up @@ -47,7 +102,7 @@ MontePy Changelog
============

0.4.1
--------------
----------------

**Features Added**

Expand Down
Loading

0 comments on commit 2184765

Please sign in to comment.