Skip to content

Commit 504a392

Browse files
committed
standardize env var properties on Config class
1 parent e577b1e commit 504a392

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lambdas/config.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# ruff: noqa: EM102, TRY003
2+
13
import logging
24
import os
35
from typing import Any, ClassVar
@@ -46,11 +48,19 @@ def get_verbose_flag(verbose: bool | str) -> bool: # noqa: FBT001
4648

4749
@property
4850
def alma_export_bucket(self) -> str:
49-
return os.environ["TIMDEX_ALMA_EXPORT_BUCKET_ID"]
51+
var = "TIMDEX_ALMA_EXPORT_BUCKET_ID"
52+
value = os.getenv(var)
53+
if not value:
54+
raise OSError(f"Env var '{var}' must be defined")
55+
return value
5056

5157
@property
5258
def timdex_bucket(self) -> str:
53-
return os.environ["TIMDEX_S3_EXTRACT_BUCKET_ID"]
59+
var = "TIMDEX_S3_EXTRACT_BUCKET_ID"
60+
value = os.getenv(var)
61+
if not value:
62+
raise OSError(f"Env var '{var}' must be defined")
63+
return value
5464

5565
@property
5666
def s3_timdex_dataset_data_location(self) -> str:

0 commit comments

Comments
 (0)