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

Fix country and extension loading #1281

Open
bonjourmauko opened this issue Oct 15, 2024 · 2 comments
Open

Fix country and extension loading #1281

bonjourmauko opened this issue Oct 15, 2024 · 2 comments
Labels
kind:build Pull requests that update a dependency file

Comments

@bonjourmauko
Copy link
Member

Hi there!

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

Here is what I did:

I'm trying to deploy the country-template to conda. See:
openfisca/country-template#157

Here is what I expected to happen:

In the test phase, the country should be properly loaded, and the tests should run.

Whether the tests pass or not is not the issue, but the loading of the tax benefit system.

Here is what actually happened:

It fails. See:
https://github.com/openfisca/country-template/actions/runs/11348459181/job/31562332866

ERROR:openfisca_core.taxbenefitsystems.tax_benefit_system:Unable to load OpenFisca variables from file "/home/runner/miniconda3/envs/openfisca/lib/python3.9/site-packages/openfisca_country_template/variables/taxes.py"
Traceback (most recent call last):
Traceback (most recent call last):
  File "/home/runner/miniconda3/envs/openfisca/bin/openfisca", line 10, in <module>
    sys.exit(main())
  File "/home/runner/miniconda3/envs/openfisca/lib/python3.9/site-packages/openfisca_core/scripts/openfisca_command.py", line 163, in main
    return sys.exit(main(parser))
  File "/home/runner/miniconda3/envs/openfisca/lib/python3.9/site-packages/openfisca_core/scripts/run_test.py", line 16, in main
    tax_benefit_system = build_tax_benefit_system(
  File "/home/runner/miniconda3/envs/openfisca/lib/python3.9/site-packages/openfisca_core/scripts/__init__.py", line 58, in build_tax_benefit_system
    tax_benefit_system = country_package.CountryTaxBenefitSystem()
  File "/home/runner/miniconda3/envs/openfisca/lib/python3.9/site-packages/openfisca_country_template/__init__.py", line 34, in __init__
    self.add_variables_from_directory(os.path.join(COUNTRY_DIR, "variables"))
  File "/home/runner/miniconda3/envs/openfisca/lib/python3.9/site-packages/openfisca_core/taxbenefitsystems/tax_benefit_system.py", line 285, in add_variables_from_directory
    self.add_variables_from_file(py_file)
  File "/home/runner/miniconda3/envs/openfisca/lib/python3.9/site-packages/openfisca_core/taxbenefitsystems/tax_benefit_system.py", line 230, in add_variables_from_file
    self.get_package_metadata()["location"],
  File "/home/runner/miniconda3/envs/openfisca/lib/python3.9/site-packages/openfisca_core/taxbenefitsystems/tax_benefit_system.py", line 534, in get_package_metadata
    "name": source_metadata.get("Name").lower(),
AttributeError: 'NoneType' object has no attribute 'lower'
  File "/home/runner/miniconda3/envs/openfisca/lib/python3.9/site-packages/openfisca_core/taxbenefitsystems/tax_benefit_system.py", line 230, in add_variables_from_file
    self.get_package_metadata()["location"],
  File "/home/runner/miniconda3/envs/openfisca/lib/python3.9/site-packages/openfisca_core/taxbenefitsystems/tax_benefit_system.py", line 534, in get_package_metadata
    "name": source_metadata.get("Name").lower(),
AttributeError: 'NoneType' object has no attribute 'lower'

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

#1037
#1059
#1015

Context

I identify more as a:

  • Developer
@bonjourmauko bonjourmauko added the kind:build Pull requests that update a dependency file label Oct 15, 2024
@bonjourmauko
Copy link
Member Author

Poke @benoit-cty

@benoit-cty
Copy link
Contributor

benoit-cty commented Oct 15, 2024

Hello,
If we look at https://github.com/openfisca/openfisca-core/blob/master/.conda/openfisca-country-template/recipe.yaml

We see :

package:
  name: ${{ name|lower }}

But name is not defined in this file.

Maybe we need to add {% set name = "OpenFisca-Country-Template" %}

But I'm not sure as your log output shows that he his trying to read setup.py to load the Name= from it.

Not related but it is possible to read from pyproject.toml instead of setup.py with

{% set pyproject = load_file_data('pyproject.toml') %}
  {% for req in pyproject.get('project').get('dependencies') %}
  - {{ req }}
  {% endfor %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:build Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

2 participants