CloudUploadSettings
The settings for uploading data into the GCP cloud storage. These apply for each individual upload. These settings overwrite the encord.http.constants.RequestsSettings() which is set during encord.EncordUserClient creation.
class encord.http.utils.CloudUploadSettings(max_retries=None, backoff_factor=None, allow_failures=False)
max_retries: Optional[int] = None
Number of allowed retries when uploading
backoff_factor: Optional[float] = None
With each retry, there is a sleep of backoff_factor * (2 ** (retry_number - 1) )
allow_failures: bool = False
If failures are allowed, the upload continues even if some items were not successfully uploaded even after retries. For example, upon creation of a large image group, you might want to create the image group even if a few images were not successfully uploaded. The unsuccessfully uploaded images are then logged.
@dataclass
class CloudUploadSettings:
"""
The settings for uploading data into the GCP cloud storage. These apply for each individual upload. These settings
will overwrite the encord.http.constants.RequestsSettings which is set during
`encord.EncordUserClient` creation.
"""
max_retries: Optional[int] = None
"""Number of allowed retries when uploading"""
backoff_factor: Optional[float] = None
"""With each retry, there will be a sleep of backoff_factor * (2 ** (retry_number - 1) )"""
allow_failures: bool = False
"""
If failures are allowed, the upload will continue even if some items were not successfully uploaded even
after retries. For example, upon creation of a large image group, you might want to create the image group
even if a few images were not successfully uploaded. The unsuccessfully uploaded images will then be logged.
"""
RequestsSettings
The settings for all outgoing network requests. These apply for each individual request.
class encord.http.constants.RequestsSettings(max_retries=3, backoff_factor=1.5, connection_retries=3, connect_timeout=180, read_timeout=180, write_timeout=180)
max_retries: int = 3
Number of allowed retries when a request is sent. It only affects idempotent retryable requests.
backoff_factor: float = 1.5
With each retry, there is a sleep of backoff_factor * (2 ** (retry_number - 1) )
connection_retries: int = 3
Number of allowed retries to establish TCP connection when a request is sent.
connect_timeout: int = 180
Maximum number of seconds from connection establishment to the first byte of response received.
read_timeout: int = 180
Maximum number of seconds to obtain full response.
write_timeout: int = 180
Maximum number of seconds to send request payload.
from dataclasses import dataclass
DEFAULT_CONNECTION_RETRIES = 3
DEFAULT_MAX_RETRIES = 3
DEFAULT_BACKOFF_FACTOR = 1.5
DEFAULT_READ_TIMEOUT = 180 # In seconds
DEFAULT_WRITE_TIMEOUT = 180 # In seconds
DEFAULT_CONNECT_TIMEOUT = 180 # In seconds
@dataclass
class RequestsSettings:
"""
The settings for all outgoing network requests. These apply for each individual request.
"""
max_retries: int = DEFAULT_MAX_RETRIES
"""Number of allowed retries when a request is sent. It only affects idempotent retryable requests."""
backoff_factor: float = DEFAULT_BACKOFF_FACTOR
"""With each retry, there will be a sleep of backoff_factor * (2 ** (retry_number - 1) )"""
connection_retries: int = DEFAULT_CONNECTION_RETRIES
"""Number of allowed retries to establish TCP connection when a request is sent."""
connect_timeout: int = DEFAULT_CONNECT_TIMEOUT
"""Maximum number of seconds from connection establishment to the first byte of response received"""
read_timeout: int = DEFAULT_READ_TIMEOUT
"""Maximum number of seconds to obtain full response"""
write_timeout: int = DEFAULT_WRITE_TIMEOUT
"""Maximum number of seconds to send request payload"""
DEFAULT_REQUESTS_SETTINGS = RequestsSettings()
get_all_model_iteration_uids
A convenience function that works well with encord.project.Project.list_models().
encord.utilities.project_utilities.get_all_model_iteration_uids(model_configurations)
Return type
Set[str]
from typing import List, Set
from encord.orm.model import ModelConfiguration
[docs]def get_all_model_iteration_uids(model_configurations: List[ModelConfiguration]) -> Set[str]:
"""A convenience function that works well with :meth:`encord.project.Project.list_models`"""
model_iteration_uids = set()
for model_configuration in model_configurations:
model_iteration_uids.update(model_configuration.model_iteration_uids)
return model_iteration_uids
DataType
An enumeration.
class encord.constants.enums.DataType(value)
- VIDEO = 'video'
- IMG_GROUP = 'img_group'
- DICOM = 'dicom'
- IMAGE = 'image'
- DICOM_STUDY = 'dicom_study'
- MISSINGDATA_TYPE = '_MISSING_DATA_TYPE'
from __future__ import annotations
from typing import Any
from encord.common.enum import StringEnum
[docs]class DataType(StringEnum):
VIDEO = "video"
IMG_GROUP = "img_group"
DICOM = "dicom"
IMAGE = "image"
DICOM_STUDY = "dicom_study"
# will be displayed if the Encord platform has a new data type that is not present in this SDK version. Please upgrade your SDK version
MISSING_DATA_TYPE = "_MISSING_DATA_TYPE_"
@classmethod
def _missing_(cls, value: Any) -> DataType:
return cls.MISSING_DATA_TYPE
[docs] @staticmethod
def from_upper_case_string(string: str) -> DataType:
for data_type in DataType:
if string == data_type.to_upper_case_string():
return data_type
return DataType.MISSING_DATA_TYPE
[docs] def to_upper_case_string(self) -> str:
return self.value.upper()
from_upper_case_string
static from_upper_case_string(string)
Return type:
@staticmethod
def from_upper_case_string(string: str) -> DataType:
for data_type in DataType:
if string == data_type.to_upper_case_string():
return data_type
return DataType.MISSING_DATA_TYPE
to_upper_case_string
to_upper_case_string()
Return type:
str
def to_upper_case_string(self) -> str:
return self.value.upper()