premise icon indicating copy to clipboard operation
premise copied to clipboard

Issue with create_datapackage in 2.30.dev

Open dbantje opened this issue 8 months ago • 9 comments

When trying to create a Pathways datapackage with the mining updates in the 2.30.dev_mining branch, the code fails because of the lines https://github.com/polca/premise/blob/7e4c1d8cdc78f113f200ad3543e4fe01be815ffc/premise/pathways.py#L82C1-L91C48

energy = FinalEnergy(
    database=scenario["database"],
    iam_data=scenario["iam data"],
    model=scenario["model"],
    pathway=scenario["pathway"],
    year=scenario["year"],
    version=self.datapackage.version,
    system_model=self.datapackage.system_model,
)
energy.import_heating_inventories()

import_heating_inventories() was only a method of the Energy class, not of FinalEnergy - maybe a leftover line that should be removed / replaced?

dbantje avatar Apr 22 '25 09:04 dbantje

@romainsacchi @alvarojhahn Is this an issue that requires a larger fix, or something that could be fixed or worked around quickly?

dbantje avatar Apr 24 '25 09:04 dbantje

@dbantje indeed. Actually the code should look like this now:

final_energy = FinalEnergy(
    database=scenario["database"],
    iam_data=scenario["iam data"],
    model=scenario["model"],
    pathway=scenario["pathway"],
    year=scenario["year"],
    version=version,
    system_model=system_model,
)

final_energy.regionalize_heating_datasets()

final_energy.relink_datasets()
scenario["database"] = final_energy.database
scenario["index"] = final_energy.index
scenario["cache"] = final_energy.cache

so maybe you have not pulled recently?

romainsacchi avatar Apr 24 '25 09:04 romainsacchi

I am working on a new version of the 'mining' update. It should be finished today and then merged. I suggest not working with 2.30.dev_mining

alvarojhahn avatar Apr 24 '25 09:04 alvarojhahn

Ah, sorry. Yes, I was referring to 2.30.dev

romainsacchi avatar Apr 24 '25 09:04 romainsacchi

Perfect, thanks @alvarojhahn ! :)

dbantje avatar Apr 24 '25 09:04 dbantje

@alvarojhahn: Are there any updates about this?

dbantje avatar Apr 28 '25 08:04 dbantje

Hi @dbantje .

2.3.0.dev_mining is updated, and the changes planned to sulfidic tailings are there.

I am waiting for @romainsacchi to finish some development in 2.3.0.dev, then we will merge.

alvarojhahn avatar Apr 28 '25 12:04 alvarojhahn

@dbantje 2.3.0.dev is now working and update("mining") is available

alvarojhahn avatar May 01 '25 13:05 alvarojhahn

Thanks you for the work on those features and the merging!

I'm still getting issues when trying to create a Pathways datapackage:

  • the lines that initially caused the error are still in pathways.py: https://github.com/polca/premise/blob/5f00640e7e3132b8120aecb713edffc3a16c8d6e/premise/pathways.py#L82C1-L94C36 Since the heating markets are now regionalized when calling _update_final_energy, it should be ok to replace the above lines with (old code commented out), right?
for scenario in self.datapackage.scenarios:
    scenario = load_database(scenario)
    # energy = FinalEnergy(
    #     database=scenario["database"],
    #     iam_data=scenario["iam data"],
    #     model=scenario["model"],
    #     pathway=scenario["pathway"],
    #     year=scenario["year"],
    #     version=self.datapackage.version,
    #     system_model=self.datapackage.system_model,
    # )
    # energy.import_heating_inventories()
    # scenario["database"] = energy.database
    
    dump_database(scenario)
  • I get another error in add_scenario_data:
Traceback (most recent call last):
  File "/p/projects/ariadne/scenarioLCA/01_run_premise_from_config.py", line 120, in <module>
    ndb.create_datapackage(name=f"output/{dirname}/{fname}", transformations=transformations)
  File "/p/projects/ariadne/scenarioLCA/software/premise/premise/pathways.py", line 96, in create_datapackage
    self.export_datapackage(
  File "/p/projects/ariadne/scenarioLCA/software/premise/premise/pathways.py", line 118, in export_datapackage
    self.add_scenario_data()
  File "/p/projects/ariadne/scenarioLCA/software/premise/premise/pathways.py", line 311, in add_scenario_data
    extra_units.update(scenario["iam data"].energy_use_volumes.attrs["unit"])
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'IAMDataCollection' object has no attribute 'energy_use_volumes'
srun: error: csp14c01: task 0: Exited with exit code 1

This is for the default SSP2-NPi scenario. Could you check whether you run into the same issue on your end?

dbantje avatar May 05 '25 10:05 dbantje

Is this still an issue?

romainsacchi avatar Jun 23 '25 13:06 romainsacchi

I couldn't check yet due to the errors with unlinked exchanges.

dbantje avatar Jun 24 '25 12:06 dbantje

No, it's is resolved now :)

dbantje avatar Jun 26 '25 13:06 dbantje