hydromt.model.Model.__exit__#

Model.__exit__(exc_type, exc_value, traceback) None[source]#

Exit the model runtime context.

Ensures that resources associated with the model are properly released when leaving a with block, even if an exception occurred during its execution. This method delegates cleanup to close().

Example

with Model(root="path/to/model") as model: # This is where __enter__ is called
    model.setup_x()
    model.setup_y()
    model.write()
# Exiting the with block will call __exit__, ensuring resources are cleaned up.
Parameters:
  • exc_type (type or None) – The type of the exception raised in the with block, or None if no exception occurred.

  • exc_value (BaseException or None) – The exception instance raised in the with block, or None.

  • traceback (types.TracebackType or None) – The traceback object associated with the exception, or None.