Skip to content

triplestoreconfig

Pydantic TripleStore Configuration Data Model.

ExcludeTogglableSecretStr = Annotated[Optional[TogglableSecretStr], Field(exclude=True)] module-attribute

Annotated type alias for excluding a togglable secret from serialization.

TripleStoreConfig

Bases: GenericConfig, SecretConfig

TripleStore Configuration.

This is a configuration for the TripleStore.

This class should not be used directly as a configuration object for a strategy object, but only as a configuration field inside a configuration object.

Source code in oteapi/models/triplestoreconfig.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class TripleStoreConfig(GenericConfig, SecretConfig):
    """TripleStore Configuration.

    This is a configuration for the
    [`TripleStore`][oteapi.triplestore.triplestore.TripleStore].

    This class should not be used directly as a configuration object
    for a strategy object, but only as a configuration field inside
    a configuration object.
    """

    repositoryName: str = Field(
        ..., description="The repository name, where the mappings are stored."
    )
    agraphHost: str = Field(..., description="AllegroGraph host name.")
    agraphPort: int = Field(..., description="AllegroGraph port number.")

    # Exclude these inherited fields from serialization
    token: Annotated[ExcludeTogglableSecretStr, SecretConfig.model_fields["token"]] = (
        SecretConfig.model_fields["token"].default
    )
    client_id: Annotated[
        ExcludeTogglableSecretStr, SecretConfig.model_fields["client_id"]
    ] = SecretConfig.model_fields["client_id"].default
    client_secret: Annotated[
        ExcludeTogglableSecretStr, SecretConfig.model_fields["client_secret"]
    ] = SecretConfig.model_fields["client_secret"].default

    @model_validator(mode="after")
    def ensure_user_pass(self) -> "TripleStoreConfig":
        """Ensure that user/password are set, since they are optional in the
        SecretConfig."""
        if not all(getattr(self, _) for _ in ["user", "password"]):
            raise ValueError("User and password must be defined.")
        return self

agraphHost: str = Field(..., description='AllegroGraph host name.') class-attribute instance-attribute

agraphPort: int = Field(..., description='AllegroGraph port number.') class-attribute instance-attribute

client_id: Annotated[ExcludeTogglableSecretStr, SecretConfig.model_fields[client_id]] = SecretConfig.model_fields['client_id'].default class-attribute instance-attribute

client_secret: Annotated[ExcludeTogglableSecretStr, SecretConfig.model_fields[client_secret]] = SecretConfig.model_fields['client_secret'].default class-attribute instance-attribute

repositoryName: str = Field(..., description='The repository name, where the mappings are stored.') class-attribute instance-attribute

token: Annotated[ExcludeTogglableSecretStr, SecretConfig.model_fields[token]] = SecretConfig.model_fields['token'].default class-attribute instance-attribute

ensure_user_pass()

Ensure that user/password are set, since they are optional in the SecretConfig.

Source code in oteapi/models/triplestoreconfig.py
42
43
44
45
46
47
48
@model_validator(mode="after")
def ensure_user_pass(self) -> "TripleStoreConfig":
    """Ensure that user/password are set, since they are optional in the
    SecretConfig."""
    if not all(getattr(self, _) for _ in ["user", "password"]):
        raise ValueError("User and password must be defined.")
    return self