Skip to content

Commit

Permalink
feat: add filter_dependency flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Romazes committed Oct 1, 2024
1 parent 326e616 commit 8fcd385
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lean/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ def __init__(self, config_json_object):
self._is_required_from_user = False
self._save_persistently_in_lean = False
self._log_message: str = ""
self.has_filter_dependency: bool = False
if "log-message" in config_json_object.keys():
self._log_message = config_json_object["log-message"]
if "filters" in config_json_object.keys():
self._filter = Filter(config_json_object["filters"])
self.has_filter_dependency = Filter.has_conditions
else:
self._filter = Filter([])
self._input_default = config_json_object["input-default"] if "input-default" in config_json_object else None
Expand Down Expand Up @@ -137,6 +139,10 @@ def __init__(self, filter_conditions):
self._conditions: List[BaseCondition] = [BaseCondition.factory(
condition["condition"]) for condition in filter_conditions]

@property
def has_conditions(self) -> bool:
"""Returns True if there are any conditions, False otherwise."""
return bool(self._conditions)

class InfoConfiguration(Configuration):
"""Configuration class used for informational configurations.
Expand Down
8 changes: 6 additions & 2 deletions lean/models/json_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ def get_id(self):

def sort_configs(self) -> List[Configuration]:
sorted_configs = []
filter_configs = []
brokerage_configs = []
for config in self._lean_configs:
if isinstance(config, BrokerageEnvConfiguration):
brokerage_configs.append(config)
else:
sorted_configs.append(config)
return brokerage_configs + sorted_configs
if config.has_filter_dependency:
filter_configs.append(config)
else:
sorted_configs.append(config)
return brokerage_configs + sorted_configs + filter_configs

def get_name(self) -> str:
"""Returns the user-friendly name which users can identify this object by.
Expand Down

0 comments on commit 8fcd385

Please sign in to comment.