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.Session for 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'
Parameters:
  • model_name (str) – name of the model to be created

  • annotated_fields (dict[str, Any]) – dict containing the parameters and annotated values that should become the properties of the model

Return type:

BaseModel

Returns:

pydantic model

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')]"
Parameters:
  • json_field_definition (dict[str, Any]) – the json field definition

  • default_value (Any | None, default: None) – default value of the field

  • required (bool | None, default: False) – if the field is required

Return type:

Any

Returns:

the python field definition

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'>
Parameters:

json_type (str | list[str] | None) – the json type

Return type:

type

Returns:

the python type

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)]}"
Parameters:

model_fields (dict[str, FieldInfo]) – BaseModel.model_fields to convert

Return type:

dict[str, Any]

Returns:

Annotated tuple usable as create_model argument

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'}
Parameters:
  • python_field_annotated – the python field annotated type

  • python_field_definition (Any)

Return type:

dict[str, Any]

Returns:

the json field definition

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'}]
Parameters:

python_type (type) – the python type

Return type:

str | list[dict[str, Any]] | None

Returns:

the json type

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.Dataset having 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}
close()[source]#

Close all datasets and associated file objects

Return type:

None

sort()[source]#

In place sort items by keys

Return type:

None