matrice.session module#

Module for Session class handling project sessions.

class matrice.session.Session(account_number, access_key, secret_key, project_id=None, project_name=None)[source]#

Bases: object

Class to manage sessions.

Initialize a new session instance.

Parameters:
  • account_number (str) – The account number associated with the session.

  • project_id (str, optional) – The ID of the project for this session.

Example

>>> session = Session(account_number="9625383462734064921642156")
__init__(account_number, access_key, secret_key, project_id=None, project_name=None)[source]#
close()[source]#

Close the current session by resetting the RPC and project details.

Example

>>> session.close()
create_classification_project(project_name)[source]#

Create a classification project.

Parameters:

project_name (str) – The name of the classification project to be created.

Returns:

An instance of the Projects class for the created project, or None if an error occurred.

Return type:

Projects

Example

>>> project = session.create_classification_project("Image Classification Project")
>>> if project:
>>>     print(f"Created project: {project}")
>>> else:
>>>     print("Could not create project.")
create_detection_project(project_name)[source]#

Create a detection project.

Parameters:

project_name (str) – The name of the detection project to be created.

Returns:

An instance of the Projects class for the created project, or None if an error occurred.

Return type:

Projects

Example

>>> project = session.create_detection_project("Object Detection Project")
>>> if project:
>>>     print(f"Created project: {project}")
>>> else:
>>>     print("Could not create project.")
create_segmentation_project(project_name)[source]#

Create a segmentation project.

Parameters:

project_name (str) – The name of the segmentation project to be created.

Returns:

An instance of the Projects class for the created project, or None if an error occurred.

Return type:

Projects

Example

>>> project = session.create_segmentation_project("Instance Segmentation Project")
>>> if project:
>>>     print(f"Created project: {project}")
>>> else:
>>>     print("Could not create project.")
create_session(access_key, secret_key)[source]#

Create and initialize a new session with specified credentials.

Parameters:
  • account_number (str) – The account number to associate with the new session.

  • access_key (str) – The access key for authentication.

  • secret_key (str) – The secret key for authentication.

Returns:

An instance of the Session class initialized with the given credentials.

Return type:

Session

Example

>>> session = create_session("9625383462734064921642156", "HREDGFXB6KI0TWH6UZEYR", "UY8LP0GQRKLSFPZAW1AUF")
>>> print(session)
<Session object at 0x...>
get_project_type_summary()[source]#

Get the count of different types of projects.

Returns:

A tuple containing: - A dictionary with project types as keys and their counts as values if the request is successful. - An error message if the request fails.

Return type:

tuple

Example

>>> project_summary, error = session.get_project_type_summary()
>>> if error:
>>>     print(f"Error: {error}")
>>> else:
>>>     print(f"Project type summary: {project_summary}")
list_projects(project_type='', page_size=10, page_number=0)[source]#

List projects based on the specified type.

Parameters:

project_type (str, optional) – The type of projects to list (e.g., ‘classification’, ‘detection’). If empty, all projects are listed.

Returns:

A tuple containing the dictionary of projects and a message indicating the result of the fetch operation.

Return type:

tuple

Example

>>> projects, message = session.list_projects("classification")
>>> print(message)
Projects fetched successfully
>>> for project_name, project_instance in projects.items():
>>>     print(project_name, project_instance)
refresh()[source]#

Refresh the instance by reinstantiating it with the previous values.

update(project_id)[source]#

Update the session with new project details.

Parameters:

project_id (str, optional) – The new ID of the project.

Example

>>> session.update(project_id="660b96fc019dd5321fd4f8c7")