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

override_dict accepts a JSON/YAML string with possible unexpected results #729

Open
3 tasks
brynpickering opened this issue Dec 12, 2024 · 0 comments
Open
3 tasks
Labels
bug v0.6 Version 0.6

Comments

@brynpickering
Copy link
Member

What happened?

It's technically possible to provide calliope with a JSON/YAML string as the input to override_dict, instead of a dictionary. AttrDict handles this fine, even if it is unexpected. However, it sees it as a pseudo-file and resolves any "imports". This bug corpped up, because the order in which it resolves those imports relative to loading the base file doesn't work as expected (in the case I've seen it on, setting an override on a timeseries filepath at the tech level doesn't filter through).

m = calliope.Model("path/to/model.yaml", override_dict='{"import": ["path/to/relative/import.yaml"]}', scenario="scenario_loaded_from_imported_file")

It's quite niche, you need to only have the model/run config in model.yaml and then everything else loaded as an import via the override dict YAML string as:

def _model_imports():
    return {
        "import" [
            "model_config/locations.yaml",
            "model_config/techs.yaml",
            "scenarios.yaml"
        ],
        "model.timeseries_data_path": f"timeseries_data",
    }
override_dict = json.dumps(_model_imports())
m = calliope.Model("path/to/model.yaml", override_dict=override_dict, scenario="scenario_loaded_from_imported_file")

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

Version

v0.6.10

Relevant log output

No response

@brynpickering brynpickering added bug v0.6 Version 0.6 labels Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v0.6 Version 0.6
Projects
None yet
Development

No branches or pull requests

1 participant