openfisca / openfisca-core

OpenFisca core engine. See other repositories for countries-specific code & data.
https://openfisca.org
GNU Affero General Public License v3.0
170 stars 75 forks source link

Strict dependencies could be problematic for larger project #1147

Closed benoit-cty closed 1 year ago

benoit-cty commented 2 years ago

Hi there!

I really enjoy OpenFisca, but I recently encountered an issue.

Here is what I did:

import plotly to made a plot in a project using OpenFisca-France.

Here is what I expected to happen:

Importing work.

Here is what actually happened:

TypeError: <class 'numpy.typing._dtype_like._SupportsDType'> is not a generic class

Here is data (or links to it) that can help you reproduce this issue:

This is not directly an OpenFisca issue as it comes from xarray (See https://github.com/pydata/xarray/issues/6818) that as a problem with NumPy 1.20.

But it is due to the OpenFisca directive 'numpy >= 1.11, < 1.21', resulting to installation of 1.20.3 from may 2021.

I understand that fixing version is safer for OpenFisca, but when using it

There is no emergency as I solved my problem by downgrading xarray. I just want to let the team know that it can cause problem.

Context

I identify more as a:

bonjourmauko commented 1 year ago

Hi @benoit-cty , we've been working to update numpy :) All help is welcome. Take a look at #1161

MattiSG commented 1 year ago

Thanks @benoit-cty for taking the time to document this issue.

For the specific case described, I believe indeed the main issue is the severely outdated version of numpy. Upgrades have been stuck after issues cropped up like in #954, and then concerns by major reusers of having to adapt their code. We are now considering specifying that older numpy versions are only supported within either a time (e.g. 18 months) or versions (e.g. last 3) constraint, leaving it to reusers to decide of their own upgrade path, since the current system is not sustainable considering how outdated dependencies are getting.

Through discussion with @maukoquiroga, I believe the best way forward is to have a one-off transition to numpy ≥ 1.20, which will bring typing support and enable easier systematic typing in the codebase. #1168 is a first step in this direction, dropping support for numpy < 1.20 to bring Python 3.8 compatibility.

However, the title of your issue seems to be for a wider set of issues. If you have other suggestions than the ones outlined above for increasing compatibility, please share them here! 😃

benoit-cty commented 1 year ago

In https://github.com/openfisca/openfisca-core/pull/1168 I see that we still restrict to numpy < 1.21 (according to https://pypi.org/project/numpy/#history it's june 2021) why not allow 1.23 for example ? Does it break OpenFisca ?

bonjourmauko commented 1 year ago

In #1168 I see that we still restrict to numpy < 1.21 (according to https://pypi.org/project/numpy/#history it's june 2021) why not allow 1.23 for example ? Does it break OpenFisca ?

It does. #1168 introduces a way to manually run workflows with newer versions to NumPy, to encourage contributions, and #1161 is a work in progress to support NumPy 1.23.

benoit-cty commented 1 year ago

OK, so I think we could close this issue now that it is clear that OpenFisca will try to keep up-to-date max version.