omero_connect.omero_connect()

Decorator that handles OMERO connection lifecycle management.

Usage

Source

omero_connect.omero_connect(func)

This decorator automatically establishes a connection to an OMERO server using credentials from environment variables, passes the connection object to the decorated function, and ensures proper cleanup by closing the connection afterward, even if an exception occurs.

Parameters

func: Callable[…, Any]
The function to be decorated. The decorated function must accept a ‘conn’ keyword argument that will receive the OMERO connection.

Returns

Callable[…, Any]
Callable[…, Any]: A wrapper function that handles the OMERO connection lifecycle.

Raises

ConnectionError

If connection to the OMERO server fails or if there are credential issues

Exception
Other exceptions from the decorated function are passed through