eodal.config.settings module

Global eodal settings defining access to metadata DB (eodal.operational modules, only), CREODIAS (optional), Copernicus (optional) and some package-wide file and directory naming defaults. In addition, the module exposes a logger object for package wide-logging (console and file output).

The Settings class uses pydantic. This means all attributes of the class can be overwritten using environmental variables or a .env file.

Copyright (C) 2022, 2023 Lukas Valentin Graf

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

class eodal.config.settings.Settings(_case_sensitive: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_nested_delimiter: str | None = None, _secrets_dir: str | Path | None = None, *, DHUS_USER: str = '', DHUS_PASSWORD: str = '', CREODIAS_USER: str = '', CREODIAS_PASSWORD: str = '', CREODIAS_TOTP_SECRET: str = '', CREODIAS_ZIPPER_URL: str = 'https://zipper.creodias.eu/download', CREODIAS_MAX_RECORDS: int = 2000, PLANET_API_KEY: str = '', ORDERS_URL: str = 'https://api.planet.com/compute/ops/orders/v2', DATA_URL: str = 'https://api.planet.com/data/v1', DB_USER: str = 'postgres', DB_PW: str = 'P@ssW0rd!', DB_HOST: str = 'localhost', DB_PORT: str = '5432', DB_NAME: str = 'metadata_db', DEFAULT_SCHEMA: str = 'cs_sat_s1', ECHO_DB: bool = False, USE_STAC: bool = True, MAX_ITEMS: int = 500, LIMIT_ITEMS: int = 5, STAC_BACKEND: ~typing.Any = <class 'eodal.config.stac_providers.STAC_Providers.MSPC'>, PC_SDK_SUBSCRIPTION_KEY: str = '', STAC_API_IO_CA_BUNDLE: bool = True, NUMBER_HTTPS_RETRIES: int = 5, CURRENT_TIME: str = '20231124-124025', LOGGER_NAME: str = 'eodal', LOG_FORMAT: str = '%(asctime)s %(name)-12s %(levelname)-8s %(message)s', LOG_DIR: str = '/home/docs', LOG_FILE: str = '/home/docs/20231124-124025_eodal.log', LOGGING_LEVEL: int = 20, TEMP_WORKING_DIR: ~pathlib.Path = PosixPath('/tmp'), logger: ~logging.Logger = <Logger eodal (WARNING)>)[source]

Bases: BaseSettings

The eodal setting class. Allows to modify default settings and behavior of the package using a .env file or environmental variables

CREODIAS_MAX_RECORDS: int
CREODIAS_PASSWORD: str
CREODIAS_TOTP_SECRET: str
CREODIAS_USER: str
CREODIAS_ZIPPER_URL: str
CURRENT_TIME: str
DATA_URL: str
DB_HOST: str
DB_NAME: str
DB_PORT: str
DB_PW: str
DB_USER: str
DEFAULT_SCHEMA: str
DHUS_PASSWORD: str
DHUS_USER: str
ECHO_DB: bool
LIMIT_ITEMS: int
LOGGER_NAME: str
LOGGING_LEVEL: int
LOG_DIR: str
LOG_FILE: str
LOG_FORMAT: str
MAX_ITEMS: int
NUMBER_HTTPS_RETRIES: int
ORDERS_URL: str
PC_SDK_SUBSCRIPTION_KEY: str
PLANET_API_KEY: str
STAC_API_IO_CA_BUNDLE: bool
STAC_BACKEND: Any
TEMP_WORKING_DIR: Path
USE_STAC: bool
get_logger()[source]

returns a logger object with stream and file handler

logger: logging.Logger
model_config: ClassVar[SettingsConfigDict] = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'env_file': None, 'env_file_encoding': None, 'env_nested_delimiter': None, 'env_prefix': '', 'extra': 'forbid', 'protected_namespaces': ('model_', 'settings_'), 'secrets_dir': None, 'validate_default': True}

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

model_fields: ClassVar[dict[str, FieldInfo]] = {'CREODIAS_MAX_RECORDS': FieldInfo(annotation=int, required=False, default=2000), 'CREODIAS_PASSWORD': FieldInfo(annotation=str, required=False, default=''), 'CREODIAS_TOTP_SECRET': FieldInfo(annotation=str, required=False, default=''), 'CREODIAS_USER': FieldInfo(annotation=str, required=False, default=''), 'CREODIAS_ZIPPER_URL': FieldInfo(annotation=str, required=False, default='https://zipper.creodias.eu/download'), 'CURRENT_TIME': FieldInfo(annotation=str, required=False, default='20231124-124025'), 'DATA_URL': FieldInfo(annotation=str, required=False, default='https://api.planet.com/data/v1'), 'DB_HOST': FieldInfo(annotation=str, required=False, default='localhost'), 'DB_NAME': FieldInfo(annotation=str, required=False, default='metadata_db'), 'DB_PORT': FieldInfo(annotation=str, required=False, default='5432'), 'DB_PW': FieldInfo(annotation=str, required=False, default='P@ssW0rd!'), 'DB_USER': FieldInfo(annotation=str, required=False, default='postgres'), 'DEFAULT_SCHEMA': FieldInfo(annotation=str, required=False, default='cs_sat_s1'), 'DHUS_PASSWORD': FieldInfo(annotation=str, required=False, default=''), 'DHUS_USER': FieldInfo(annotation=str, required=False, default=''), 'ECHO_DB': FieldInfo(annotation=bool, required=False, default=False), 'LIMIT_ITEMS': FieldInfo(annotation=int, required=False, default=5), 'LOGGER_NAME': FieldInfo(annotation=str, required=False, default='eodal'), 'LOGGING_LEVEL': FieldInfo(annotation=int, required=False, default=20), 'LOG_DIR': FieldInfo(annotation=str, required=False, default='/home/docs'), 'LOG_FILE': FieldInfo(annotation=str, required=False, default='/home/docs/20231124-124025_eodal.log'), 'LOG_FORMAT': FieldInfo(annotation=str, required=False, default='%(asctime)s %(name)-12s %(levelname)-8s %(message)s'), 'MAX_ITEMS': FieldInfo(annotation=int, required=False, default=500), 'NUMBER_HTTPS_RETRIES': FieldInfo(annotation=int, required=False, default=5), 'ORDERS_URL': FieldInfo(annotation=str, required=False, default='https://api.planet.com/compute/ops/orders/v2'), 'PC_SDK_SUBSCRIPTION_KEY': FieldInfo(annotation=str, required=False, default=''), 'PLANET_API_KEY': FieldInfo(annotation=str, required=False, default=''), 'STAC_API_IO_CA_BUNDLE': FieldInfo(annotation=bool, required=False, default=True), 'STAC_BACKEND': FieldInfo(annotation=Any, required=False, default=<class 'eodal.config.stac_providers.STAC_Providers.MSPC'>), 'TEMP_WORKING_DIR': FieldInfo(annotation=Path, required=False, default=PosixPath('/tmp')), 'USE_STAC': FieldInfo(annotation=bool, required=False, default=True), 'logger': FieldInfo(annotation=Logger, required=False, default=<Logger eodal (WARNING)>)}

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

This replaces Model.__fields__ from Pydantic V1.

eodal.config.settings.get_settings()[source]

loads package settings using last-recently-used cache