Skip to content

Variables

AppConfig

Bases: BaseSettings

Pydantic model of the Prefect Variables config

Parameters:

Name Type Description Default
BaseSettings _type_

description

required
Source code in backend/archiver/config/variables.py
11
12
13
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
class AppConfig(BaseSettings):
    """Pydantic model of the Prefect Variables config

    Args:
        BaseSettings (_type_): _description_

    """
    model_config = SettingsConfigDict(
        env_file_encoding="utf-8",
        case_sensitive=True,
        extra="forbid",
        validate_default=True,
    )

    MINIO_REGION: str = ""
    MINIO_USER: str = ""
    MINIO_PASSWORD: str = ""
    MINIO_RETRIEVAL_BUCKET: str = ""
    MINIO_STAGING_BUCKET: str = ""
    MINIO_LANDINGZONE_BUCKET: str = ""
    MINIO_URL: str = ""

    API_ROOT_PATH: str = ""
    API_PORT: int = 0
    API_LOG_LEVEL: str = ""
    API_RELOAD: bool = False

    LTS_STORAGE_ROOT: Path = Path("")
    ARCHIVER_SCRATCH_FOLDER: Path = Path("")

    SCICAT_ENDPOINT: str = ""
    SCICAT_API_PREFIX: str = ""

Variables

Singleton abstracting access to all Variables expected to be defined in Prefect

Source code in backend/archiver/config/variables.py
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class Variables:
    """Singleton abstracting access to all Variables expected to be defined in Prefect

    """
    _instance = None

    def __new__(cls):
        if cls._instance is None:
            cls._instance = super(Variables, cls).__new__(cls)
        return cls._instance

    def __get(self, name: str) -> str:
        c = None

        # try for local overrides as env variables
        c = os.environ.get(name.upper())
        if c is not None:
            return c

        try:
            c = Variable.get(name)
        finally:
            if c is None or c.value is None:
                return ""
            return c.value

    @property
    def SCICAT_ENDPOINT(self) -> str:
        return self.__get("scicat_endpoint")

    @property
    def SCICAT_API_PREFIX(self) -> str:
        return self.__get("scicat_api_prefix")

    @property
    def MINIO_RETRIEVAL_BUCKET(self) -> str:
        return self.__get("minio_retrieval_bucket")

    @property
    def MINIO_LANDINGZONE_BUCKET(self) -> str:
        return self.__get("minio_landingzone_bucket")

    @property
    def MINIO_STAGING_BUCKET(self) -> str:
        return self.__get("minio_staging_bucket")

    @property
    def MINIO_REGION(self) -> str:
        return self.__get("minio_region")

    @property
    def MINIO_USER(self) -> str:
        return self.__get("minio_user")

    @property
    def MINIO_PASSWORD(self) -> str:
        return self.__get("minio_password")

    @property
    def MINIO_URL(self) -> str:
        return self.__get("minio_url")

    @property
    def ARCHIVER_SCRATCH_FOLDER(self) -> Path:
        return Path(self.__get("archiver_scratch_folder"))

    @property
    def LTS_STORAGE_ROOT(self) -> Path:
        return Path(self.__get("lts_storage_root"))