hydromt.model.Model.__enter__#

Model.__enter__() Model[source]#

Enter the model runtime context.

This allows the model to be used as a context manager in a with block. The method returns the model instance itself, enabling setup and write operations to be performed within the block.

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.
Returns:

The model instance.

Return type:

Model