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

Logging in BaseModel.from_config methods. #436

Open
davidorme opened this issue Jun 7, 2024 · 0 comments
Open

Logging in BaseModel.from_config methods. #436

davidorme opened this issue Jun 7, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@davidorme
Copy link
Collaborator

Describe the bug

I've been going over the Variables PR #431 to try and push it along now that @vgro has broken the back of the update.

  • I've updated all the variable descriptions
  • I've updated all the model required vars sections.
  • I'm going through the example log (which very helpfully prints out what data gets checked and set at each step - aren't we clever!) to validate all of the sections.

But as part of going through the log, I noticed a difference between the PlantsModel.from_config() and everything else. The other models do this (for example):

LOGGER.info(
"Information required to initialise the litter model successfully "
"extracted."
)
return cls(
data=data,
core_components=core_components,
model_constants=model_constants,
)

Plants does this:

# Try and create the instance - safeguard against exceptions from __init__
try:
inst = cls(
data=data,
core_components=core_components,
flora=flora,
model_constants=model_constants,
)
except Exception as excep:
LOGGER.critical(
f"Error creating plants model from configuration: {excep!s}"
)
raise excep
LOGGER.info("Plants model instance generated from configuration.")
return inst

Okay - so that is a little paranoid but there is a practical difference in the logging output. With plants, there is a message after all the init logging indicating model success. The other models report an intermediate step - they only claim to have extracted the information needed - but the messages read a bit like the __init__ has completed and then are followed by all the logging messages.

I think we should shift to using a Plants like setup for all model - it makes the logs clearer - but we should be consistent either way.

To Reproduce

Run ve_example and look at the log.

@davidorme davidorme added the bug Something isn't working label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant