USEPA / ElectricityLCI

Creative Commons Zero v1.0 Universal
24 stars 10 forks source link

Cannot import model_specs after change in model config handling #148

Closed WesIngwersen closed 4 years ago

WesIngwersen commented 4 years ago

This code now fails because model_specs is not defined https://github.com/USEPA/ElectricityLCI/blob/2232c41f2cb4fd333ad59c8710aa55906e6a7ed3/electricitylci/eia923_generation.py#L9

It seems when this change was made https://github.com/USEPA/ElectricityLCI/commit/587a093cf4b62cf316b61017a1d05dfe7adbdced#diff-31f24fa7269e7b74b1866eb183ffb1b9

that the import handling was not all updated

WesIngwersen commented 4 years ago

@bl-young can you respond to this

m-jamieson commented 4 years ago

Are you calling eia923_generation.py directly from some other code? main.py should build model_specs here. If you do want to call directly, you'll need some other code:

import electricitylci.model_config as config
config.model_specs=config.build_model_class("ELCI_1")
# or config.model_specs=config.build_model_class() to get prompted.
bl-young commented 4 years ago

Correct - the original challenge was that you couldn't access individual modules outside of running the entire code, so the change implemented allows for pulling specific modules directly. As Matt said, you end up needing an extra line or two to specify the model_specs before you can access those.

See the conversation here: https://github.com/USEPA/ElectricityLCI/pull/128#issue-455439423

bl-young commented 4 years ago

I'm sure this needs to be updated in the wiki

WesIngwersen commented 4 years ago

OK thanks. This is helpful. yes a wiki update would be great. I will close this issue