Skip to content

Commit

Permalink
Merge 5378892 into 5c4c5cf
Browse files Browse the repository at this point in the history
  • Loading branch information
john-science committed Sep 13, 2023
2 parents 5c4c5cf + 5378892 commit 7c6316a
Show file tree
Hide file tree
Showing 22 changed files with 346 additions and 364 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Expand Up @@ -32,4 +32,4 @@

- [ ] The [release notes](https://terrapower.github.io/armi/release/index.html) (location `doc/release/0.X.rst`) are up-to-date with any important changes.
- [ ] The documentation is still up-to-date in the `doc` folder.
- [ ] The dependencies are still up-to-date in `setup.py`.
- [ ] The dependencies are still up-to-date in `pyproject.toml`.
39 changes: 22 additions & 17 deletions .github/workflows/validatemanifest.py
Expand Up @@ -13,39 +13,44 @@
# limitations under the License.

"""
Validating the MANIFEST.in.
Validating the package-data in the pyproject.toml.
Currently, the only validation we do of the MANIFEST.in file is to make sure
that we are trying to include files that don't exist.
Validate that we aren't trying to include files that don't exist.
"""

from glob import glob
import os

import toml

# CONSTANTS
INCLUDE_STR = "include "
MANIFEST_PATH = "MANIFEST.in"
ARMI_DIR = "armi/"
PRPROJECT = "pyproject.toml"


def main():
# loop through each line in the manifest file and find all the file paths
errors = []
lines = open(MANIFEST_PATH, "r", encoding="utf-8")
for i, line in enumerate(lines):
# if this is anything but an include line, move on
if not line.startswith(INCLUDE_STR):
continue
# parse the data files out of the pyproject.toml
txt = open(PRPROJECT, "r").read()
data = toml.loads(txt)
fileChunks = data["tool"]["setuptools"]["package-data"]["armi"]

# loop through each line in the package-data and find all the file paths
errors = []
for i, line in enumerate(fileChunks):
# make sure the file exists
path = line.strip()[len(INCLUDE_STR) :]
if not os.path.exists(path):
errors.append((i, path))
path = ARMI_DIR + line.strip()
if "*" in path:
paths = [f for f in glob(path) if len(f) > 3]
if not len(paths):
errors.append((i, path))
else:
if not os.path.exists(path):
errors.append((i, path))

# If there were any missing files, raise an Error.
if errors:
for (i, line) in errors:
print("Nonexistant file on line {}: {}".format(i, line))
raise ValueError("MANIFEST file is incorrect: includes non-existant files.")
raise ValueError("Package-data file is incorrect: includes non-existant files.")


if __name__ == "__main__":
Expand Down
70 changes: 0 additions & 70 deletions MANIFEST.in

This file was deleted.

11 changes: 4 additions & 7 deletions README.rst
Expand Up @@ -72,22 +72,21 @@ dependencies could conflict with your system dependencies.

$ git clone https://github.com/terrapower/armi
$ cd armi
$ pip3 install -r requirements.txt
$ python3 setup.py install
$ pip install -e .
$ armi

The easiest way to run the tests is to install `tox <https://tox.readthedocs.io/en/latest/>`_
and then run::

$ pip3 install -r requirements-testing.txt
$ pip install -e .[test]
$ tox -- -n 6

This runs the unit tests in parallel on 6 processes. Omit the ``-n 6`` argument
to run on a single process.

The tests can also be run directly, using ``pytest``::

$ pip3 install -r requirements-testing.txt
$ pip install -e .[test]
$ pytest -n 4 armi

From here, we recommend going through a few of our `gallery examples
Expand Down Expand Up @@ -313,7 +312,6 @@ see if their idea has wings, and if it does, they can then find a way to bring
it to engineering and commercial reality.



History of ARMI
---------------
ARMI was originally created by TerraPower, LLC near Seattle WA starting in 2009. Its
Expand Down Expand Up @@ -397,7 +395,6 @@ Most of our code is in the ``camelCase`` style, which is not the normal style fo
Python. This started in 2009 and we have stuck with the convention.



License
-------
TerraPower and ARMI are registered trademarks of TerraPower, LLC.
Expand All @@ -422,7 +419,7 @@ The ARMI system is licensed as follows:
See the License for the specific language governing permissions and
limitations under the License.
Be careful when including any dependency in ARMI (say in a requirements.txt file) not
Be careful when including any dependency in ARMI (say in the ``pyproject.toml`` file) not
to include anything with a license that superceeds our Apache license. For instance,
any third-party Python library included in ARMI with a GPL license will make the whole
project fall under the GPL license. But a lot of potential users of ARMI will want to
Expand Down
8 changes: 7 additions & 1 deletion armi/meta.py
Expand Up @@ -13,5 +13,11 @@
# limitations under the License.

"""Metadata describing an ARMI distribution."""
try:
# Python 3.x < 3.8
from importlib import metadata
except ImportError:
# Python >= 3.8
import importlib_metadata as metadata

__version__ = "0.2.8"
__version__ = metadata.version("armi")
2 changes: 1 addition & 1 deletion armi/reactor/blueprints/assemblyBlueprint.py
Expand Up @@ -194,7 +194,7 @@ def _constructAssembly(self, cs, blueprint):

@staticmethod
def _shouldMaterialModiferBeApplied(value) -> bool:
"""Determine if a material modifier entry is applicable
"""Determine if a material modifier entry is applicable.
Two exceptions:
Expand Down
6 changes: 3 additions & 3 deletions armi/reactor/blueprints/blockBlueprint.py
Expand Up @@ -226,15 +226,15 @@ def construct(
def _getBlockwiseMaterialModifierOptions(
self, children: Iterable[Composite]
) -> Set[str]:
"""Collect all the material modifiers that exist on a block"""
"""Collect all the material modifiers that exist on a block."""
validMatModOptions = set()
for c in children:
perChildModifiers = self._getMaterialModsFromBlockChildren(c)
validMatModOptions.update(perChildModifiers)
return validMatModOptions

def _getMaterialModsFromBlockChildren(self, c: Composite) -> Set[str]:
"""Collect all the material modifiers from a child of a block"""
"""Collect all the material modifiers from a child of a block."""
perChildModifiers = set()
for material in self._getMaterialsInComposite(c):
for materialParentClass in material.__class__.__mro__:
Expand All @@ -252,7 +252,7 @@ def _getMaterialModsFromBlockChildren(self, c: Composite) -> Set[str]:
return perChildModifiers

def _getMaterialsInComposite(self, child: Composite) -> Iterator[Material]:
"""Collect all the materials in a composite"""
"""Collect all the materials in a composite."""
# Leaf node, no need to traverse further down
if isinstance(child, Component):
yield child.material
Expand Down
6 changes: 3 additions & 3 deletions armi/utils/dochelpers.py
Expand Up @@ -31,7 +31,7 @@


def create_figure(path, caption=None, align=None, alt=None, width=None):
r"""
"""
This method is available within ``.. exec::``. It allows someone to create a figure with a
caption.
"""
Expand All @@ -50,7 +50,7 @@ def create_figure(path, caption=None, align=None, alt=None, width=None):


def create_table(rst_table, caption=None, align=None, widths=None, width=None):
r"""
"""
This method is available within ``.. exec::``. It allows someone to create a table with a
caption.
Expand Down Expand Up @@ -119,7 +119,7 @@ def usermethod():


class PyReverse(Directive):
r"""Runs pyreverse to generate UML for specified module name and options.
"""Runs pyreverse to generate UML for specified module name and options.
The directive accepts the same arguments as pyreverse, except you should not specify
``--project`` or ``-o`` (output format). These are automatically specified.
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Expand Up @@ -91,7 +91,7 @@ def autodoc_skip_member_handler(app, what, name, obj, skip, options):


def setup(app):
"""Method to make `python setup.py build_sphinx` generate api documentation."""
"""Method to make `make html` generate api documentation."""
app.connect("autodoc-skip-member", autodoc_skip_member_handler)

app.add_domain(PatchedPythonDomain, override=True)
Expand Down
2 changes: 1 addition & 1 deletion doc/developer/documenting.rst
Expand Up @@ -21,7 +21,7 @@ Building the documentation
Before building documentation, ensure that you have installed the test requirements into
your ARMI virtual environment with::

pip3 install -r requirements-testing.txt
pip install -e .[test]

You also need to have the following utilities available in your PATH:

Expand Down
6 changes: 3 additions & 3 deletions doc/developer/first_time_contributors.rst
Expand Up @@ -30,15 +30,15 @@ new your code does.

The standard way to run the tests is to install and use `tox <https://tox.readthedocs.io/en/latest/>`_::

$ pip3 install tox
$ pip install tox
$ tox -- -n 6

This runs the unit tests in parallel on 6 processes. Omit the ``-n 6`` argument
to run on a single process.

Or the tests can also be run using ``pytest`` directly::

$ pip3 install -r requirements-testing.txt
$ pip intall -e .[test]
$ pytest -n 4 armi

Submitting Changes
Expand Down Expand Up @@ -66,7 +66,7 @@ Also, please check out our (quick) synopsis on :doc:`good commit messages </deve
Licensing of Tools
==================

Be careful when including any dependency in ARMI (say in a ``requirements.txt`` file) not
Be careful when including any dependency in ARMI (say in the ``pyproject.toml`` file) not
to include anything with a license that superceeds our Apache license. For instance,
any third-party Python library included in ARMI with a GPL license will make the whole
project fall under the GPL license. But a lot of potential users of ARMI will want to
Expand Down
26 changes: 10 additions & 16 deletions doc/developer/tooling.rst
Expand Up @@ -80,31 +80,25 @@ out-of-date.
Packaging and dependency management
-----------------------------------
The process of packaging Python projects and managing their dependencies is somewhat
challenging and nuanced. The contents of our ``setup.py`` follow existing conventions as
much as possible. In particular, we follow `this fantastic article
<https://caremad.io/posts/2013/07/setup-vs-requirement/>`_ about dependecy management in
Python projects.
challenging and nuanced. The contents of our ``pyproject.toml`` follow existing conventions as
much as possible. In particular, we follow `the official Python packaging guidance
<https://packaging.python.org/en/latest/>`_.

pyproject.toml
^^^^^^^^^^^^^^
As much as possible, the ARMI team will try to centralize our installation and build systems
through the top-level ``pyproject.toml`` file. The only exception will be our documentation,
which has much customization done through the Sphinx ``doc/conf.py`` file.

setup.py
^^^^^^^^
The packages listed in the ``install_requires`` argument to ``setup()`` are meant to
express, as abstractly as possible, the packages that need to be installed **somehow**
for the package to work. In addition, ``extras_require`` are used to specify other
packages that are not strictly required, but if installed enable extra functionality,
like unit testing or building documentation.

requirements.txt
^^^^^^^^^^^^^^^^
The ``requirements***.txt`` files exist to describe a complete environment more
specifically. If specific versions of packages are required, they should be defined here.
Any extra arguments to ``pip`` will also be placed here. For instance, there is a ``-e``
that tells ``pip`` to install ARMI itself and defer to ``setup.py`` for a version-agnostic
list of dependencies. We also have multiple requirements files for different needs, like
testing.

Third-Party Licensing
^^^^^^^^^^^^^^^^^^^^^
Be careful when including any dependency in ARMI (say in a requirements.txt file) not
Be careful when including any dependency in ARMI (say in the ``pyproject.toml`` file) not
to include anything with a license that superceeds our Apache license. For instance,
any third-party Python library included in ARMI with a GPL license will make the whole
project fall under the GPL license. But a lot of potential users of ARMI will want to
Expand Down
1 change: 1 addition & 0 deletions doc/release/0.2.rst
Expand Up @@ -14,6 +14,7 @@ What's new in ARMI
#. Moved the ``Reactor`` assembly number from the global scope to a ``Parameter``. (`PR#1383 <https://github.com/terrapower/armi/pull/1383>`_)
#. Added ``powerDensity`` as a high-level alternative to ``power`` to configure a Reactor. (`PR#1395 <https://github.com/terrapower/armi/pull/1395>`_)
#. Added SHA1 hashes of XS control files to the welcome text. (`PR#1334 <https://github.com/terrapower/armi/pull/1334>`_)
#. Moved from ``setup.py`` to ``pyproject.toml``. (`PR#1409 <https://github.com/terrapower/armi/pull/1409>`_)
#. Add python 3.11 to ARMI's CI testing GH actions! (`PR#1341 <https://github.com/terrapower/armi/pull/1341>`_)
#. Put back ``avgFuelTemp`` block parameter. (`PR#1362 <https://github.com/terrapower/armi/pull/1362>`_)
#. Make cylindrical component block collection less strict about pre-homogenization checks. (`PR#1347 <https://github.com/terrapower/armi/pull/1347>`_)
Expand Down
6 changes: 3 additions & 3 deletions doc/tutorials/making_your_first_app.rst
Expand Up @@ -51,7 +51,7 @@ files for us to fill in, like this::
materials.py
thermalSolver.py
doc/
setup.py
pyproject.toml
README.md
LICENSE.md

Expand Down Expand Up @@ -82,8 +82,8 @@ These files are:

* :file:`myapp/thermalSolver.py` contains the thermal/hydraulics solver

* :file:`setup.py` the `python package installation file
<https://docs.python.org/3/distutils/setupscript.html>`_ to help users install your
* :file:`pyproject.toml` the `python package installation file
<https://packaging.python.org/en/latest/flow/>`_ to help users install your
application.

* :file:`README.md` and :file:`LICENSE.md` are an optional description and license of your
Expand Down
8 changes: 2 additions & 6 deletions doc/user/user_install.rst
Expand Up @@ -82,14 +82,10 @@ the git repository with::
.. tip:: If you plan to contribute to ARMI (please do!), you may want to use
SSH keys and use ``git clone git@github.com:terrapower/armi.git``.

Now install the ARMI dependencies::
Now install the ARMI with all its dependencies::

(armi-venv) $ cd armi
(armi-venv) $ pip install -r requirements.txt

Then, install ARMI into your venv with::

(armi-venv) $ pip install -e .
(armi-venv) $ pip install -e .[test]

.. tip:: If you don't want to install ARMI into your venv, you will need to add the ARMI source
location to your system's ``PYTHONPATH`` environment variable so that
Expand Down

0 comments on commit 7c6316a

Please sign in to comment.