samgis.utilities package

Submodules

samgis.utilities.constants module

Project constants

samgis.utilities.type_hints module

custom type hints

class samgis.utilities.type_hints.ApiRequestBody(**data)[source]

Bases: BaseModel

Input lambda request validator type (not yet parsed)

bbox: RawBBox
debug: bool
id: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'bbox': FieldInfo(annotation=RawBBox, required=True), 'debug': FieldInfo(annotation=bool, required=False, default=False), 'id': FieldInfo(annotation=str, required=False, default=''), 'prompt': FieldInfo(annotation=list[Union[RawPromptPoint, RawPromptRectangle]], required=True), 'source_type': FieldInfo(annotation=str, required=False, default='OpenStreetMap.Mapnik'), 'zoom': FieldInfo(annotation=Union[int, float], required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

prompt: list[RawPromptPoint | RawPromptRectangle]
source_type: str
zoom: int | float
class samgis.utilities.type_hints.ApiResponseBodyFailure(**data)[source]

Bases: BaseModel

duration_run: float
message: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'duration_run': FieldInfo(annotation=float, required=True), 'message': FieldInfo(annotation=str, required=True), 'request_id': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

request_id: str
class samgis.utilities.type_hints.ApiResponseBodySuccess(**data)[source]

Bases: ApiResponseBodyFailure

geojson: str
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'duration_run': FieldInfo(annotation=float, required=True), 'geojson': FieldInfo(annotation=str, required=True), 'message': FieldInfo(annotation=str, required=True), 'n_predictions': FieldInfo(annotation=int, required=True), 'n_shapes_geojson': FieldInfo(annotation=int, required=True), 'request_id': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

n_predictions: int
n_shapes_geojson: int
class samgis.utilities.type_hints.ContentTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, Enum

Segment Anything: validation point prompt type

APPLICATION_JSON = 'application/json'
TEXT_HTML = 'text/html'
TEXT_PLAIN = 'text/plain'
class samgis.utilities.type_hints.ImagePixelCoordinates[source]

Bases: TypedDict

Image pixel coordinates type

x: int
y: int
class samgis.utilities.type_hints.LatLngDict(**data)[source]

Bases: BaseModel

Generic geographic latitude-longitude type

lat: float
lng: float
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'lat': FieldInfo(annotation=float, required=True), 'lng': FieldInfo(annotation=float, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

class samgis.utilities.type_hints.PromptLabel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

Valid prompt label type

EXCLUDE = 0
INCLUDE = 1
class samgis.utilities.type_hints.PromptPointType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, Enum

Segment Anything: validation point prompt type

point = 'point'
class samgis.utilities.type_hints.PromptRectangleType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: str, Enum

Segment Anything: validation rectangle prompt type

rectangle = 'rectangle'
class samgis.utilities.type_hints.RawBBox(**data)[source]

Bases: BaseModel

Input lambda bbox request type (not yet parsed)

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'ne': FieldInfo(annotation=LatLngDict, required=True), 'sw': FieldInfo(annotation=LatLngDict, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

ne: LatLngDict
sw: LatLngDict
class samgis.utilities.type_hints.RawPromptPoint(**data)[source]

Bases: BaseModel

Input lambda prompt request of type ‘PromptPointType’ - point (not yet parsed)

data: LatLngDict
label: PromptLabel
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'data': FieldInfo(annotation=LatLngDict, required=True), 'label': FieldInfo(annotation=PromptLabel, required=True), 'type': FieldInfo(annotation=PromptPointType, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

type: PromptPointType
class samgis.utilities.type_hints.RawPromptRectangle(**data)[source]

Bases: BaseModel

Input lambda prompt request of type ‘PromptRectangleType’ - rectangle (not yet parsed)

data: RawBBox
get_type_str()[source]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'data': FieldInfo(annotation=RawBBox, required=True), 'type': FieldInfo(annotation=PromptRectangleType, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

type: PromptRectangleType
class samgis.utilities.type_hints.XYZDefaultProvidersNames(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Default xyz provider names

DEFAULT_TILES_NAME = 'openstreetmap.mapnik'
DEFAULT_TILES_NAME_SHORT = 'openstreetmap'
class samgis.utilities.type_hints.XYZTerrainProvidersNames(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: StrEnum

Custom xyz provider names for digital elevation models

MAPBOX_TERRAIN_TILES_NAME = 'mapbox.terrain-rgb'
NEXTZEN_TERRAIN_TILES_NAME = 'nextzen.terrarium'

Module contents

various helpers functions