Skip to content

config

This submodule defines constant values and definitions from the OPTIMADE specification for use by the validator.

The VALIDATOR_CONFIG object can be imported and modified before calling the validator inside a Python script to customise the hardcoded values.

ValidatorConfig (BaseSettings) pydantic-model

This class stores validator config parameters in a way that can be easily modified for testing niche implementations. Many of these fields are determined by the specification directly, but it may be desirable to modify them in certain cases.

Source code in optimade/validator/config.py
class ValidatorConfig(BaseSettings):
    """This class stores validator config parameters in a way that
    can be easily modified for testing niche implementations. Many
    of these fields are determined by the specification directly,
    but it may be desirable to modify them in certain cases.

    """

    response_classes: dict[str, Any] = Field(
        _RESPONSE_CLASSES,
        description="Dictionary containing the mapping between endpoints and response classes for the main database",
    )

    response_classes_index: dict[str, Any] = Field(
        _RESPONSE_CLASSES_INDEX,
        description="Dictionary containing the mapping between endpoints and response classes for the index meta-database",
    )

    entry_schemas: dict[str, Any] = Field(
        _ENTRY_SCHEMAS, description="The entry listing endpoint schemas"
    )

    entry_endpoints: set[str] = Field(
        _ENTRY_ENDPOINTS,
        description="The entry endpoints to validate, if present in the API's `/info` response `entry_types_by_format['json']`",
    )

    unique_properties: set[str] = Field(
        _UNIQUE_PROPERTIES,
        description=(
            "Fields that should be treated as unique indexes for all endpoints, "
            "i.e. fields on which filters should return at most one entry."
        ),
    )

    inclusive_operators: dict[DataType, set[str]] = Field(
        _INCLUSIVE_OPERATORS,
        description=(
            "Dictionary mapping OPTIMADE `DataType`s to a list of operators that are 'inclusive', "
            "i.e. those that should return entries with the matching value from the filter."
        ),
    )

    exclusive_operators: dict[DataType, set[str]] = Field(
        _EXCLUSIVE_OPERATORS,
        description=(
            "Dictionary mapping OPTIMADE `DataType`s to a list of operators that are 'exclusive', "
            "i.e. those that should not return entries with the matching value from the filter."
        ),
    )

    field_specific_overrides: dict[str, dict[SupportLevel, Container[str]]] = Field(
        _FIELD_SPECIFIC_OVERRIDES,
        description=(
            "Some fields do not require all type comparison operators to be supported. "
            "This dictionary allows overriding the list of supported operators for a field, using "
            "the field name as a key, and the support level of different operators with a subkey. "
            "Queries on fields listed in this way will pass the validator provided the server returns a 501 status."
        ),
    )

    links_endpoint: str = Field("links", description="The name of the links endpoint")
    versions_endpoint: str = Field(
        "versions", description="The name of the versions endpoint"
    )

    info_endpoint: str = Field("info", description="The name of the info endpoint")
    non_entry_endpoints: set[str] = Field(
        _NON_ENTRY_ENDPOINTS,
        description="The list specification-mandated endpoint names that do not contain entries",
    )
    top_level_non_attribute_fields: set[str] = Field(
        BaseResourceMapper.TOP_LEVEL_NON_ATTRIBUTES_FIELDS,
        description="Field names to treat as top-level",
    )

    enum_fallback_values: dict[str, dict[str, list[str]]] = Field(
        _ENUM_DUMMY_VALUES,
        description="Provide fallback values for enum fields to use when validating filters.",
    )

entry_endpoints: set pydantic-field

The entry endpoints to validate, if present in the API's /info response entry_types_by_format['json']

entry_schemas: dict pydantic-field

The entry listing endpoint schemas

enum_fallback_values: dict pydantic-field

Provide fallback values for enum fields to use when validating filters.

exclusive_operators: dict pydantic-field

Dictionary mapping OPTIMADE DataTypes to a list of operators that are 'exclusive', i.e. those that should not return entries with the matching value from the filter.

field_specific_overrides: dict pydantic-field

Some fields do not require all type comparison operators to be supported. This dictionary allows overriding the list of supported operators for a field, using the field name as a key, and the support level of different operators with a subkey. Queries on fields listed in this way will pass the validator provided the server returns a 501 status.

inclusive_operators: dict pydantic-field

Dictionary mapping OPTIMADE DataTypes to a list of operators that are 'inclusive', i.e. those that should return entries with the matching value from the filter.

info_endpoint: str pydantic-field

The name of the info endpoint

The name of the links endpoint

non_entry_endpoints: set pydantic-field

The list specification-mandated endpoint names that do not contain entries

response_classes: dict pydantic-field

Dictionary containing the mapping between endpoints and response classes for the main database

response_classes_index: dict pydantic-field

Dictionary containing the mapping between endpoints and response classes for the index meta-database

top_level_non_attribute_fields: set pydantic-field

Field names to treat as top-level

unique_properties: set pydantic-field

Fields that should be treated as unique indexes for all endpoints, i.e. fields on which filters should return at most one entry.

versions_endpoint: str pydantic-field

The name of the versions endpoint