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

Add progress option to ve_run #403

Merged
merged 6 commits into from
Mar 4, 2024
Merged

Conversation

davidorme
Copy link
Collaborator

Description

This PR adds a simple optional progress report to ve_run, so that something happens when the command runs and logging is being sent to file (which is likely all reasonable use cases).

When ve_run is executed with --progress, a user sees:

Starting Virtual Ecosystem simulation.
* Logging to: /tmp/ve_example/out/logfile.log
* Loading configuration
* Saved compiled configuration: /tmp/ve_example/out/vr_full_model_configuration.toml
* Built core model components
* Initial data loaded
* Models initialised: plants, animals, litter, hydrology, abiotic_simple, soil
* Starting simulation
100%|███████████████████████████████████████████| 24/24 [00:06<00:00,  3.52it/s]
* Simulation completed
* Merged time series data
* Saved final model state
VR run complete.

Fixes #402

There are probably more elegant ways of handling the tqdm progress bar, but tqdm is usually used with a for loop rather than while. We could explicitly loop over the known number of updates at the moment, but retaining the current while timing loop is a useful implicit reminder that updates might not always be synchronised.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist

  • Make sure you've run the pre-commit checks: $ pre-commit run -a
  • All tests pass: $ poetry run pytest

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@davidorme davidorme linked an issue Mar 4, 2024 that may be closed by this pull request
@davidorme
Copy link
Collaborator Author

Just spotted the VR in VR run complete.

@davidorme davidorme requested review from jacobcook1995, dalonsoa and vgro and removed request for jacobcook1995 March 4, 2024 10:50
Copy link
Collaborator

@dalonsoa dalonsoa left a comment

Choose a reason for hiding this comment

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

It looks good, but I don't really understand the reason for not using a for loop directly with tqdm, as usual, given that you know exactly the number of steps beforehand.

@davidorme
Copy link
Collaborator Author

I think we are using while because the original conception of the model had a kind of event stack - not everything happened on a synchronised tick with a fixed set of update times. I think that is something we may want to bring back in at some point. But ultimately, although a for loop would work better with tqdm here, I wanted to keep the changes simple.

@davidorme davidorme merged commit c94cef6 into develop Mar 4, 2024
17 checks passed
@davidorme davidorme deleted the 402-add-progress-option-to-ve_run branch March 4, 2024 13:29
@davidorme davidorme mentioned this pull request Mar 4, 2024
7 tasks
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.

Add progress option to ve_run
2 participants