OMERO helpers¶
Connections¶
omero_annotate_ai.omero.simple_connection.SimpleOMEROConnection
¶
Simple OMERO connection manager with keychain support for passwords.
Initialize the connection manager.
connect
¶
connect(host: str, username: str, password: str, group: str | None = None, secure: bool = True, verbose: bool = True, port: int | None = None) -> Any
Create OMERO connection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
OMERO server host, or a websocket URL ( |
required |
username
|
str
|
OMERO username |
required |
password
|
str
|
OMERO password |
required |
group
|
str | None
|
OMERO group (optional) |
None
|
secure
|
bool
|
Keep data transfer encrypted after login (default True).
|
True
|
verbose
|
bool
|
Print connection messages (default True) |
True
|
port
|
int | None
|
OMERO server port. Ignored for URL hosts, which carry their own. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The connected BlitzGateway. |
Raises:
| Type | Description |
|---|---|
ConnectionFailed
|
The server cannot be reached or the login failed. |
load_config_files
¶
Load configuration from .env, connection history and .ezomero files.
Priority order: .env -> connection history -> .ezomero
The returned dictionary never contains a password. Passwords are only
ever read from the keychain, via :meth:load_password.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary with configuration parameters |
save_password
¶
Save password to keychain with optional expiration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
OMERO server host |
required |
username
|
str
|
OMERO username |
required |
password
|
str
|
OMERO password |
required |
expire_hours
|
int | None
|
Hours until password expires (None = never expires) |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if saved successfully, False otherwise |
load_password
¶
Load password from keychain and check expiration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
OMERO server host |
required |
username
|
str
|
OMERO username |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Password if found and not expired, None otherwise |
Tracking tables and configs¶
omero_annotate_ai.omero.omero_functions.list_annotation_tables
¶
Find all tables attached to a container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
OMERO connection |
required | |
container_type
|
str
|
Type of container ('project', 'dataset', 'plate', 'screen') |
required |
container_id
|
int
|
Container ID to search in |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of dictionaries with table information, sorted newest first |
omero_annotate_ai.omero.omero_functions.read_tracking_table
¶
Read a tracking table (0.5+ only) with link columns named image_id / roi_id.
omero_annotate_ai.omero.omero_functions.read_table_rows
¶
A tracking table's rows.
Raises instead of returning quietly: a resume that cannot read its table must stop, never carry on as if the table were empty.
omero_annotate_ai.omero.omero_functions.find_annotation_config_for_table
¶
The config YAML a training set keeps on OMERO, looked up by table ID.
Returns:
| Type | Description |
|---|---|
AnnotationConfig | None
|
The AnnotationConfig, or None if the set has no config on OMERO. |
Deleting a training set¶
omero_annotate_ai.omero.omero_functions.delete_training_set
¶
delete_training_set(conn, table_id: int, container_type: str | None = None, container_id: int | None = None, dry_run: bool = True, force_others: bool = False) -> dict[str, Any]
Delete a tracking table and everything a run created for it.
Everything is found by ID or by the set's tag
(omero-annotate-ai:<table_id>:), never by name, so another training
set's objects are never touched:
rois: theroi_idof each row, plus ROIs on the set's images whose description carries the tag (uploads a crash left untracked).labels: thelabel_idof each row, plus tagged label files.annotation_inputs: theannotation_input_idof each row.configs: the set's config YAML(s),annotation_config_table_<id>.yaml.table: the tracking table FileAnnotation, deleted last.
Objects are looked up in every group the user can see and deleted in the
table's group. Objects owned by another user (possible in read-write groups)
are listed under others and block the deletion unless force_others
is True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
conn
|
OMERO connection |
required | |
table_id
|
int
|
Tracking table (FileAnnotation) ID |
required |
container_type
|
str | None
|
Container to search for configs; defaults to every container the table is linked to |
None
|
container_id
|
int | None
|
Container ID that goes with |
None
|
dry_run
|
bool
|
When True (default) nothing is deleted; the report says what would be. |
True
|
force_others
|
bool
|
Also delete objects owned by other users. |
False
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Report dict with the IDs per kind, |
dict[str, Any]
|
no longer exist), |
dict[str, Any]
|
|
Raises:
| Type | Description |
|---|---|
PermissionError
|
Objects belong to another user and |
CmdError
|
The server reported an error while deleting, or did not finish in time. |