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

[SCons] Check for minimum version of ruamel.yaml #891

Merged
merged 6 commits into from
Jul 27, 2020

Conversation

bryanwweber
Copy link
Member

To run the tests of the converter scripts, ruamel.yaml must be installed
with a minumum version at least 0.15.94. We aren't sure what the true
minimum version is, but 0.15.94 was released in April 2019 so is
probably widely released enough to count. Note that the version
available from the Ubuntu 16.04 repositories is not new

If applicable, fill in the issue number this pull request is fixing

Fixes #831

Checklist

  • There is a clear use-case for this code change
  • The commit message has a short title & references relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • The pull request is ready for review

test/SConscript Outdated
@@ -268,6 +268,33 @@ test_root = '#interfaces/cython/cantera/test'
for f in mglob(localenv, test_root, '^test_*.py'):
python_subtests.append(f.name[5:-3])

if localenv['python_package'] != 'none':
# We choose ruamel.yaml 0.15.94 as the minimum version,
Copy link
Member

Choose a reason for hiding this comment

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

0.15.87 ... ?

Copy link
Member

@ischoegl ischoegl Jul 2, 2020

Choose a reason for hiding this comment

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

Actually

 ruamel_yaml-0.15.80        |py37h8f50634_1001         267 KB  conda-forge

on several of the runners.

Copy link
Member

@ischoegl ischoegl Jul 2, 2020

Choose a reason for hiding this comment

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

Update: Ubuntu 18.04 uses 0.15.34 see link, and I recall that it worked out of the box. Same minimum version will work for debian. CentOS7 is older (0.13.14, although CentOS8 has 0.15.41) and like Xenial (0.10.23) throws the error.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, thank you for helping triangulate this!

@codecov
Copy link

codecov bot commented Jul 2, 2020

Codecov Report

Merging #891 into main will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #891   +/-   ##
=======================================
  Coverage   71.18%   71.18%           
=======================================
  Files         376      376           
  Lines       46201    46201           
=======================================
  Hits        32888    32888           
  Misses      13313    13313           

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 cf1c081...16c8fe6. Read the comment docs.

@bryanwweber bryanwweber force-pushed the fix-831 branch 2 times, most recently from 243f9ff to b876598 Compare July 3, 2020 11:42
Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

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

I'm wondering if it would make more sense to do this check in SConstruct, at the same time we do the checks for Numpy and Cython. Otherwise, we create the scenario where the user just runs scons build && scons install, never triggering this check and ending up with a broken Cantera installation.

@bryanwweber
Copy link
Member Author

The reservation I have about putting this check in SConstruct instead of test/SConscript is that ruamel.yaml is not a build requirement, it's a runtime requirement. In the case you suggest, the user would only hit an error message when they tried to convert a mechanism, and the fix would be that ruamel.yaml isn't installed (or the version is too old). They could perfectly well use the library with any existing YAML file with no problems. Another case where I don't want to introduce another build-time requirement is for packaging.

Maybe if we put the check in SConstruct, it could be a warning for the build/install stage and an error during the test stage?

@speth
Copy link
Member

speth commented Jul 5, 2020

Hm, I didn't realize that we didn't run the tests in the packaging environments. But is there any environment we have set up where installing ruamel.yaml is any more difficult than installing Numpy or Cython? I feel like people usually ignore warnings that pop up in scons build (which isn't unreasonable in 10000 lines of output).

Despite what I said earlier, maybe we should check for the minimum ruamel.yaml version in the conversion scripts, given that we know that there are still-supported operating systems which provide older versions. And it would be nice to provide a more helpful error message than AttributeError: module 'ruamel.yaml' has no attribute 'RoundTripRepresenter'.

At that point, checking for ruamel.yaml at the scons test stage isn't much different from just letting those particular tests fail. I think the point of checking at the start of scons build is to fail fast if possible.

@bryanwweber
Copy link
Member Author

Thanks for the thoughts @speth. I implemented the version check in the *2yaml.py scripts for now, to improve the error message as you say.

Hm, I didn't realize that we didn't run the tests in the packaging environments.

It depends on the package, but for instance, for the macOS MATLAB package, we don't build the Python module at all, so there's no reason to have ruamel.yaml installed.

But is there any environment we have set up where installing ruamel.yaml is any more difficult than installing Numpy or Cython?

Not particularly, at least, not that I can think of. Apologies for being dense, I probably should have caught this before, but are you suggesting that the check for ruamel.yaml only be done if python_package != 'none'? I have a few conflicting thoughts here, let me write them all out and see if things start to clarify.

First, think that conditioning the check on actually building the Python interface could make sense. On the other hand, I have a gut feeling that we shouldn't restrict the user's environment unless it's really necessary.

What if we check for a good version if a user tries to install the Python interface? A user running scons install will presumably want to actually use the interface, so that'd be a good time to check without restricting the build step. And fixing the error wouldn't require rebuilding anything, so it wouldn't be a case where the user would save time by seeing the error in the build step.

@bryanwweber
Copy link
Member Author

OK, I implemented a check of ruamel.yaml at install time. I also slightly redid the check for Python version to make the required version for both the full and minimal interfaces the same. I'm not sure about this change, because it's possible in the future that the minimum version for the minimal interface could be lower than for the full interface (which is how it is implemented right now). So thoughts about that change would be appreciated, and its in its own commit so can be dropped easily.

SConstruct Outdated Show resolved Hide resolved
@speth
Copy link
Member

speth commented Jul 10, 2020

are you suggesting that the check for ruamel.yaml only be done if python_package != 'none'? I have a few conflicting thoughts here, let me write them all out and see if things start to clarify.

Yes, that was my thought. If you aren't installing at least the "minimal" Python module, it doesn't matter whether or not you have ruamel.yaml installed.

First, think that conditioning the check on actually building the Python interface could make sense. On the other hand, I have a gut feeling that we shouldn't restrict the user's environment unless it's really necessary.

I'm confused - what does "restricting the user's environment" mean?

What if we check for a good version if a user tries to install the Python interface? A user running scons install will presumably want to actually use the interface, so that'd be a good time to check without restricting the build step. And fixing the error wouldn't require rebuilding anything, so it wouldn't be a case where the user would save time by seeing the error in the build step.

Checking before install or test makes sense. Currently, you're only doing it before install, right?

@bryanwweber
Copy link
Member Author

what does "restricting the user's environment" mean?

Requiring them to install ruamel.yaml when they don't need it.

Checking before install or test makes sense. Currently, you're only doing it before install, right?

In SConstruct, the only check is before install. The test phase is de facto handled by the checks in the scripts themselves. It would be possible to expand the SConstruct check to include the test phase, but that would preclude running subsets of the test suite (for example, scons test-thermo) if the Python interface had been built - perhaps a minor consideration, but since it isn't necessary to check at test time in SConstruct given the check in the script, I don't think its necessary to add it.

@speth
Copy link
Member

speth commented Jul 10, 2020

If I'm running scons test, I'd rather it fail immediately than run for several minutes before telling me that I need to install ruamel.yaml. What about writing something like:

check_for_ruamel_yaml = any(target in COMMAND_LINE_TARGETS for target in ['install', 'test', 'test-python-convert'])

and then using this variable in the various if statements? I think this catches all of the cases where you would need ruamel.yaml.

@bryanwweber
Copy link
Member Author

@speth I implemented that suggestion, thanks. Any thoughts about synchronizing the minimum Python versions?

Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

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

I think this looks good, generally. Just had a couple of minor suggestions.

SConstruct Outdated Show resolved Hide resolved
SConstruct Show resolved Hide resolved
interfaces/cython/cantera/ck2yaml.py Outdated Show resolved Hide resolved
To run the YAML converter scripts, ruamel.yaml must be installed with a
minumum version at least 0.15.34. We aren't sure what the true minimum
version is, but 0.15.34 was released in September 2017 and is the
newest version available from the Ubuntu 18.04 repositories.
One of the SolutionArray tests uses pandas as an output option.
Check for the minimum ruamel.yaml version, 0.15.34, at install and test
time. The check happens at install and test time because ruamel.yaml is
only required to run the Python interface, not to build it.
The minimum Python version is the same for the full and the minimal
interfaces.
The minimum NumPy version is 1.12 to support the use of numpy.full() in
the SolutionArray interface introduced in Cantera#838.
Since we set the minimum Python version in SConstruct, use that value to
fill in python_requires in setup.py.in. This ensures that when the
minimum Python version is changed in the future, setup.py will
automatically reflect the change.
@bryanwweber
Copy link
Member Author

@speth Thanks for the comments! Updated now.

Copy link
Member

@speth speth left a comment

Choose a reason for hiding this comment

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

Thanks! This looks good now.

@speth speth merged commit ba13c65 into Cantera:main Jul 27, 2020
@bryanwweber bryanwweber deleted the fix-831 branch July 27, 2020 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insufficient ruamel.yaml dependencies on older systems
3 participants