Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RMG futurization: Python 3 compatibility and PEP-8 compliance #1724

Merged
merged 164 commits into from
Sep 24, 2019
Merged

Conversation

mliu49
Copy link
Contributor

@mliu49 mliu49 commented Sep 23, 2019

Motivation or Problem

Due to the imminent end of Python 2 support, it is important that RMG is updated to be compatible with Python 3.

Description of Changes

This PR is the culmination of almost six week's work by me, @alongd, @amarkpayne, @mjohnson541, and @xiaoruiDong in futurizing RMG-Py and Arkane.

Main outcomes:

  • Python 3 compatibility (and loss of Python 2 compatibility)
  • PEP-8 name changes (camelCase to lowercase_with_underscores)
  • PEP-8 code style changes

This PR also includes the removal of all remaining scoop functionality, given it has been non-functional since parallel processing has been refactored to use Python multiprocessing, and the reduction module, which was heavily tied into the scoop framework and therefore also non-functional.

Merging

The standard test suite and RMG-tests should test most of the key functionality. Since the individual components of this branch have been previously reviewed, I plan on merging this directly once tests pass.

Next Steps

More detailed testing is definitely needed, but my proposed plan is to do that after merging this into master. The main motivation behind that is so we can switch back to the standard contributor workflow as soon as possible, and allow everyone to begin updating existing PRs and more easily make new PRs for fixing any remaining bugs.

mliu49 and others added 30 commits August 11, 2019 21:29
Change Travis build language to minimal
Remove the sudo setting which is deprecated
Move default test stage out of jobs section
Copy of environment_linux.yml with a few changes
Removed packages whose Py3 replacements are still in progress
Removed version requirement on pydot
Note that the build matrix will be expanded for all test stages
Since this is not the master or stable branch, it won't matter
However, this will need to be updated before merging into master
For compatibility with Python 2/3
Our implementation of model reduction is slow to the point of
being infeasible for any moderately sized mechanism which requries
reduction.

It is also tightly integrated with parallel processing via scoop,
which is also deprecated and no longer works properly.
Parallelization using scoop has been deprecated and replaced
by multiprocessing. This removes all of the remaining code.

rmgpy/rmg/parreactTest.py and rmgpy/thermo/thermoengineTest.py
were removed because they don't contain any tests that run.
Add list() for iterators
Standardized imports in Arkane (and import numpy as np)
Replaced 'xrange' with 'range'
Replaced itervalues() and iteritems() with values() and items()
Replace deprecated 'warn' with 'warning'
Standardized module docstrings in Arkane
Use CamelCase for class names
Make classes in Arkane inherit from object
Execute a file correctly in exec()
Also replace instances of catching broad exceptions
Only covers the following files:
chemkinTest.py
constants*.py
constraints*.py
display.py
exceptions.py
quantityTest.py
rmgObjectTest.py
Before we were getting it from a dependency of a dependency
Previous wildcard imports masked this issue.
Thanks to @mliu49 for catching this and making this fix.
Inform users if they are using an unsupported Python version
@codecov
Copy link

codecov bot commented Sep 23, 2019

Codecov Report

Merging #1724 into master will decrease coverage by 9%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1724      +/-   ##
==========================================
- Coverage   41.66%   32.65%   -9.01%     
==========================================
  Files         176       87      -89     
  Lines       30215    26158    -4057     
  Branches     6256     6874     +618     
==========================================
- Hits        12588     8541    -4047     
+ Misses      16703    16645      -58     
- Partials      924      972      +48
Impacted Files Coverage Δ
rmgpy/data/kinetics/depository.py 60.27% <ø> (-3.11%) ⬇️
rmgpy/molecule/symmetry.py 0% <ø> (ø) ⬆️
rmgpy/data/statmech.py 42.39% <ø> (-0.84%) ⬇️
rmgpy/rmg/pdep.py 12.21% <ø> (-0.12%) ⬇️
rmgpy/qm/main.py 65.32% <ø> (ø) ⬆️
rmgpy/reaction.py 0% <ø> (ø) ⬆️
rmgpy/rmg/main.py 21.68% <ø> (-0.17%) ⬇️
rmgpy/molecule/filtration.py 88.33% <ø> (ø) ⬆️
rmgpy/data/kinetics/family.py 48.49% <ø> (-0.43%) ⬇️
rmgpy/molecule/__init__.py 100% <ø> (ø) ⬆️
... and 200 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3846fcc...f73cb57. Read the comment docs.

@mliu49
Copy link
Contributor Author

mliu49 commented Sep 23, 2019

I added a commit implementing a check for the Python version to make it obvious to users if they need to update their environment. Otherwise, I think compiling or running RMG would lead to a non-obvious SyntaxError. Could someone take a look?

@mliu49 mliu49 mentioned this pull request Sep 23, 2019
17 tasks
@mliu49
Copy link
Contributor Author

mliu49 commented Sep 23, 2019

Closes #785 🎉

@@ -4,9 +4,9 @@
#
################################################################################

.PHONY : all minimal main solver check cantherm clean install decython documentation mopac_travis
.PHONY : all minimal main solver check pycheck arkane clean install decython documentation mopac_travis
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Outside the scope of this PR) Are our .PHONY targets up to date? Should things like test and eg0 be in there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also wondering about this. I looked it up, and it seems like phony targets are most important if you have files with the same name as the target. In that case, putting the target in the phony list tells make to execute the target rather than compile the file.

Copy link
Member

@amarkpayne amarkpayne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked over the last commit @mliu49 added and it looks good to me.

@mliu49 mliu49 merged commit 11146ef into master Sep 24, 2019
@amarkpayne amarkpayne deleted the py3 branch September 25, 2019 15:39
@mliu49 mliu49 mentioned this pull request Dec 4, 2019
@mliu49 mliu49 mentioned this pull request Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants