otx.api.utils.argument_checks#

Utils for checking functions and methods arguments.

Functions

check_dictionary_keys_values_type(parameter, ...)

Function raises ValueError exception if dictionary key or value has unexpected type.

check_directory_path(parameter, parameter_name)

Function to check directory path string objects.

check_file_extension(file_path, ...)

Function raises ValueError exception if file has unexpected extension.

check_file_path(parameter, parameter_name, ...)

Function to check file path string objects.

check_input_parameters_type([custom_checks])

Decorator to check input parameters type.

check_is_parameter_like_dataset(parameter, ...)

Checks if the parameter is like a dataset.

check_nested_classes_parameters(parameter, ...)

Function to check type of parameters with nested elements.

check_nested_elements_type(iterable, ...)

Function raises ValueError exception if one of elements in collection has unexpected type.

check_parameter_type(parameter, ...)

Function extracts nested expected types and raises ValueError exception if parameter has unexpected type.

check_that_all_characters_printable(...[, ...])

Function raises ValueError if one of string-parameter characters is not printable.

check_that_file_exists(file_path, file_path_name)

Function raises ValueError exception if file not exists.

check_that_null_character_absents_in_string(...)

Function raises ValueError exception if null character: '0' is specified in path to file.

check_that_parameter_is_not_empty(parameter, ...)

Function raises ValueError if parameter is empty.

get_bases(parameter)

Function to get set of all base classes of parameter.

get_parameter_repr(parameter)

Function to get parameter representation.

raise_value_error_if_parameter_has_unexpected_type(...)

Function raises ValueError exception if parameter has unexpected type.

Classes

BaseInputArgumentChecker()

Abstract class to check input arguments.

DatasetParamTypeCheck(parameter, parameter_name)

Class to check DatasetEntity-type parameters.

DirectoryPathCheck(parameter, parameter_name)

Class to check directory path parameters.

FilePathCheck(parameter, parameter_name, ...)

Class to check file_path-like parameters.

InputConfigCheck(parameter, parameter_name)

Class to check input config_parameters.

JsonFilePathCheck(parameter, parameter_name)

Class to check optional yaml file path parameters.

OptionalDirectoryPathCheck(parameter, ...)

Class to check optional directory path parameters.

OptionalFilePathCheck(parameter, ...)

Class to check optional file_path-like parameters.

OptionalImageFilePathCheck(parameter, ...)

Class to check optional image file path parameters.

YamlFilePathCheck(parameter, parameter_name)

Class to check optional yaml file path parameters.

class otx.api.utils.argument_checks.BaseInputArgumentChecker[source]#

Bases: ABC

Abstract class to check input arguments.

abstract check()[source]#

Abstract method to check input arguments.

class otx.api.utils.argument_checks.DatasetParamTypeCheck(parameter, parameter_name)[source]#

Bases: BaseInputArgumentChecker

Class to check DatasetEntity-type parameters.

check()[source]#

Method raises ValueError exception if parameter is not equal to Dataset.

class otx.api.utils.argument_checks.DirectoryPathCheck(parameter, parameter_name)[source]#

Bases: BaseInputArgumentChecker

Class to check directory path parameters.

check()[source]#

Method raises ValueError exception if directory path parameter is not equal to expected.

class otx.api.utils.argument_checks.FilePathCheck(parameter, parameter_name, expected_file_extension)[source]#

Bases: BaseInputArgumentChecker

Class to check file_path-like parameters.

check()[source]#

Method raises ValueError exception if file path parameter is not equal to expected.

class otx.api.utils.argument_checks.InputConfigCheck(parameter, parameter_name)[source]#

Bases: BaseInputArgumentChecker

Class to check input config_parameters.

check()[source]#

Method raises ValueError exception if “input_config” parameter is not equal to expected.

class otx.api.utils.argument_checks.JsonFilePathCheck(parameter, parameter_name)[source]#

Bases: FilePathCheck

Class to check optional yaml file path parameters.

class otx.api.utils.argument_checks.OptionalDirectoryPathCheck(parameter, parameter_name)[source]#

Bases: BaseInputArgumentChecker

Class to check optional directory path parameters.

check()[source]#

Method raises ValueError exception if directory path parameter is not equal to expected.

class otx.api.utils.argument_checks.OptionalFilePathCheck(parameter, parameter_name, expected_file_extension)[source]#

Bases: BaseInputArgumentChecker

Class to check optional file_path-like parameters.

check()[source]#

Method raises ValueError exception if file path parameter is not equal to expected.

class otx.api.utils.argument_checks.OptionalImageFilePathCheck(parameter, parameter_name)[source]#

Bases: OptionalFilePathCheck

Class to check optional image file path parameters.

class otx.api.utils.argument_checks.YamlFilePathCheck(parameter, parameter_name)[source]#

Bases: FilePathCheck

Class to check optional yaml file path parameters.

otx.api.utils.argument_checks.check_dictionary_keys_values_type(parameter, parameter_name, expected_key_class, expected_value_class)[source]#

Function raises ValueError exception if dictionary key or value has unexpected type.

otx.api.utils.argument_checks.check_directory_path(parameter, parameter_name)[source]#

Function to check directory path string objects.

otx.api.utils.argument_checks.check_file_extension(file_path: str, file_path_name: str, expected_extensions: list)[source]#

Function raises ValueError exception if file has unexpected extension.

otx.api.utils.argument_checks.check_file_path(parameter, parameter_name, expected_file_extensions)[source]#

Function to check file path string objects.

otx.api.utils.argument_checks.check_input_parameters_type(custom_checks: dict | None = None)[source]#

Decorator to check input parameters type.

Parameters:

custom_checks – dictionary where key - name of parameter and value - custom check class

otx.api.utils.argument_checks.check_is_parameter_like_dataset(parameter, parameter_name)[source]#

Checks if the parameter is like a dataset.

Function raises ValueError exception if parameter does not have __len__, __getitem__ and get_subset attributes of DataSet-type object.

otx.api.utils.argument_checks.check_nested_classes_parameters(parameter, parameter_name, origin_class, nested_elements_class)[source]#

Function to check type of parameters with nested elements.

otx.api.utils.argument_checks.check_nested_elements_type(iterable, parameter_name, expected_type)[source]#

Function raises ValueError exception if one of elements in collection has unexpected type.

otx.api.utils.argument_checks.check_parameter_type(parameter, parameter_name, expected_type)[source]#

Function extracts nested expected types and raises ValueError exception if parameter has unexpected type.

otx.api.utils.argument_checks.check_that_all_characters_printable(parameter, parameter_name, allow_crlf=False)[source]#

Function raises ValueError if one of string-parameter characters is not printable.

otx.api.utils.argument_checks.check_that_file_exists(file_path: str, file_path_name: str)[source]#

Function raises ValueError exception if file not exists.

otx.api.utils.argument_checks.check_that_null_character_absents_in_string(parameter: str, parameter_name: str)[source]#

Function raises ValueError exception if null character: ‘0’ is specified in path to file.

otx.api.utils.argument_checks.check_that_parameter_is_not_empty(parameter, parameter_name)[source]#

Function raises ValueError if parameter is empty.

otx.api.utils.argument_checks.get_bases(parameter) set[source]#

Function to get set of all base classes of parameter.

otx.api.utils.argument_checks.get_parameter_repr(parameter) str[source]#

Function to get parameter representation.

otx.api.utils.argument_checks.raise_value_error_if_parameter_has_unexpected_type(parameter, parameter_name, expected_type)[source]#

Function raises ValueError exception if parameter has unexpected type.