Skip to content

Commit

Permalink
add env conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaiPetukhov committed Dec 17, 2024
1 parent 5bccbc2 commit 6ba6a32
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions agent/worker/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ def get_optional_defaults():
return _OPTIONAL_DEFAULTS.copy()


def read_optional_setting(name):
return os.getenv(name, _OPTIONAL_DEFAULTS[name])
def read_optional_setting(name, postprocess_fn = None):
value = os.getenv(name, _OPTIONAL_DEFAULTS[name])
if postprocess_fn is not None:
return postprocess_fn(value)
return value


def HOST_DIR():
Expand Down Expand Up @@ -544,7 +547,7 @@ def DISABLE_TELEMETRY():


def REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS():
return read_optional_setting(_REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS)
return read_optional_setting(_REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS, lambda x: int(x))


def AGENT_ID():
Expand Down

0 comments on commit 6ba6a32

Please sign in to comment.