iiasa / message_ix

The integrated assessment and energy systems model MESSAGEix
https://docs.messageix.org
Apache License 2.0
112 stars 149 forks source link

Track/adjust for test failure with genno 1.23.0 #788

Closed khaeru closed 5 months ago

khaeru commented 5 months ago

(Apparently) with genno 1.23.0, we see failures like this:

>       assert_qty_equal(obs, demand, check_attrs=False)

message_ix/tests/test_report.py:70: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

left = Index(['chicago', 'new-york', 'topeka'], dtype='object', name='n')
right = MultiIndex([( 'chicago',),
            ('new-york',),
            (  'topeka',)],
           names=['n'])
obj = 'Series.index'

    def _check_types(left, right, obj: str = "Index") -> None:
        if not exact:
            return

>       assert_class_equal(left, right, exact=exact, obj=obj)
E       AssertionError: Series.index are different
E       
E       Series.index classes are different
E       [left]:  Index(['chicago', 'new-york', 'topeka'], dtype='object', name='n')
E       [right]: MultiIndex([( 'chicago',),
E                   ('new-york',),
E                   (  'topeka',)],
E                  names=['n'])

This may actually be a regression in genno due to some housekeeping in khaeru/genno#115, that adapted AttrSeries.__init__ to address deprecation warnings with pandas 2.2. What appears to have happened is that the code now skips this block that ensures a pd.MultiIndex. So obs in this test, while functionally identical to demand, has a different index class and thus fails assert_qty_equal().

This fix is probably upstream, this is just to track.

khaeru commented 5 months ago

@glatterf42 my preferred temporarily mitigation here would be to install genno<1.23 in the CI workflows.

glatterf42 commented 5 months ago

We currently have two failed tests, but when all tests first started failing, there was only one. This was on Saturday and I found these version changes:

On Sunday, the second test failure was introduced when some additional dependency updates came along:

glatterf42 commented 5 months ago

The relevant changes in pytest might be detailed here: https://docs.pytest.org/en/stable/changelog.html#old-deprecations-are-now-errors

glatterf42 commented 5 months ago

Partially/temporarily addressed by #789.

khaeru commented 5 months ago

This should be addressed in genno 1.23.1, just released.