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

Write current model state when run fails #484

Open
shartgring opened this issue Oct 14, 2024 · 1 comment
Open

Write current model state when run fails #484

shartgring opened this issue Oct 14, 2024 · 1 comment

Comments

@shartgring
Copy link
Collaborator

shartgring commented Oct 14, 2024

Feature type

Adding new functionality

Improvement Description

When a run fails, it now has to be restarted for the full run period. It might be useful to write the current model state as state output given that state.path_output exists in the config. This will give the option to restart the model with the state of the last timestep

Implementation Description

Would it be possible to 'catch' the error and run a function? Or will an error/exception inevitably mean that no function can be run after the error is catched? Or is this behaviour not supported/desired in Julia

Additional Context

No response

@visr
Copy link
Member

visr commented Oct 14, 2024

This should be possible, we already do some logging on a crash:

Wflow.jl/src/Wflow.jl

Lines 169 to 178 in 37ae6dd

catch e
# avoid logging backtrace for the single line FEWS log format
# that logger also uses SimpleLogger which doesn't result in a good backtrace
if fews_run
@error "Wflow simulation failed" exception = e _id = :wflow_run
else
@error "Wflow simulation failed" exception = (e, catch_backtrace()) _id =
:wflow_run
end
rethrow()

That could be expanded to write the state as well.

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

No branches or pull requests

2 participants