-
Notifications
You must be signed in to change notification settings - Fork 6
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
Run a single model for a single timestep #404
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Prefer extracting single-step run method, and calling it from scheduler at each step. Seems a simpler implementation, rather than threading this run-single-step behaviour top-down through the scheduler. This reverts commit 4d92ac5.
This defers model (class/wrapper implementations of SectorModel) loading to a single place, just before calling model.simulate or model.before_model_run, and gives a relatively simple method to call to run a model for a single step. Towards having a 'smif run single-model-single-step' CLI command, and also in support of model/scheduler environment separation.
Fixes circular import and emphasises the two routes into running models: - execute_run reads a full model run configuration and then schedules all steps to run to completion - execute_step runs a single model for a single step and assumes that all preceding steps have run (e.g. previous timestep has run, other models have produced necessary outputs)
To mirror simulate and before_model_run, and to avoid too many arguments/options for each.
Print a summary of individual (decide/before_step/step) commands in a runnable order.
These are the only runnable items - scenarios and scenario dependencies are useful in knowing data dependencies but are irrelevant for run order.
Enable further work in making DecisionManager resumable - that is, run 'smif decide modelrun --decision 0' then run the models, then run 'smif decide modelrun --decision 1' to set up some further decisions for further simulation, and so on.
Run 'smif run <modelrun> --dry-run' to see how to use these subcommands to step through running a model run. Essentially there are three steps: - 'smif decide' sets up decisions and reports on the timesteps and decisions that the DecisionManager says should run - 'smif before_step' initialises a model - this should only need to be run once per modelrun, and not all models do work in this step - 'smif step' runs a single model for a single timestep and single decision, setting up the data handle and calling Model.simulate
This is unused - may be worth stripping out if there are no active plans to develop database backend.
With round-trip testing and in particular single-level MultiIndex handling.
Codecov Report
@@ Coverage Diff @@
## master #404 +/- ##
==========================================
- Coverage 70.91% 70.85% -0.06%
==========================================
Files 64 65 +1
Lines 5717 5758 +41
Branches 730 736 +6
==========================================
+ Hits 4054 4080 +26
- Misses 1559 1572 +13
- Partials 104 106 +2
Continue to review full report at Codecov.
|
- ~4x speed-up (from about 2m to 30s) - uses pytest capsys fixture to capture stdout and stderr - quirk with logging means that object loggers seem to get disabled after repeated calls to setup_logging. Fix for now is to call logging.info() directly in the one case that would otherwise fail (checking jobs run by serail_job_scheduler).
tomalrussell
force-pushed
the
feature/run_once
branch
from
February 28, 2020 09:23
cde1b0b
to
5705532
Compare
tomalrussell
changed the title
[WIP] Run a single model for a single timestep
Run a single model for a single timestep
Feb 28, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This will close #402 - work in progress.
The main thing here is the introduction of new smif CLI subcommands.
Run
smif run <modelrun> --dry-run
to see how to use these subcommands tostep through running a model run.
Essentially there are three steps:
smif decide
sets up decisions and reports on the timesteps and decisionsthat the DecisionManager says should run
smif before_step
initialises a model - this should only need to be run onceper modelrun, and not all models do work in this step
smif step
runs a single model for a single timestep and single decision,setting up the data handle and calling Model.simulate
TODO: