diff --git a/.conda/build.sh b/.conda/build.sh deleted file mode 100644 index c942c713eb1..00000000000 --- a/.conda/build.sh +++ /dev/null @@ -1,6 +0,0 @@ -# Install RMG -make install - -# lazy "install" of everything in our 'external' folder. -# most of which should probably be elsewhere -cp -R ${SRC_DIR}/external ${SP_DIR} diff --git a/.conda/conda_build_config.yaml b/.conda/conda_build_config.yaml deleted file mode 100644 index 6a0cca7f0c7..00000000000 --- a/.conda/conda_build_config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -python: - - 3.7 -numpy: - - 1.15 - -# Specifically for Travis build. Should change if building locally. -CONDA_BUILD_SYSROOT: - - /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk # [osx] diff --git a/.conda/meta.yaml b/.conda/meta.yaml index e781b460496..20466c88d3b 100644 --- a/.conda/meta.yaml +++ b/.conda/meta.yaml @@ -1,84 +1,185 @@ -# For conda build +# meta.yaml +# +# welcome to meta.yaml, poor soul that you are. this file specifies the 'recipe' for compiling +# RMG-Py into binaries which can then be uploaded for access via the conda package manager +# to use this file, you can follow the procedure shown in .github/workflows/conda_build.yml +# package: name: rmg - version: 3.2.0 + version: 3.3.0 source: path: ../ build: - number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }} + number: 0 + script: | + python utilities.py check-pydas # write the rmgpy/solver/settings.pxi file + python setup.py install --single-version-externally-managed --record=record.txt requirements: build: - - {{ compiler('c') }} # [unix] + - {{ compiler('c') }} host: - - cython >=0.25.2 - - numpy - - openbabel >=3 - - pydas >=1.0.2 - - pydqed >=1.0.1 - - pyrdl - - python - - quantities - - rdkit >=2018 - - scipy - - setuptools + - conda-forge::cairo + - conda-forge::cairocffi + - conda-forge::ffmpeg >=7 + - conda-forge::xlrd + - conda-forge::xlwt + - conda-forge::h5py + - conda-forge::graphviz >=12 + - conda-forge::markupsafe + - conda-forge::psutil + - conda-forge::ncurses + - conda-forge::suitesparse + - conda-forge::graphviz + - conda-forge::pyopenssl >20 + - conda-forge::coolprop + - conda-forge::cantera =2.6 + - conda-forge::mopac + - conda-forge::cclib >=1.6.3,<1.9 + - conda-forge::openbabel >=3 + - conda-forge::rdkit >=2022.09.1 + - conda-forge::python >=3.9 + - conda-forge::setuptools <80 + - conda-forge::coverage + - conda-forge::cython >=0.25.2,<3.1 + - conda-forge::scikit-learn + - conda-forge::scipy >=1.9 + - conda-forge::numpy >=1.10.0,<2 + - conda-forge::pydot + - conda-forge::jinja2 + - conda-forge::jupyter + - conda-forge::pymongo + - conda-forge::pyparsing + - conda-forge::pyyaml + - conda-forge::networkx + - conda-forge::pytest + - conda-forge::pytest-cov + - conda-forge::pytest-check + - conda-forge::pyutilib + - conda-forge::matplotlib >=1.5 + - conda-forge::mpmath + - conda-forge::pandas + - conda-forge::gprof2dot + - conda-forge::numdifftools + - conda-forge::quantities !=0.16.0,!=0.16.1 + - conda-forge::ringdecomposerlib-python + - rmg::pydas >=1.0.3 + - rmg::pydqed >=1.0.3 + - rmg::symmetry + - rmg::rmgdatabase =3.3.0 + - blas=*=openblas run: - - cairo - - cairocffi - - cantera >=2.3.0 - - cclib >=1.6.3 - - coolprop - - coverage - - cython >=0.25.2 - - ffmpeg - - gprof2dot - - graphviz - - h5py - - jinja2 - - jupyter - - markupsafe - - matplotlib >=1.5 - - mopac - - mpmath - - muq2 - - networkx - - nose - - numdifftools - - {{ pin_compatible('numpy') }} - - openbabel >=3 - - pandas - - psutil - - pydas >=1.0.2 - - pydot - - pydqed >=1.0.1 - - pymongo - - pyparsing - - pyrdl - - python - - pyyaml - - pyzmq - - quantities - - rdkit >=2018 - - rmgdatabase >=3.2.0 - - scikit-learn - - scipy - - symmetry - - xlrd - - xlwt + - conda-forge::cairo + - conda-forge::cairocffi + - conda-forge::ffmpeg >=7 + - conda-forge::xlrd + - conda-forge::xlwt + - conda-forge::h5py + - conda-forge::graphviz >=12 + - conda-forge::markupsafe + - conda-forge::psutil + - conda-forge::ncurses + - conda-forge::suitesparse + - conda-forge::graphviz + - conda-forge::pyopenssl >20 + - conda-forge::coolprop + - conda-forge::cantera =2.6 + - conda-forge::mopac + - conda-forge::cclib >=1.6.3,<1.9 + - conda-forge::openbabel >=3 + - conda-forge::rdkit >=2022.09.1 + - conda-forge::python >=3.9 + - conda-forge::setuptools <80 + - conda-forge::coverage + - conda-forge::cython >=0.25.2,<3.1 + - conda-forge::scikit-learn + - conda-forge::scipy >=1.9 + - conda-forge::numpy >=1.10.0,<2 + - conda-forge::pydot + - conda-forge::jinja2 + - conda-forge::jupyter + - conda-forge::pymongo + - conda-forge::pyparsing + - conda-forge::pyyaml + - conda-forge::networkx + - conda-forge::pytest + - conda-forge::pytest-cov + - conda-forge::pytest-check + - conda-forge::pyutilib + - conda-forge::matplotlib >=1.5 + - conda-forge::mpmath + - conda-forge::pandas + - conda-forge::gprof2dot + - conda-forge::numdifftools + - conda-forge::quantities !=0.16.0,!=0.16.1 + - conda-forge::ringdecomposerlib-python + - rmg::pydas >=1.0.3 + - rmg::pydqed >=1.0.3 + - rmg::symmetry + - rmg::rmgdatabase =3.3.0 + - blas=*=openblas test: + requires: + - conda-forge::cairo + - conda-forge::cairocffi + - conda-forge::ffmpeg >=7 + - conda-forge::xlrd + - conda-forge::xlwt + - conda-forge::h5py + - conda-forge::graphviz >=12 + - conda-forge::markupsafe + - conda-forge::psutil + - conda-forge::ncurses + - conda-forge::suitesparse + - conda-forge::graphviz + - conda-forge::pyopenssl >20 + - conda-forge::coolprop + - conda-forge::cantera =2.6 + - conda-forge::mopac + - conda-forge::cclib >=1.6.3,<1.9 + - conda-forge::openbabel >=3 + - conda-forge::rdkit >=2022.09.1 + - conda-forge::python >=3.9 + - conda-forge::setuptools <80 + - conda-forge::coverage + - conda-forge::cython >=0.25.2,<3.1 + - conda-forge::scikit-learn + - conda-forge::scipy >=1.9 + - conda-forge::numpy >=1.10.0,<2 + - conda-forge::pydot + - conda-forge::jinja2 + - conda-forge::jupyter + - conda-forge::pymongo + - conda-forge::pyparsing + - conda-forge::pyyaml + - conda-forge::networkx + - conda-forge::pytest + - conda-forge::pytest-cov + - conda-forge::pytest-check + - conda-forge::pyutilib + - conda-forge::matplotlib >=1.5 + - conda-forge::mpmath + - conda-forge::pandas + - conda-forge::gprof2dot + - conda-forge::numdifftools + - conda-forge::quantities !=0.16.0,!=0.16.1 + - conda-forge::ringdecomposerlib-python + - rmg::pydas >=1.0.3 + - rmg::pydqed >=1.0.3 + - rmg::symmetry + - rmg::rmgdatabase =3.3.0 + - blas=*=openblas source_files: - 'examples/rmg/superminimal' - - 'examples/arkane/networks/n-butanol' + - 'examples/arkane/networks/n-butanol_msc' imports: - rmgpy - arkane commands: - - rmg.py examples/rmg/superminimal/input.py # [unix] - - Arkane.py examples/arkane/networks/n-butanol/input.py # [unix] - - python %SCRIPTS%\rmg.py examples\rmg\superminimal\input.py # [win] - - python %SCRIPTS\Arkane.py examples\arkane\networks\n-butanol\input.py # [win] + - rmg.py examples/rmg/superminimal/input.py + - Arkane.py examples/arkane/networks/n-butanol_msc/input.py about: home: https://github.com/ReactionMechanismGenerator/RMG-Py diff --git a/.github/workflows/conda_build.yml b/.github/workflows/conda_build.yml index 8ddbef08771..9e5b0e874ab 100644 --- a/.github/workflows/conda_build.yml +++ b/.github/workflows/conda_build.yml @@ -1,58 +1,66 @@ name: Conda Build +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: + pull_request: + workflow_dispatch: push: branches: - stable jobs: - build-linux: - runs-on: ubuntu-latest + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-13, macos-latest] + numpy-version: ["1.26"] + python-version: ["3.9"] + runs-on: ${{ matrix.os }} + name: Build ${{ matrix.os }} Python ${{ matrix.python-version }} Numpy ${{ matrix.numpy-version }} defaults: run: shell: bash -l {0} steps: - - uses: actions/checkout@v2 - - uses: conda-incubator/setup-miniconda@v2 + - uses: actions/checkout@v4 + + - name: Setup Miniforge + uses: conda-incubator/setup-miniconda@v3 with: - environment-file: environment.yml - python-version: 3.7 - activate-environment: rmg_env - - name: Conda info + miniforge-variant: Miniforge3 + miniforge-version: latest + auto-update-conda: true + show-channel-urls: true + conda-remove-defaults: "true" + auto-activate-base: "true" + activate-environment: "" + + - name: Install Build Tools + run: conda install python anaconda-client conda-build + + - name: Configure Auto-Upload + if: github.ref == 'refs/heads/stable' run: | - conda info - conda list + conda config --set anaconda_upload yes + - name: Build Binary - env: - CONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} run: | - conda install -y conda-build - conda install -y anaconda-client + # set a default value to the conda_token if needed (like from forks) + : "${CONDA_TOKEN:=${{ secrets.ANACONDA_TOKEN }}}" + : "${CONDA_TOKEN:=default_value}" + echo "CONDA_TOKEN=$CONDA_TOKEN" >> $GITHUB_ENV conda config --add channels rmg - conda config --set anaconda_upload yes - conda build --token $CONDA_TOKEN --user rmg .conda - build-osx: - runs-on: macos-latest - defaults: - run: - shell: bash -l {0} + conda config --add channels conda-forge + CONDA_NPY=${{ matrix.numpy-version }} CONDA_PY=${{ matrix.python-version }} conda build --token $CONDA_TOKEN --user rmg . + + result: + if: ${{ always() }} + runs-on: ubuntu-latest + name: Final Results + needs: [build] steps: - - uses: actions/checkout@v2 - - uses: conda-incubator/setup-miniconda@v2 - with: - environment-file: environment.yml - python-version: 3.7 - activate-environment: rmg_env - - name: Conda info - run: | - conda info - conda list - - name: Build Binary - env: - CONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }} - run: | - conda install -y conda-build - conda install -y anaconda-client - conda config --add channels rmg - conda config --set anaconda_upload yes - xcrun --show-sdk-path - conda build --token $CONDA_TOKEN --user rmg .conda + - run: exit 1 + # see https://github.com/orgs/community/discussions/26822?sort=new#discussioncomment-8285141 + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped') }} diff --git a/Arkane.py b/Arkane.py index c0d4203770c..0b409f4d326 100644 --- a/Arkane.py +++ b/Arkane.py @@ -1,68 +1,4 @@ -#!/usr/bin/env python3 +from arkane import __main__ -############################################################################### -# # -# RMG - Reaction Mechanism Generator # -# # -# Copyright (c) 2002-2023 Prof. William H. Green (whgreen@mit.edu), # -# Prof. Richard H. West (r.west@neu.edu) and the RMG Team (rmg_dev@mit.edu) # -# # -# Permission is hereby granted, free of charge, to any person obtaining a # -# copy of this software and associated documentation files (the 'Software'), # -# to deal in the Software without restriction, including without limitation # -# the rights to use, copy, modify, merge, publish, distribute, sublicense, # -# and/or sell copies of the Software, and to permit persons to whom the # -# Software is furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in # -# all copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # -# DEALINGS IN THE SOFTWARE. # -# # -############################################################################### - -""" -This is the main executable script for Arkane, a tool for computing chemical -reaction rates and other properties used in detailed kinetics models using -various methodologies and theories. To run Arkane, use the command :: - - $ python Arkane.py FILE - -where ``FILE`` is the path to an Arkane input file describing the job to -execute. Arkane will run the specified job, writing the output to -``output.py`` and a log to both the console and to ``Arkane.log``, with both -files appearing in the same directory as the input file. Some additional -command-line arguments are available; run the command :: - - $ python Arkane.py -h - -for more information. -""" - -import os -import logging - -from arkane.main import Arkane - -arkane = Arkane() - -# Parse and validate the command-line arguments -arkane.parse_command_line_arguments() - -# Execute the job -arkane.execute() - -try: - import psutil - - process = psutil.Process(os.getpid()) - memory_info = process.memory_info() - logging.info('Memory used: %.2f MB' % (memory_info.rss / 1024.0 / 1024.0)) -except ImportError: - logging.info('Optional package dependency "psutil" not found; memory profiling information will not be saved.') +if __name__ == "__main__": + __main__.main() diff --git a/arkane/__main__.py b/arkane/__main__.py new file mode 100644 index 00000000000..39a6afe915b --- /dev/null +++ b/arkane/__main__.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 + +############################################################################### +# # +# RMG - Reaction Mechanism Generator # +# # +# Copyright (c) 2002-2023 Prof. William H. Green (whgreen@mit.edu), # +# Prof. Richard H. West (r.west@neu.edu) and the RMG Team (rmg_dev@mit.edu) # +# # +# Permission is hereby granted, free of charge, to any person obtaining a # +# copy of this software and associated documentation files (the 'Software'), # +# to deal in the Software without restriction, including without limitation # +# the rights to use, copy, modify, merge, publish, distribute, sublicense, # +# and/or sell copies of the Software, and to permit persons to whom the # +# Software is furnished to do so, subject to the following conditions: # +# # +# The above copyright notice and this permission notice shall be included in # +# all copies or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # +# DEALINGS IN THE SOFTWARE. # +# # +############################################################################### + +""" +This is the main executable script for Arkane, a tool for computing chemical +reaction rates and other properties used in detailed kinetics models using +various methodologies and theories. To run Arkane, use the command :: + + $ python Arkane.py FILE + +where ``FILE`` is the path to an Arkane input file describing the job to +execute. Arkane will run the specified job, writing the output to +``output.py`` and a log to both the console and to ``Arkane.log``, with both +files appearing in the same directory as the input file. Some additional +command-line arguments are available; run the command :: + + $ python Arkane.py -h + +for more information. +""" + +import os +import logging + +from arkane.main import Arkane + +def main(): + arkane = Arkane() + + # Parse and validate the command-line arguments + arkane.parse_command_line_arguments() + + # Execute the job + arkane.execute() + + try: + import psutil + + process = psutil.Process(os.getpid()) + memory_info = process.memory_info() + logging.info('Memory used: %.2f MB' % (memory_info.rss / 1024.0 / 1024.0)) + except ImportError: + logging.info('Optional package dependency "psutil" not found; memory profiling information will not be saved.') + +if __name__ == "__main__": + main() diff --git a/documentation/source/users/rmg/installation/anacondaUser.rst b/documentation/source/users/rmg/installation/anacondaUser.rst index af480ff13ee..0244e7ce7f0 100644 --- a/documentation/source/users/rmg/installation/anacondaUser.rst +++ b/documentation/source/users/rmg/installation/anacondaUser.rst @@ -7,67 +7,40 @@ Binary Installation Using Anaconda for Unix-Based Systems: Linux and Mac OSX #. Install the `conda` package manager via `miniforge`, if you do not already have it (or Anaconda), by following the `Miniforge installation instructions `_. -#. Install both RMG and the RMG-database binaries through the terminal. Dependencies will be installed automatically. It is safest to make a new conda environment for RMG and its dependencies. Type the following command into the terminal to create the new environment named 'rmg_env' containing the latest stable version of the RMG program and its database. :: +#. Install both RMG and the RMG-database binaries through the terminal. Dependencies will be installed automatically. It is safest to make a new conda environment for RMG and its dependencies. Type the following command into the terminal to create the new environment named 'rmg_env' containing the latest stable version of the RMG program and its database. :: - conda create -c defaults -c rmg -c rdkit -c cantera -c pytorch -c conda-forge --name rmg_env rmg rmgdatabase + conda create --name rmg_env 'rmg::rmg' Whenever you wish to use it you must first activate the environment:: conda activate rmg_env For more information about using conda, please check out the `conda user guide `_. + + To install a specific version of RMG, add the version to the install command:: + + conda create --name rmg_33_env 'rmg::rmg==3.3.0' + + Not all versions of RMG are available via conda for all platforms. Check the `official RMG conda channel `_ to see which are available for download. #. You may now run an RMG test job. Save the `Minimal Example Input File `_ to a local directory. Use the terminal to run your RMG job inside that folder using the following command :: rmg.py input.py - If you encounter the ImportError related to ``libmkl_rt.so.2``, refer to the :ref:`Fixing the ImportError related to libmkl_rt.so.2 ` - section below to fix the error and re-run the RMG test job. - -You may now use RMG-Py, Arkane, as well as any of the :ref:`Standalone Modules ` included in the RMG-Py package. - -.. _fixImportError: - -Fixing the ImportError related to ``libmkl_rt.so.2`` -============================================================ - -You may encounter the following ImportError when you try to run a RMG test job :: - - Traceback (most recent call last): - File "/PATH-TO-YOUR-ANACONDA/envs/rmg_env/bin/rmg.py", line 48, in - from rmgpy.rmg.main import RMG, initialize_log, process_profile_stats, make_profile_graph - File "/PATH-TO-YOUR-ANACONDA/envs/rmg_env/lib/python3.7/site-packages/rmgpy/rmg/main.py", line 51, in - from cantera import ck2cti - File "/PATH-TO-YOUR-ANACONDA/envs/rmg_env/lib/python3.7/site-packages/cantera/__init__.py", line 4, in - from ._cantera import * - ImportError: libmkl_rt.so.2: cannot open shared object file: No such file or directory - -where ``PATH-TO-YOUR-ANACONDA`` is the path to the ``Anaconda3`` directory installed on your machine. -The default install location of Anaconda on Linux is ``/home//Anaconda3``. - -To fix this issue, simply copy ``libmkl_rt.so.1`` as ``libmkl_rt.so.2`` under the rmg environment library by typing the following -line on your terminal:: - - cp /PATH-TO-YOUR-ANACONDA/envs/rmg_env/lib/libmkl_rt.so.1 /PATH-TO-YOUR-ANACONDA/envs/rmg_env/lib/libmkl_rt.so.2 - -Note that ``PATH-TO-YOUR-ANACONDA`` needs to be the path to your ``Anaconda3`` directory, which mostly likely looks -like ``/home//Anaconda3``. If you are unable to locate the ``libmkl_rt.so.1`` file on your computer, you can find its location with the following command:: - - locate libmkl_rt.so.1 - -After copying the file as ``libmkl_rt.so.2``, try running the RMG test job again:: - - rmg.py input.py - -You will see a line saying ``MODEL GENERATION COMPLETED`` on your terminal if your RMG test job ran successfully. + You will see a line saying ``MODEL GENERATION COMPLETED`` on your terminal if your RMG test job ran successfully. Updating your binary installation of RMG in Linux or Mac OSX ============================================================ -If you had previously installed a binary version of the RMG package, you may -check and update your installation to the latest stable version available on Anaconda by typing the following command on the terminal :: +If you had previously installed a binary version of the RMG package and wish to update to a newer version, we suggest creating a new conda environment and installing the updated version there :: + + conda create --name rmg_xyz_env 'rmg::rmg==x.y.z' + +It is also possible, though not advisable, to update your existing installation to the latest stable version available on Anaconda by typing the following command on the terminal :: source activate rmg_env - conda update rmg rmgdatabase -c rmg + conda update 'rmg::rmg' + +Doing this may break any other code present in the conda environment and RMG may not function correctly. If you attempt this update method and face issues, please attempt to install the new version of RMG in a new conda environment before reaching out for assistance. diff --git a/documentation/source/users/rmg/installation/index.rst b/documentation/source/users/rmg/installation/index.rst index 78be9d3ee45..d371c960231 100644 --- a/documentation/source/users/rmg/installation/index.rst +++ b/documentation/source/users/rmg/installation/index.rst @@ -46,6 +46,17 @@ For users unfamiliar with bash or Linux, we recommend looking at Be sure to also change the version number in the docker run commands to match the version you pulled. A full list of available docker images can be found at `Docker Hub `_. +Alternative Install: Binary Installation Using Anaconda +=========================================================== + +If you are accustomed to using the Anaconda package manager or cannot tolerate the storage overhead of Docker, installation from conda is also available. +This is recommended for users who want to use RMG out of the box and are not interested in changing the RMG code or making many additions to RMG's thermodynamic and kinetics databases. +If this does interest you, please see the Developer Install below. + +.. toctree:: + :maxdepth: 1 + + anacondaUser Developer Install: Installation from Source =========================================================== @@ -74,7 +85,6 @@ not recommended for use. linux macos - anacondaUser anacondaUserWindows anacondaDeveloperWindows windowsEnvironment diff --git a/rmg.py b/rmg.py index 6127d761f80..52e876dc9e8 100644 --- a/rmg.py +++ b/rmg.py @@ -1,108 +1,4 @@ -#!/usr/bin/env python +from rmgpy import __main__ -############################################################################### -# # -# RMG - Reaction Mechanism Generator # -# # -# Copyright (c) 2002-2023 Prof. William H. Green (whgreen@mit.edu), # -# Prof. Richard H. West (r.west@neu.edu) and the RMG Team (rmg_dev@mit.edu) # -# # -# Permission is hereby granted, free of charge, to any person obtaining a # -# copy of this software and associated documentation files (the 'Software'), # -# to deal in the Software without restriction, including without limitation # -# the rights to use, copy, modify, merge, publish, distribute, sublicense, # -# and/or sell copies of the Software, and to permit persons to whom the # -# Software is furnished to do so, subject to the following conditions: # -# # -# The above copyright notice and this permission notice shall be included in # -# all copies or substantial portions of the Software. # -# # -# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # -# DEALINGS IN THE SOFTWARE. # -# # -############################################################################### - -""" -RMG is an automatic chemical mechanism generator. It is awesomely awesome. -""" - -import os.path -import logging - -import rmgpy -from rmgpy.rmg.main import RMG, initialize_log, process_profile_stats, make_profile_graph -from rmgpy.util import parse_command_line_arguments - -################################################################################ - - -def main(): - # Parse the command-line arguments (requires the argparse module) - args = parse_command_line_arguments() - - if args.postprocess: - logging.info("Postprocessing the profiler statistics (will be appended to RMG.log)") - else: - # Initialize the logging system (resets the RMG.log file) - level = logging.INFO - if args.debug: - level = 0 - elif args.verbose: - level = logging.DEBUG - elif args.quiet: - level = logging.WARNING - initialize_log(level, os.path.join(args.output_directory, 'RMG.log')) - - logging.info(rmgpy.settings.report()) - - kwargs = { - 'restart': args.restart, - 'walltime': args.walltime, - 'maxproc': args.maxproc, - 'kineticsdatastore': args.kineticsdatastore, - 'max_iterations': args.maxiter, - } - - if args.profile: - import cProfile - rmg_profiler = cProfile.Profile() - stats_file = os.path.join(args.output_directory, 'RMG.profile') - - global_vars = {} - local_vars = { - 'inputFile': args.file, - 'output_dir': args.output_directory, - 'kwargs': kwargs, - 'RMG': RMG, - 'rmg_profiler': rmg_profiler, - } - - command = """rmg = RMG(input_file=inputFile, output_directory=output_dir, profiler=rmg_profiler); rmg.execute(**kwargs)""" - - print("Running under cProfile") - if not args.postprocess: - # actually run the program! - rmg_profiler.runctx(command, global_vars, local_vars) - rmg_profiler.dump_stats(stats_file) - # postprocess the stats - log_file = os.path.join(args.output_directory, 'RMG.log') - process_profile_stats(stats_file, log_file) - - # Make the profile graph. Force graph generation regardless of display status if args.postprocess - make_profile_graph(stats_file, force_graph_generation=args.postprocess) - - else: - - rmg = RMG(input_file=args.file, output_directory=args.output_directory) - rmg.execute(**kwargs) - - -################################################################################ - -if __name__ == '__main__': - main() +if __name__ == "__main__": + __main__.main() diff --git a/rmgpy/__main__.py b/rmgpy/__main__.py new file mode 100644 index 00000000000..6127d761f80 --- /dev/null +++ b/rmgpy/__main__.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python + +############################################################################### +# # +# RMG - Reaction Mechanism Generator # +# # +# Copyright (c) 2002-2023 Prof. William H. Green (whgreen@mit.edu), # +# Prof. Richard H. West (r.west@neu.edu) and the RMG Team (rmg_dev@mit.edu) # +# # +# Permission is hereby granted, free of charge, to any person obtaining a # +# copy of this software and associated documentation files (the 'Software'), # +# to deal in the Software without restriction, including without limitation # +# the rights to use, copy, modify, merge, publish, distribute, sublicense, # +# and/or sell copies of the Software, and to permit persons to whom the # +# Software is furnished to do so, subject to the following conditions: # +# # +# The above copyright notice and this permission notice shall be included in # +# all copies or substantial portions of the Software. # +# # +# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # +# DEALINGS IN THE SOFTWARE. # +# # +############################################################################### + +""" +RMG is an automatic chemical mechanism generator. It is awesomely awesome. +""" + +import os.path +import logging + +import rmgpy +from rmgpy.rmg.main import RMG, initialize_log, process_profile_stats, make_profile_graph +from rmgpy.util import parse_command_line_arguments + +################################################################################ + + +def main(): + # Parse the command-line arguments (requires the argparse module) + args = parse_command_line_arguments() + + if args.postprocess: + logging.info("Postprocessing the profiler statistics (will be appended to RMG.log)") + else: + # Initialize the logging system (resets the RMG.log file) + level = logging.INFO + if args.debug: + level = 0 + elif args.verbose: + level = logging.DEBUG + elif args.quiet: + level = logging.WARNING + initialize_log(level, os.path.join(args.output_directory, 'RMG.log')) + + logging.info(rmgpy.settings.report()) + + kwargs = { + 'restart': args.restart, + 'walltime': args.walltime, + 'maxproc': args.maxproc, + 'kineticsdatastore': args.kineticsdatastore, + 'max_iterations': args.maxiter, + } + + if args.profile: + import cProfile + rmg_profiler = cProfile.Profile() + stats_file = os.path.join(args.output_directory, 'RMG.profile') + + global_vars = {} + local_vars = { + 'inputFile': args.file, + 'output_dir': args.output_directory, + 'kwargs': kwargs, + 'RMG': RMG, + 'rmg_profiler': rmg_profiler, + } + + command = """rmg = RMG(input_file=inputFile, output_directory=output_dir, profiler=rmg_profiler); rmg.execute(**kwargs)""" + + print("Running under cProfile") + if not args.postprocess: + # actually run the program! + rmg_profiler.runctx(command, global_vars, local_vars) + rmg_profiler.dump_stats(stats_file) + # postprocess the stats + log_file = os.path.join(args.output_directory, 'RMG.log') + process_profile_stats(stats_file, log_file) + + # Make the profile graph. Force graph generation regardless of display status if args.postprocess + make_profile_graph(stats_file, force_graph_generation=args.postprocess) + + else: + + rmg = RMG(input_file=args.file, output_directory=args.output_directory) + rmg.execute(**kwargs) + + +################################################################################ + +if __name__ == '__main__': + main() diff --git a/rmgpy/version.py b/rmgpy/version.py index fa611e30f4d..c77bee82397 100644 --- a/rmgpy/version.py +++ b/rmgpy/version.py @@ -33,4 +33,4 @@ This value can be accessed via `rmgpy.__version__`. """ -__version__ = '3.2.0' +__version__ = '3.3.0' diff --git a/setup.py b/setup.py index 4bebd5a5566..e6b47c66c59 100644 --- a/setup.py +++ b/setup.py @@ -119,8 +119,8 @@ ] scripts = [ - 'Arkane.py', 'rmg.py', + 'Arkane.py', 'scripts/checkModels.py', 'scripts/diffModels.py', 'scripts/generateChemkinHTML.py', @@ -149,6 +149,12 @@ python_requires='>=3.9,<3.10', packages=find_packages(where='.', include=["rmgpy*"]) + find_packages(where='.', include=["arkane*"]), scripts=scripts, + entry_points={ + 'console_scripts': [ + 'rmg.py = rmgpy.__main__:main', + 'Arkane.py = arkane.__main__:main', + ], + }, include_package_data=True, package_data={ "": ["*.pxd"],