Types#
This section provides an overview of the various types and classes used within the eodag library. It includes details about the core types, download arguments, and specialized data structures like XarrayDict for handling geospatial data efficiently.
EODAG types
- class eodag.types.__init__.BaseModelCustomJsonSchema(**data)[source]#
Base class for generated models with custom json schema.
- Parameters:
data (
Any)
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class eodag.types.__init__.ProviderSortables[source]#
A class representing sortable parameter(s) of a provider and the allowed maximum number of used sortable(s) in a search request with the provider
- Parameters:
sortables – The list of sortable parameter(s) of a provider
max_sort_params – (optional) The allowed maximum number of sortable(s) in a search request with the provider
- class eodag.types.__init__.S3SessionKwargs[source]#
A class representing available keyword arguments to pass to
boto3.session.Sessionfor authentication
- eodag.types.__init__.annotated_dict_to_model(model_name, annotated_fields)[source]#
Convert a dictionary of Annotated values to a Pydantic BaseModel.
>>> from pydantic import Field >>> annotated_fields = { ... "field1": Annotated[str, Field(description="A string field"), "json_schema_required"], ... "field2": Annotated[int, Field(default=42, description="An integer field")], ... } >>> model = annotated_dict_to_model("TestModel", annotated_fields) >>> json_schema = model.model_json_schema() >>> json_schema["required"] ['field1'] >>> json_schema["properties"]["field1"] {'description': 'A string field', 'title': 'Field1', 'type': 'string'} >>> json_schema["properties"]["field2"] {'default': 42, 'description': 'An integer field', 'title': 'Field2', 'type': 'integer'} >>> json_schema["title"] 'TestModel' >>> json_schema["type"] 'object'
- eodag.types.__init__.json_field_definition_to_python(json_field_definition, default_value=None, required=False)[source]#
Get python field definition from json object
>>> result = json_field_definition_to_python( ... { ... 'type': 'boolean', ... 'title': 'Foo parameter' ... } ... ) >>> res_repr = str(result).replace('_extensions', '') # python3.8 compatibility >>> res_repr = res_repr.replace(', default=None', '') # pydantic >= 2.7.0 compatibility >>> res_repr "typing.Annotated[bool, FieldInfo(annotation=NoneType, required=False, title='Foo parameter')]"
- eodag.types.__init__.json_type_to_python(json_type)[source]#
Get python type from json type https://spec.openapis.org/oas/v3.1.0#data-types
>>> json_type_to_python("number") <class 'float'>
- eodag.types.__init__.model_fields_to_annotated(model_fields)[source]#
Convert BaseModel.model_fields from FieldInfo to Annotated
>>> from pydantic import create_model >>> some_model = create_model("some_model", foo=(str, None)) >>> fields_definitions = model_fields_to_annotated(some_model.model_fields) >>> fd_repr = str(fields_definitions).replace('_extensions', '') # python3.8 compatibility >>> fd_repr = fd_repr.replace(', default=None', '') # pydantic >= 2.7.0 compatibility >>> fd_repr "{'foo': typing.Annotated[str, FieldInfo(annotation=NoneType, required=False)]}"
- eodag.types.__init__.python_field_definition_to_json(python_field_definition)[source]#
Get json field definition from python typing.Annotated
>>> from pydantic import Field >>> from typing import Annotated >>> python_field_definition_to_json( ... Annotated[ ... Optional[str], ... Field(None, description='Foo bar', json_schema_extra={'$ref': '/path/to/schema'}) ... ] ... ) {'type': ['string', 'null'], 'description': 'Foo bar', '$ref': '/path/to/schema'}
- eodag.types.__init__.python_type_to_json(python_type)[source]#
Get json type from python https://spec.openapis.org/oas/v3.1.0#data-types
>>> python_type_to_json(int) 'integer' >>> python_type_to_json(Union[float, str]) [{'type': 'number'}, {'type': 'string'}]
- class eodag.types.download_args.DownloadConf[source]#
Download configuration
- Variables:
output_dir – where to store downloaded products, as an absolute file path (Default: local temporary directory)
output_extension – downloaded file extension
extract – whether to extract the downloaded products, only applies to archived products
dl_url_params – additional parameters to pass over to the download url as an url parameter
delete_archive – whether to delete the downloaded archives
asset – regex filter to identify assets to download
- class eodag_cube.types.XarrayDict(dict=None, /, **kwargs)[source]#
Dictionnary that stores as values independant
xarray.Datasethaving various dimensions.Example#
>>> import xarray >>> XarrayDict({ ... "foo": xarray.Dataset.from_dict( ... { ... "x": {"dims": ("x"), "data": [0, 1]}, ... "a": {"dims": ("x"), "data": [10, 20]} ... } ... ), ... "bar": xarray.Dataset.from_dict( ... { ... "y": {"dims": ("y"), "data": [0, 1, 2]}, ... "b": {"dims": ("y"), "data": [10, 20, 30]} ... } ... ) ... }) <XarrayDict> (2) {'foo': <xarray.Dataset> (x: 2) Size: 32B, 'bar': <xarray.Dataset> (y: 3) Size: 48B}