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

[WIP] Changes to make tests pass when using conda forge channel #2440

Merged
merged 2 commits into from
Apr 3, 2017

Conversation

djkirkham
Copy link
Contributor

This PR contains a set of changes to make sure the tests pass when installing the environment from the conda-forge channel, with a view to ultimately using that environment for the Travis automated tests.

Due to some issues with cartopy/matplotlib detailed in SciTools/cartopy#848, matplotlib is pinned to 1.*. (The package spec matplotlib<2 picks up 2.0.0rc2 which is inexplicably in the conda-forge channel, so I've pinned it with <1.9.)

In addition to some system and example tests which are still failing, some integration tests will fail using conda-forge until SciTools/iris-grib#75 is merged and a release has been made.

@marqh
Copy link
Member

marqh commented Mar 16, 2017

I think that there are a range of reasons why this may well be a sensible approach for us to take. I am keen to hear words of caution and tactical ways to protect ourselves were we to adopt this approach

@djkirkham
Copy link
Contributor Author

imagehash changes: SciTools/test-iris-imagehash#11

@marqh
Copy link
Member

marqh commented Mar 21, 2017

i am in favour of these changes in principal. I haven't found the time to finish my detail review yet

i'd like to encourage comments for key stakeholders about the approach of moving CI testing to conda-forge, which is the purpose of this work

are there voices in favour?
voices with concern?
issues to address?

thoughts please

@djkirkham
Copy link
Contributor Author

The main issue as I see it is that conda forge changes so quickly that we might struggle to keep up with the changes. Additionally, it's pretty gauling if tests start failing because something on the channel changed. This is still an issue with the scitools channel of course, but at least we're in control of that.

@QuLogic
Copy link
Member

QuLogic commented Mar 21, 2017

That seems like an advantage to me; having everything "work" because scitools is using a bunch of outdated packages is not really "working".

@DPeterK
Copy link
Member

DPeterK commented Mar 22, 2017

I agree with @djkirkham - we should not have to constantly be caught up to the latest everything. Doing so has the danger of introducing a very high workload to Iris devs that would come at the expense of the cessation of new features...

having everything "work" because scitools is using a bunch of outdated packages is not really "working"

Two things here:

  1. if all the tests pass, then to the best of our knowledge everything is working. The definition of working is that things are not breaking all the time; it is not that we are using the latest everything.
  2. some packages that are pinned a few point versions behind the latest release is not "outdated".

I agree that allowing ourselves to get far behind the latest version of packages is a very bad thing. It is similarly bad, however, to be constantly trying to chase the latest everything, and I'm concerned that conda-forge just moves a little too fast and too unpredictably to be really reliable to base Iris on -- at least, not without some well thought through pinning of some packages.

@ajdawson
Copy link
Member

This is still an issue with the scitools channel of course, but at least we're in control of that.

You'd have quite a lot of control over the conda-forge channel too, don't forget that.

I think it is an advantage to keep up with the conda-forge channel, because that is the one most users are working with, and if iris works there then it is working for a lot of people.

@djkirkham
Copy link
Contributor Author

The key issues seem to be these:

  • Using the latest conda-forge packages exposes us to test failures which may be out of our control and would slow the introduction of new features
  • Pinning the libraries or using the out-of-date packages on Scitools means that we're not supporting packages which are actually being used by users, and every so often there is a massive amount of work to bring things up-to-date

In an offline discussion earlier, the idea emerged to pin key libraries for the tests, but have a process in place to run the tests on the latest conda-forge libraries and notify us of any failures. That way new code could still easily be merged, and we'd be able to keep abreast of changes in conda-forge.

Thoughts?

@marqh
Copy link
Member

marqh commented Mar 22, 2017

@djkirkham a useful summary, thank you

My present view is that I/we can quickly 'patch' a test failure by pinning a dependency; this gives me/us time to implement an improvement and to then remove the pin

the idea emerged to pin key libraries for the tests, but have a process in place to run the tests on the latest conda-forge libraries and notify us of any failures.

I think this may be more conservative than is required. I would feel comfortable having the tests with no pins (or as few as possible) and to add a pin if a failure mode rears its head. Perhaps a developer rule that doing this should include raising a bug ticket and hoping to fix it in the future

Thus, I am advocating a reactive approach.
I think this could work for us

bounds = bounds[keys + (Ellipsis, )]
# Bounds will generally have an extra dimension compared
# to points, so add an Ellipsis at the end, unless there
# is already on, as numpy does not support double Ellipsis.
Copy link
Member

Choose a reason for hiding this comment

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

Not quite clear: should that be "unless there already is one" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have corrected it.

Copy link
Member

@DPeterK DPeterK left a comment

Choose a reason for hiding this comment

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

We need to fix the netcdftime screwup properly, not patch around it.

netcdftime.datetime(2000, 7, 21, 4, 48),
netcdftime.datetime(2000, 11, 1, 7, 12),
netcdftime.datetime(2001, 2, 11, 9, 36)]
if netCDF4.__version__ > '1.2.4':
Copy link
Member

Choose a reason for hiding this comment

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

Really?!

@@ -236,8 +244,12 @@ def test_time_360(self):
time_coord = DimCoord([100.1, 200.2], long_name="time",
units=time_unit)
cube.add_dim_coord(time_coord, 0)
expected_index = [netcdftime.datetime(2000, 4, 11, 2, 24),
netcdftime.datetime(2000, 7, 21, 4, 48)]
if netCDF4.__version__ > '1.2.4':
Copy link
Member

Choose a reason for hiding this comment

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

Again 😱

Why do we not have a test that picks this up properly rather than having two completely unrelated tests that have two different codepaths based on the version of an unrelated package?

Copy link
Member

@marqh marqh Mar 30, 2017

Choose a reason for hiding this comment

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

I feel pretty bad about this approach, but it represents another step in a long line of trying to work with netcdf4python

i think that this is the best of a bad bunch

there is also a particular issue with conda-forge builds of netcdf, not all versions are available as proper builds

further work is required on this, which needs to be planned
#2322

@marqh marqh dismissed DPeterK’s stale review March 30, 2017 14:40

dkillick and I have agreed to push this out to another activity, not to have it as a blocker for this PR

e.message))
continue
else:
raise
Copy link
Member

Choose a reason for hiding this comment

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

@djkirkham I think that this should be raise e to propagate the exception, surely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, raise on its own will keep the original stack trace. raise e would start a new stack trace from here. Minor detail, but it gives an extra bit of debugging information.

Copy link
Member

Choose a reason for hiding this comment

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

Yup, nice. But could you add a comment just to make that subtle point crystal clear to those that follow ... thanks!

@@ -26,12 +26,15 @@
# importing anything else
import iris.tests as tests

import numpy as np
import netcdftime
Copy link
Member

Choose a reason for hiding this comment

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

@djkirkham Fix the sort order of the imports please

@@ -99,7 +99,6 @@ def setUp(self):
'proleptic_gregorian': np.array(list(range(360, 367)) +
list(range(1, 4))),
'noleap': np.array(list(range(359, 366)) + list(range(1, 4))),
'julian': np.array(list(range(360, 367)) + list(range(1, 4))),
Copy link
Member

Choose a reason for hiding this comment

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

@marqh ( @djkirkham ) Any idea why this has been removed?

Also, the from cf_units import CALENDARS as calendars is now no longer used.

There is also a disconnect between the calendars in calendars and the calendars that this test is covering ... might want to join that up somehow ...

Copy link
Contributor Author

@djkirkham djkirkham Mar 31, 2017

Choose a reason for hiding this comment

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

@bjlittle This is because netcdftime julian datetime objects don't give the correct day of year in the latest version; they always give a value of 1.

In fact, some of the other calendar types have the same issue if they are constructed directly:

>>> import netcdftime
>>> ut = netcdftime.utime('days since 1980-12-25', calendar='365_day')
>>> date = ut.num2date(0)
>>> date2 = netcdftime.DatetimeNoLeap(1980, 12, 25)
>>> print repr(date)
netcdftime._netcdftime.DatetimeNoLeap(1980, 12, 25, 0, 0, 0, 0, 2, 359)
>>> print date.dayofyr
359
>>> print date.timetuple()
(1980, 12, 25, 0, 0, 0, 2, 359, -1)
>>> print repr(date2)           
netcdftime._netcdftime.DatetimeNoLeap(1980, 12, 25, 0, 0, 0, 0, -1, 1)
>>> print date2.dayofyr
1
>>> print date2.timetuple()
(1980, 12, 25, 0, 0, 0, -1, 1, -1)

All of our datetime objects are constructed using a utime object (via cf_units) so we avoid this issue with the other calendars.

I think it's probably worth just commenting out the offending line in our tests and having a comment explaining why. Either that, or pin netcdf4.

@bjlittle
Copy link
Member

bjlittle commented Mar 31, 2017

@djkirkham Where the heck is the travis-ci output ❓ ... 😕

@@ -116,6 +116,11 @@ def make_cube(self, calendar):

def test_calendars(self):
for calendar in calendars:
# Skip the Julian calendar due to
# https://github.com/Unidata/netcdftime/issues/13
# Remove this if block once the issue is resolved.
Copy link

Choose a reason for hiding this comment

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

Is this issue present as a result in changing versions of netcdftime?

If so, would pinning the version of netcdftime be the preferred option until Unidata/cftime#13 is resolved?

Copy link

Choose a reason for hiding this comment

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

A parallel in our own project is where we pin the numpy version to v1.11 until an iris issue is resolved:
#2425

@QuLogic QuLogic added this to the v2.0 milestone Apr 4, 2017
@QuLogic QuLogic modified the milestones: v1.13.0, v2.0 May 17, 2017
bjlittle added a commit to bjlittle/iris that referenced this pull request Jun 5, 2017
bjlittle added a commit to bjlittle/iris that referenced this pull request Jun 5, 2017
@djkirkham djkirkham deleted the totest branch October 26, 2017 13:02
@ehogan ehogan mentioned this pull request Nov 3, 2017
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.

8 participants