Skip to content

Commit

Permalink
specify we are pulling a boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-weirather committed Sep 17, 2024
1 parent 9866329 commit 1a3778d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions comfy_cli/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@ def set(self, key, value):
"""
Set a key-value pair in the config file.
"""
self.config["DEFAULT"][key] = value
self.config["DEFAULT"][key] = str(value)
self.write_config() # Write changes to file immediately

def get(self, key):
def get(self, key, type_cast=str):
"""
Get a value from the config file. Returns None if the key does not exist.
"""
return self.config["DEFAULT"].get(key, None) # Returns None if the key does not exist
value = self.config["DEFAULT"].get(key, None) # Returns None if the key does not exist

# Handle boolean conversion
if type_cast == bool:
return value.lower() in ("true", "yes", "1")

return type_cast(value)

def load(self):
config_file_path = self.get_config_file_path()
Expand Down
2 changes: 1 addition & 1 deletion comfy_cli/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def track_event(event_name: str, properties: any = None):
if properties is None:
properties = {}
logging.debug(f"tracking event called with event_name: {event_name} and properties: {properties}")
enable_tracking = config_manager.get(constants.CONFIG_KEY_ENABLE_TRACKING)
enable_tracking = config_manager.get(constants.CONFIG_KEY_ENABLE_TRACKING, type_cast=bool)
if not enable_tracking:
return

Expand Down

0 comments on commit 1a3778d

Please sign in to comment.