matrice.utils module#

matrice.utils.check_for_duplicate(session, service, name)[source]#

Check if an item with the given name already exists for the specified service.

Parameters:
  • service (str) – The name of the service to check (e.g., ‘dataset’, ‘annotation’, ‘model_export’).

  • name (str) – The name of the item to check for duplication.

Returns:

A tuple containing three elements: - API response (dict): The raw response from the API. - error_message (str or None): Error message if an error occurred, None otherwise. - status_message (str): A status message indicating success or failure.

Return type:

tuple

Example

>>> resp, err, msg = check_for_duplicate('dataset', 'MyDataset')
>>> if err:
>>>     print(f"Error: {err}")
>>> else:
>>>     print(f"Duplicate check result: {resp}")
matrice.utils.get_summary(session, project_id, service_name)[source]#

Fetch a summary of the specified service in the project.

Parameters:
  • rpc (object) – The RPC client instance.

  • project_id (str) – The project ID.

  • service_name (str) – The name of the service to fetch the summary for. Valid values are ‘annotations’, ‘models’, ‘exports’, ‘deployments’, ‘experiments’.

Returns:

A tuple containing: - The summary data if the request is successful. - An error message if the request fails.

Return type:

tuple

Example

>>> summary, error = get_summary(rpc, project_id, 'models')
>>> if error:
>>>     print(f"Error: {error}")
>>> else:
>>>     print(f"Summary: {summary}")
matrice.utils.handle_response(response, success_message, failure_message)[source]#
matrice.utils.log_error(self, filename, function_name, error_message)[source]#

“This function logs error to be-system.