veriflow.datasources.base#
Module with the base class that all datasources should inherit from.
Classes
|
Class to inherit from, defines the required methods and attributes. |
|
Base config for a datasource config. |
- class veriflow.datasources.base.BaseDatasource(config)[source]#
Class to inherit from, defines the required methods and attributes.
- Parameters:
config (BaseDatasourceConfig)
- config_class#
alias of
BaseDatasourceConfig
- property spatial_type: SpatialType#
Spatial structure (point/gridded) of the datasource’s data.
- abstract property configured_stations: set[str] | None#
Return the standardized internal station identifiers configured for this datasource.
This standardized format is needed for caching across different datasources. If your datasource implementation does not have any configurable stations, return None.
- abstract property configured_variables: set[str] | None#
Return the standardized internal variable identifiers configured for this datasource.
This standardized format is needed for caching across different datasources. If your datasource implementation does not have any configurable variables, return None.
- property configured_variables_internal: set[str] | None#
Return the standardized internal variable identifiers configured for this datasource.
This standardized format is needed for caching across different datasources. If your datasource implementation does not have any configurable variables, return None.
- fetch_available_forecast_reference_time_period()[source]#
Return the period actually available from the source right now, if resolvable.
Used to clamp an open-ended/rolling configured verification period (e.g. “up to now”) to what the source can currently serve, so operational runs don’t fail by requesting data that hasn’t been produced (yet) or has fallen outside the source’s retention. Returns None by default, meaning the configured verification period is used as-is.
When implemented, this method is used during caching. In a standard veriflow run, the period for which to fetch data is defined in the configuration. However, the actual available period from the datasource may differ, and this method allows Veriflow to adjust the verification period accordingly. As a result, we never request data outside the source’s actual availability and the cache is only updated with new data if it is available in the datasource.
- Return type:
TimePeriod | None
- clamp_verification_period_on_frt_to_available_period(available)[source]#
Clamp the configured verification period to the source’s currently available period.
- Parameters:
available (TimePeriod)
- Return type:
None
- validate_fetched_data()[source]#
Validate that the dataset is consistent with the config.
- Return type:
None
- filter_dataset(dataset)[source]#
Filter the dataset on lead times and times outside the verification period.
- classmethod from_config(raw_config)#
Initialize class from config dict.
- fetch_validate_filter_cache(*, clear_cache=False)[source]#
High-level wrapper to fetch, validate, filter and apply id mapping to the dataset.
- create_cache_request(cached_dataset)[source]#
Get the cache request based on the cached dataset and the config.
- Parameters:
cached_dataset (Dataset)
- Return type:
- static get_cached_data(cached_dataset, datasource)[source]#
Get the dataset from the cache based on the datasource configuration.
- Parameters:
cached_dataset (Dataset)
datasource (BaseDatasource)
- Return type:
- class veriflow.datasources.base.BaseDatasourceConfig(*, import_adapter, source_id, data_type, spatial_type=SpatialType.point, general, id_mapping=None, **extra_data)[source]#
Base config for a datasource config.
Specific config definitions should inherit from this base class.
- Parameters:
import_adapter (str)
source_id (Annotated[str, StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=1, max_length=None, pattern=^[A-Za-z][A-Za-z0-9_]*$, ascii_only=None), MinLen(min_length=1)])
data_type (DataType)
spatial_type (SpatialType)
general (Annotated[GeneralInfoConfig, SkipJsonSchema()])
id_mapping (Annotated[IdMappingConfig, SkipJsonSchema()] | None)
extra_data (Any)
- source_id: ", metadata=[MinLen(min_length=1)])]#
- spatial_type: SpatialType#
- general: Annotated[GeneralInfoConfig, SkipJsonSchema()]#
- id_mapping: Annotated[IdMappingConfig, SkipJsonSchema()] | None#
- property verification_period: TimePeriod#
- property verification_period_on_frt: TimePeriod#
- property verification_period_on_time: TimePeriod#