Skip to content

Fix country and extension loading #1281

@bonjourmauko

Description

@bonjourmauko

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:buildPull requests that update a dependency file

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions