Skip to content

Conversation

@fnattino
Copy link
Collaborator

@fnattino fnattino commented Dec 4, 2025

First (small) bit for #25. With this PR, we allow for the in-memory configuration of the engine, without the need to parse a config file every time the engine is initialized.

Copy link
Collaborator Author

@fnattino fnattino Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just an initial placeholder for the "new" diffwofost engine. Right now it is identical to the pcse.engine.Engine, with exception for the use of the Configuration instead of the ConfigurationLoader, with exception for the use of the actual VariableKiosk vs the VariableKioskTestHelper (which allows to set in external variables).

Comment on lines 20 to 22
leaf_dynamics_config = Configuration.from_pcse_config_file(
phy_data_folder / "WOFOST_Leaf_Dynamics.conf"
)
Copy link
Collaborator Author

@fnattino fnattino Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By initializing this here, we load the model configuration file only once for all the tests in this module. But we could even initialize it in-memory as in:

from diffwofost.physical_models.crop.leaf_dynamics import WOFOST_Leaf_Dynamics
leaf_dynamics_config = Configuration(
  CROP=WOFOST_Leaf_Dynamics,
  OUTPUT_VARS=["LAI", "TWLV"]
)

so we could get rid of the .conf files from the testdata folder. What do you think?

Copy link
Collaborator Author

@fnattino fnattino Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we should keep at least one config file in order to test the ability to set up the configuration from a config file - see this test

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! this is exactly what I had in mind 👍 . We should define the config as an object and remove the config files. It is okay to keep one for test purposes, but let's remove them from crop model tests, like leaf_dynamics, root_dynamics, and phenology, thanks!

@fnattino
Copy link
Collaborator Author

fnattino commented Dec 4, 2025

Just realized tests are failing because of a feature introduced which would require Python >= 3.11: https://github.com/WUR-AI/diffWOFOST/pull/59/files#r2589286305 - what do you think @SarahAlidoost ?

@fnattino fnattino marked this pull request as ready for review December 12, 2025 11:05
@fnattino
Copy link
Collaborator Author

Sorry @SarahAlidoost after requesting your review I have made a couple of extra commits - hope you hadn't start to have a look yet and apologies if you did! This is now complete.

# Ignore deprecation warnings from pcse.base.simulationobject
pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning:pcse.base.simulationobject")

phenology_config = Configuration.from_pcse_config_file(phy_data_folder / "WOFOST_Phenology.conf")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's replace this with the config object. This helps users/other developers to know how to use it.

# Ignore deprecation warnings from pcse.base.simulationobject
pytestmark = pytest.mark.filterwarnings("ignore::DeprecationWarning:pcse.base.simulationobject")

root_dynamics_config = Configuration.from_pcse_config_file(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here.

Copy link
Collaborator

@SarahAlidoost SarahAlidoost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fnattino great work! 🥇 just a few minor comments. Also, could you please add config to api_reference.md doc? I will update the notebooks in another branch when fixing #61

@fnattino
Copy link
Collaborator Author

Thanks for the review @SarahAlidoost - I have:

  • removed all but one model config files from the test data folder
  • removed the tests that just checked whether the original PCSE engine could be used
  • update the api_reference.md
    Let me know if you want to have a further look - feel free to merge it otherwise!

@sonarqubecloud
Copy link

@SarahAlidoost SarahAlidoost merged commit 189ccf5 into main Dec 17, 2025
11 checks passed
@SarahAlidoost SarahAlidoost deleted the 25-engine-config-fn branch December 17, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants