openfisca / openfisca-core

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

Windows error : Filename too long #1201

Open benoit-cty opened 8 months ago

benoit-cty commented 8 months ago

Here is what I did:

Install OpenFisca France on Windows using Conda and an environment.yaml

Here is what I expected to happen:

Install with success.

Here is what actually happened:

error: unable to create file openfisca_france_reforms/plf_2022/parameters/prestations_sociales/prestations_etat_de_sante/invalidite/aah/abattement_conjoint_salarie_forfait_enfant.yaml: Filename too long

In OpenFisca-France we enforce a limit of 150 character for path parameters.

But it is not enought because Conda (or pip ?) use a temp path named C:\Users\bcourty\AppData\Local\Temp\pip-install-oboo5tz8\openfisca-france-reforms_9411943aa5784ca9bcc79d7d516ec176\

So the sum is above the 260 characters limit of Windows.

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

environment.yaml content:

name: leximpact-prepare-data
dependencies:
- python >=3.10,<4.0
- pip
- git
- pip:
  - "git+https://git.leximpact.dev/leximpact/simulateur-socio-fiscal/openfisca/openfisca-france-reforms.git"

Context

I identify more as a:

benoit-cty commented 8 months ago

A way to fix this will be to stop using sub-path and files for parameters and use a unique file, like a database. But it will be more complicated to maintain.

An option is to keep separate files for development but package them in one for the package release.

Any ideas ?

sandcha commented 8 months ago

Thank you for sharing this issue!

Is it linked to the CASD environment where we might not have enough rights to change the Windows OS default path lengths?

Some windows+openfisca users change this setting as described for example by this article (they also have to update the GIT configuration with git config --system core.longpaths true).

And to add some context:

The described error is linked to the openfisca_france_reforms repository which contains some reforms to the openfisca-france model. That's why an installation error coming from the parameters paths is in fact linked to the openfisca-france repository.

Then, as the way we manage the parameters in the openfisca models also comes from openfisca-core, this issue is opened on the openfisca-core repository.

This issue also refers to the leximpact-prepare-data repository: it calls openfisca-france-reforms to apply it on survey and CASD data. So, it does not affect the parameters paths but it comes with environment contraints as the code runs both on local machines and on the CASD environment.

@benoit-cty don't hesitate to edit this section if needed 😊

benoit-cty commented 8 months ago

Thanks for the precisions! It's not only CASD but all Windows developpers that do not have full access to their corporate computer. That's the case at the French assembly for example.

bonjourmauko commented 7 months ago

Thanks for reporting this issue @benoit-cty.

Given that the use of sub-folders is not enforced by core but just an opinionated practice of country-package maintainers, do you see what could be fixed in core to help users facing this issue?

A way to fix this will be to stop using sub-path and files for parameters and use a unique file, like a database.

You can already do that.

An option is to keep separate files for development but package them in one for the package release.

All parameters are loaded in memory, so « compiling » all files into one and using that one parameter file should be more or less trivial. However, as with the previous idea, that is a script that can be perfectly implemented either within a country package, or as an utility function separately, without requiring any changes in core at all.

But it is not enought because Conda (or pip ?) use a temp path named C:\Users\bcourty\AppData\Local\Temp\pip-install-oboo5tz8\openfisca-france-reforms_9411943aa5784ca9bcc79d7d516ec176\

That might be actually related to core, but I'm not sure: variables (and I assume extensions are reforms) are loaded dynamically by core, with a unique id corresponding to the addess in memory of each variable.

However, I believe that happens after the file is read into memory, so I suspect that the problem you report happens before (and this mechanism by the way does not apply to parameters).

By the way, I don't know if it is related to this specifically https://github.com/conda/conda/issues/7203

bonjourmauko commented 7 months ago

@benoit-cty @sandcha An idea:

find openfisca_france/parameters -name "*.yaml" | xargs -I{} sh -c 'cat {}; echo ""' >> parameters.yaml

(However, there is a possible issue concerning core here: namespacing, which is in fact derived from path).