geti_sdk.rest_converters
Introduction
The rest_converters package contains methods for serializing and deserializing
entities, using the data models defined in the data_models
module.
The rest converters are used in the rest_clients
.
Module contents
- class geti_sdk.rest_converters.ProjectRESTConverter
Class that handles conversion of Intel® Geti™ REST output for project entities to objects and vice versa.
- classmethod from_dict(project_input: Dict[str, Any]) Project
Create a Project from a dictionary representing a project, as returned by the /projects endpoint on the Intel® Geti™ platform.
- Parameters:
project_input – Dictionary representing a project, as returned by the Intel® Geti™ server
- Returns:
Project object representing the project given in project_input
- classmethod to_dict(project: Project, deidentify: bool = True) Dict[str, Any]
Convert the project to its dictionary representation. This functions removes database UID’s and optional fields that are None from the output dictionary, to make the output more compact and improve readability.
- Parameters:
project – Project to convert to dictionary
deidentify – True to remove all unique database ID’s from the project and it’s child entities, False to keep the ID’s intact. Defaults to True, which is useful for project import/export
- Returns:
- class geti_sdk.rest_converters.MediaRESTConverter
Class that handles conversion of Intel® Geti™ REST output for media entities to objects and vice versa.
- static from_dict(input_dict: Dict[str, Any], media_type: Type[MediaTypeVar]) MediaTypeVar
Create an instance of type media_type representing a media entity on the Intel® Geti™ server from a dictionary returned by the GETi /media REST endpoints.
- Parameters:
input_dict – Dictionary representing the media entity
media_type – Type of the media entity
- Returns:
Instance of type media_type containing the entity represented in the REST input in input_dict.
- class geti_sdk.rest_converters.AnnotationRESTConverter
Class to convert REST representations of annotations into AnnotationScene entities.
- static to_dict(annotation_scene: AnnotationScene, deidentify: bool = True) Dict[str, Any]
Convert an AnnotationScene to a dictionary. By default, removes any ID fields in the output dictionary
- Parameters:
annotation_scene – AnnotationScene object to convert
deidentify – True to remove any unique database ID fields in the output, False to keep these fields. Defaults to True
- Returns:
Dictionary holding the serialized AnnotationScene data
- static annotation_from_dict(input_dict: Dict[str, Any]) Annotation
Convert a dictionary representing an annotation to an Annotation object.
- Parameters:
input_dict
- Returns:
- static from_dict(annotation_scene: Dict[str, Any]) AnnotationScene
Create an AnnotationScene object from a dictionary returned by the /annotations REST endpoint in the Intel® Geti™ platform.
- Parameters:
annotation_scene – dictionary representing an AnnotationScene, which contains all annotations for a certain media entity
- Returns:
AnnotationScene object
- class geti_sdk.rest_converters.PredictionRESTConverter
Class to convert REST representations of predictions into Prediction entities.
- static from_dict(prediction: Dict[str, Any]) Prediction
Create a Prediction object from a dictionary returned by the /predictions REST endpoint in the Intel® Geti™ platform.
- Parameters:
prediction – dictionary representing a Prediction, which contains all prediction annotations for a certain media entity
- Returns:
Prediction object
- static to_dict(prediction: Prediction, deidentify: bool = True) Dict[str, Any]
Convert a Prediction to a dictionary. By default, removes any ID fields in the output dictionary
- Parameters:
prediction – Prediction object to convert
deidentify – True to remove any unique database ID fields in the output, False to keep these fields. Defaults to True
- Returns:
Dictionary holding the serialized Prediction data
- class geti_sdk.rest_converters.ConfigurationRESTConverter
Class that handles conversion of Intel® Geti™ REST output for configurable parameter entities to objects and vice versa.
- static entity_identifier_from_dict(input_dict: Dict[str, Any]) EntityIdentifier
Create an EntityIdentifier object from an input dictionary.
- Parameters:
input_dict – Dictionary representing an EntityIdentifier in Intel® Geti™
- Returns:
EntityIdentifier object corresponding to the data in input_dict
- static from_dict(input_dict: Dict[str, Any]) ConfigurableParameters
Create a ConfigurableParameters object holding the configurable parameters for an entity in the Intel® Geti™ platform, from a dictionary returned by the /configuration REST endpoints.
- Parameters:
input_dict – Dictionary containing the configurable parameters
- Returns:
ConfigurableParameters instance holding the parameter data
- static task_configuration_from_dict(input_dict: Dict[str, Any]) TaskConfiguration
Create a TaskConfiguration object holding all configurable parameters for a task in an Intel® Geti™ project, from a dictionary returned by the /configuration REST endpoints.
- Parameters:
input_dict – Dictionary containing the configurable parameters for the task
- Returns:
TaskConfiguration instance holding the parameter data
- static configuration_to_minimal_dict(configuration: TaskConfiguration | GlobalConfiguration | FullConfiguration, deidentify: bool = True) Dict[str, Any]
Convert a TaskConfiguration, GlobalConfiguration or FullConfiguration into a dictionary, removing fields that are None or are only relevant to the Intel® Geti™ UI.
- Parameters:
configuration – TaskConfiguration or GlobalConfiguration to convert
deidentify – True to remove all unique database identifiers, False to preserve identifiers. Defaults to True
- Returns:
Dictionary representation of the configuration
- static global_configuration_from_rest(input_: List[Dict[str, Any]] | Dict[str, Any]) GlobalConfiguration
Create a GlobalConfiguration object holding the configurable parameters for all project-wide components in the Intel® Geti™ project, from input from the /configuration/global REST endpoint.
- Parameters:
input – REST response holding the serialized configurable parameters
- Returns:
- static full_configuration_from_rest(input_dict: Dict[str, Any]) FullConfiguration
Convert a dictionary holding the full configuration for an Intel® Geti™ project, as returned by the /configuration endpoint, to an object representation.
- Parameters:
input_dict – Dictionary representing the full project configuration
- Returns:
FullConfiguration instance holding the global and task chain configuration
- static configurable_parameter_list_to_rest(configurable_parameter_list: List[ConfigurableParameters]) Dict[str, List[Dict[str, Any]]]
Convert a list of model hyper parameters to a dictionary that can be sent to the /configuration POST endpoints.
- Parameters:
configurable_parameter_list – List of ConfigurableParameter instances
- Returns:
Dictionary containing: - ‘components’: list of dictionaries representing configurable parameters,
that are conforming to the /configuration REST endpoints
- class geti_sdk.rest_converters.ModelRESTConverter
Class that handles conversion of Intel® Geti™ REST output for media entities to objects and vice versa.
- static model_group_from_dict(input_dict: Dict[str, Any]) ModelGroup
Convert a dictionary representing a model group to a ModelGroup object.
- Parameters:
input_dict – Dictionary representing a model group, as returned by the Intel® Geti™ /model_groups REST endpoint
- Returns:
ModelGroup object corresponding to the data in input_dict
- static model_from_dict(input_dict: Dict[str, Any]) Model
Convert a dictionary representing a model to a Model object.
- Parameters:
input_dict – Dictionary representing a model, as returned by the Intel® Geti™ /model_groups/models REST endpoint
- Returns:
Model object corresponding to the data in input_dict
- static optimized_model_from_dict(input_dict: Dict[str, Any]) OptimizedModel
Convert a dictionary representing an optimized model to a OptimizedModel object.
- Parameters:
input_dict – Dictionary representing an optimized model, as returned by the Intel® Geti™ /model_groups/models REST endpoint
- Returns:
OptimizedModel object corresponding to the data in input_dict
- class geti_sdk.rest_converters.StatusRESTConverter
Class that handles conversion of Intel® Geti™ REST output for status entities to objects
- static from_dict(project_status_dict: Dict[str, Any]) ProjectStatus
Create a ProjectStatus instance from the input dictionary passed in project_status_dict.
- Parameters:
project_status_dict – Dictionary representing the status of a project on the Intel® Geti™ server
- Returns:
ProjectStatus instance, holding the status data contained in project_status_dict
- class geti_sdk.rest_converters.JobRESTConverter
Class that handles conversion of Intel® Geti™ REST output for jobs to objects, and vice-versa
- class geti_sdk.rest_converters.TestResultRESTConverter
Class that handles conversion of Intel® Geti™ REST output for test results to objects, and vice-versa
- static from_dict(result_dict: Dict[str, Any]) TestResult
Create a TestResult instance from the input dictionary passed in result_dict.
- Parameters:
result_dict – Dictionary representing a test result on the Intel® Geti™ server, as returned by the /tests endpoints
- Returns:
TestResult instance, holding the result data contained in result_dict
- class geti_sdk.rest_converters.ProjectRESTConverter
Bases:
object
Class that handles conversion of Intel® Geti™ REST output for project entities to objects and vice versa.
- classmethod from_dict(project_input: Dict[str, Any]) Project
Create a Project from a dictionary representing a project, as returned by the /projects endpoint on the Intel® Geti™ platform.
- Parameters:
project_input – Dictionary representing a project, as returned by the Intel® Geti™ server
- Returns:
Project object representing the project given in project_input
- classmethod to_dict(project: Project, deidentify: bool = True) Dict[str, Any]
Convert the project to its dictionary representation. This functions removes database UID’s and optional fields that are None from the output dictionary, to make the output more compact and improve readability.
- Parameters:
project – Project to convert to dictionary
deidentify – True to remove all unique database ID’s from the project and it’s child entities, False to keep the ID’s intact. Defaults to True, which is useful for project import/export
- Returns:
- class geti_sdk.rest_converters.MediaRESTConverter
Bases:
object
Class that handles conversion of Intel® Geti™ REST output for media entities to objects and vice versa.
- static from_dict(input_dict: Dict[str, Any], media_type: Type[MediaTypeVar]) MediaTypeVar
Create an instance of type media_type representing a media entity on the Intel® Geti™ server from a dictionary returned by the GETi /media REST endpoints.
- Parameters:
input_dict – Dictionary representing the media entity
media_type – Type of the media entity
- Returns:
Instance of type media_type containing the entity represented in the REST input in input_dict.
- class geti_sdk.rest_converters.AnnotationRESTConverter
Bases:
object
Class to convert REST representations of annotations into AnnotationScene entities.
- static to_dict(annotation_scene: AnnotationScene, deidentify: bool = True) Dict[str, Any]
Convert an AnnotationScene to a dictionary. By default, removes any ID fields in the output dictionary
- Parameters:
annotation_scene – AnnotationScene object to convert
deidentify – True to remove any unique database ID fields in the output, False to keep these fields. Defaults to True
- Returns:
Dictionary holding the serialized AnnotationScene data
- static annotation_from_dict(input_dict: Dict[str, Any]) Annotation
Convert a dictionary representing an annotation to an Annotation object.
- Parameters:
input_dict
- Returns:
- static from_dict(annotation_scene: Dict[str, Any]) AnnotationScene
Create an AnnotationScene object from a dictionary returned by the /annotations REST endpoint in the Intel® Geti™ platform.
- Parameters:
annotation_scene – dictionary representing an AnnotationScene, which contains all annotations for a certain media entity
- Returns:
AnnotationScene object
- class geti_sdk.rest_converters.PredictionRESTConverter
Bases:
object
Class to convert REST representations of predictions into Prediction entities.
- static from_dict(prediction: Dict[str, Any]) Prediction
Create a Prediction object from a dictionary returned by the /predictions REST endpoint in the Intel® Geti™ platform.
- Parameters:
prediction – dictionary representing a Prediction, which contains all prediction annotations for a certain media entity
- Returns:
Prediction object
- static to_dict(prediction: Prediction, deidentify: bool = True) Dict[str, Any]
Convert a Prediction to a dictionary. By default, removes any ID fields in the output dictionary
- Parameters:
prediction – Prediction object to convert
deidentify – True to remove any unique database ID fields in the output, False to keep these fields. Defaults to True
- Returns:
Dictionary holding the serialized Prediction data
- class geti_sdk.rest_converters.ConfigurationRESTConverter
Bases:
object
Class that handles conversion of Intel® Geti™ REST output for configurable parameter entities to objects and vice versa.
- static entity_identifier_from_dict(input_dict: Dict[str, Any]) EntityIdentifier
Create an EntityIdentifier object from an input dictionary.
- Parameters:
input_dict – Dictionary representing an EntityIdentifier in Intel® Geti™
- Returns:
EntityIdentifier object corresponding to the data in input_dict
- static from_dict(input_dict: Dict[str, Any]) ConfigurableParameters
Create a ConfigurableParameters object holding the configurable parameters for an entity in the Intel® Geti™ platform, from a dictionary returned by the /configuration REST endpoints.
- Parameters:
input_dict – Dictionary containing the configurable parameters
- Returns:
ConfigurableParameters instance holding the parameter data
- static task_configuration_from_dict(input_dict: Dict[str, Any]) TaskConfiguration
Create a TaskConfiguration object holding all configurable parameters for a task in an Intel® Geti™ project, from a dictionary returned by the /configuration REST endpoints.
- Parameters:
input_dict – Dictionary containing the configurable parameters for the task
- Returns:
TaskConfiguration instance holding the parameter data
- static configuration_to_minimal_dict(configuration: TaskConfiguration | GlobalConfiguration | FullConfiguration, deidentify: bool = True) Dict[str, Any]
Convert a TaskConfiguration, GlobalConfiguration or FullConfiguration into a dictionary, removing fields that are None or are only relevant to the Intel® Geti™ UI.
- Parameters:
configuration – TaskConfiguration or GlobalConfiguration to convert
deidentify – True to remove all unique database identifiers, False to preserve identifiers. Defaults to True
- Returns:
Dictionary representation of the configuration
- static global_configuration_from_rest(input_: List[Dict[str, Any]] | Dict[str, Any]) GlobalConfiguration
Create a GlobalConfiguration object holding the configurable parameters for all project-wide components in the Intel® Geti™ project, from input from the /configuration/global REST endpoint.
- Parameters:
input – REST response holding the serialized configurable parameters
- Returns:
- static full_configuration_from_rest(input_dict: Dict[str, Any]) FullConfiguration
Convert a dictionary holding the full configuration for an Intel® Geti™ project, as returned by the /configuration endpoint, to an object representation.
- Parameters:
input_dict – Dictionary representing the full project configuration
- Returns:
FullConfiguration instance holding the global and task chain configuration
- static configurable_parameter_list_to_rest(configurable_parameter_list: List[ConfigurableParameters]) Dict[str, List[Dict[str, Any]]]
Convert a list of model hyper parameters to a dictionary that can be sent to the /configuration POST endpoints.
- Parameters:
configurable_parameter_list – List of ConfigurableParameter instances
- Returns:
Dictionary containing: - ‘components’: list of dictionaries representing configurable parameters,
that are conforming to the /configuration REST endpoints
- class geti_sdk.rest_converters.ModelRESTConverter
Bases:
object
Class that handles conversion of Intel® Geti™ REST output for media entities to objects and vice versa.
- static model_group_from_dict(input_dict: Dict[str, Any]) ModelGroup
Convert a dictionary representing a model group to a ModelGroup object.
- Parameters:
input_dict – Dictionary representing a model group, as returned by the Intel® Geti™ /model_groups REST endpoint
- Returns:
ModelGroup object corresponding to the data in input_dict
- static model_from_dict(input_dict: Dict[str, Any]) Model
Convert a dictionary representing a model to a Model object.
- Parameters:
input_dict – Dictionary representing a model, as returned by the Intel® Geti™ /model_groups/models REST endpoint
- Returns:
Model object corresponding to the data in input_dict
- static optimized_model_from_dict(input_dict: Dict[str, Any]) OptimizedModel
Convert a dictionary representing an optimized model to a OptimizedModel object.
- Parameters:
input_dict – Dictionary representing an optimized model, as returned by the Intel® Geti™ /model_groups/models REST endpoint
- Returns:
OptimizedModel object corresponding to the data in input_dict
- class geti_sdk.rest_converters.StatusRESTConverter
Bases:
object
Class that handles conversion of Intel® Geti™ REST output for status entities to objects
- static from_dict(project_status_dict: Dict[str, Any]) ProjectStatus
Create a ProjectStatus instance from the input dictionary passed in project_status_dict.
- Parameters:
project_status_dict – Dictionary representing the status of a project on the Intel® Geti™ server
- Returns:
ProjectStatus instance, holding the status data contained in project_status_dict
- class geti_sdk.rest_converters.JobRESTConverter
Bases:
object
Class that handles conversion of Intel® Geti™ REST output for jobs to objects, and vice-versa
- class geti_sdk.rest_converters.TestResultRESTConverter
Bases:
object
Class that handles conversion of Intel® Geti™ REST output for test results to objects, and vice-versa
- static from_dict(result_dict: Dict[str, Any]) TestResult
Create a TestResult instance from the input dictionary passed in result_dict.
- Parameters:
result_dict – Dictionary representing a test result on the Intel® Geti™ server, as returned by the /tests endpoints
- Returns:
TestResult instance, holding the result data contained in result_dict