samgis_web.utilities package¶
Submodules¶
samgis_web.utilities.constants module¶
Project constants
samgis_web.utilities.local_tiles_http_server module¶
- class samgis_web.utilities.local_tiles_http_server.LocalTilesHttpServer(methodName='runTest')[source]¶
Bases:
TestCase
- static http_server(host, port, directory)[source]¶
Function http_server defined within this test class to avoid pytest error “fixture ‘host’ not found”.
- Parameters:
host (
str
) – Either the DNS name or the IP address where the server will listenport (
int
) – number where the server will listen (common ports are 7860 or 8000)directory (
str
) – folder exposed by the http server
Returns:
samgis_web.utilities.type_hints module¶
custom type hints
- class samgis_web.utilities.type_hints.ApiRequestBody(**data)[source]¶
Bases:
BaseModel
Input request validator type (not yet parsed)
-
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] objects.
This replaces Model.__fields__ from Pydantic V1.
-
prompt:
list
[RawPromptPoint
|RawPromptRectangle
]¶
-
source_type:
str
¶
-
zoom:
int
|float
¶
-
debug:
- class samgis_web.utilities.type_hints.ApiResponseBodyFailure(**data)[source]¶
Bases:
BaseModel
SamGIS API Response; handle only case of failure
-
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] objects.
This replaces Model.__fields__ from Pydantic V1.
-
request_id:
str
¶
-
duration_run:
- class samgis_web.utilities.type_hints.ApiResponseBodySuccess(**data)[source]¶
Bases:
ApiResponseBodyFailure
SamGIS API Response; handle both case of success and failure
-
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] objects.
This replaces Model.__fields__ from Pydantic V1.
-
n_predictions:
int
¶
-
n_shapes_geojson:
int
¶
-
geojson:
- class samgis_web.utilities.type_hints.ContentTypes(value, names=<not given>, *values, 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_web.utilities.type_hints.ImagePixelCoordinates[source]¶
Bases:
TypedDict
Image pixel coordinates type
-
x:
int
¶
-
y:
int
¶
-
x:
- class samgis_web.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] objects.
This replaces Model.__fields__ from Pydantic V1.
-
lat:
- class samgis_web.utilities.type_hints.PromptLabel(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Valid prompt label type
- EXCLUDE = 0¶
- INCLUDE = 1¶
- class samgis_web.utilities.type_hints.PromptPointType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
str
,Enum
Segment Anything: validation point prompt type
- point = 'point'¶
- class samgis_web.utilities.type_hints.PromptRectangleType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
str
,Enum
Segment Anything: validation rectangle prompt type
- rectangle = 'rectangle'¶
- class samgis_web.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] objects.
This replaces Model.__fields__ from Pydantic V1.
-
ne:
LatLngDict
¶
-
sw:
LatLngDict
¶
- class samgis_web.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] objects.
This replaces Model.__fields__ from Pydantic V1.
-
type:
PromptPointType
¶
-
data:
- class samgis_web.utilities.type_hints.RawPromptRectangle(**data)[source]¶
Bases:
BaseModel
Input lambda prompt request of type ‘PromptRectangleType’ - rectangle (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]] = {'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] objects.
This replaces Model.__fields__ from Pydantic V1.
-
type:
PromptRectangleType
¶
- class samgis_web.utilities.type_hints.StringPromptApiRequestBody(**data)[source]¶
Bases:
BaseModel
Input lambda request validator type (not yet parsed)
-
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=''), 'source_type': FieldInfo(annotation=str, required=False, default='OpenStreetMap.Mapnik'), 'string_prompt': FieldInfo(annotation=str, required=True), '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] objects.
This replaces Model.__fields__ from Pydantic V1.
-
source_type:
str
¶
-
string_prompt:
str
¶
-
zoom:
int
|float
¶
-
debug:
- class samgis_web.utilities.type_hints.WorldFile(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
StrEnum
Default xyz provider names
- pgw = 'pgw'¶
- tfw = 'tfw'¶
- class samgis_web.utilities.type_hints.XYZDefaultProvidersNames(value, names=<not given>, *values, 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_web.utilities.type_hints.XYZTerrainProvidersNames(value, names=<not given>, *values, 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