Skip to content

Commit

Permalink
minor refactor of constants function
Browse files Browse the repository at this point in the history
  • Loading branch information
skrawcz committed Nov 18, 2024
1 parent 69d12f3 commit 80c24fa
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ui/sdk/src/hamilton_sdk/tracking/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ def _load_config(config_location: str) -> configparser.ConfigParser:
file_config = _load_config(DEFAULT_CONFIG_LOCATION)


def _convert_to_type(val: str) -> Any:
if not isinstance(val, str): # guard
return val
if val.isdigit():
def _convert_to_type(val_: str) -> Any:
if not isinstance(val_, str): # guard
return val_
if val_.isdigit():
# convert to int
val = int(val)
elif val.lower() in {"true", "false"}:
val_ = int(val_)
elif val_.lower() in {"true", "false"}:
# convert to bool
val = val.lower() == "true"
val_ = val_.lower() == "true"
else:
try: # check if float
val = float(val)
val_ = float(val_)
except ValueError:
pass
return val
return val_


# loads from config file and overwrites
Expand Down

0 comments on commit 80c24fa

Please sign in to comment.