Skip to content

Commit

Permalink
Allow empty strings as default json module input values (#370)
Browse files Browse the repository at this point in the history
* Allow empty strings as default json module input values

* Minor fix

* Minor change
  • Loading branch information
jhonabreul authored Oct 6, 2023
1 parent 50aa531 commit 5e62db1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lean/commands/live/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def _raise_for_missing_properties(lean_config: Dict[str, Any], environment_name:
:param lean_config_path: the path to the LEAN configuration file
"""
brokerage_configurer, data_feed_configurers = _get_configurable_modules_from_environment(lean_config, environment_name)
brokerage_properties = brokerage_configurer.get_required_properties()
brokerage_properties = brokerage_configurer.get_required_properties(include_optionals=False)
data_queue_handler_properties = []
for data_feed_configurer in data_feed_configurers:
data_queue_handler_properties.extend(data_feed_configurer.get_required_properties())
data_queue_handler_properties.extend(data_feed_configurer.get_required_properties(include_optionals=False))
required_properties = list(set(brokerage_properties + data_queue_handler_properties))
missing_properties = [p for p in required_properties if p not in lean_config or lean_config[p] == ""]
missing_properties = set(missing_properties)
Expand Down
15 changes: 9 additions & 6 deletions lean/models/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,21 @@ def __init__(self, config_json_object):
self._save_persistently_in_lean = True
self._input_method = self._prompt_info = self._help = ""
self._input_default = self._cloud_id = None
if "input-method" in config_json_object.keys():
self._optional = False
if "input-method" in config_json_object:
self._input_method = config_json_object["input-method"]
if "prompt-info" in config_json_object.keys():
if "prompt-info" in config_json_object:
self._prompt_info = config_json_object["prompt-info"]
if "help" in config_json_object.keys():
if "help" in config_json_object:
self._help = config_json_object["help"]
if "input-default" in config_json_object.keys():
if "input-default" in config_json_object:
self._input_default = config_json_object["input-default"]
if "cloud-id" in config_json_object.keys():
if "cloud-id" in config_json_object:
self._cloud_id = config_json_object["cloud-id"]
if "save-persistently-in-lean" in config_json_object.keys():
if "save-persistently-in-lean" in config_json_object:
self._save_persistently_in_lean = config_json_object["save-persistently-in-lean"]
if "optional" in config_json_object:
self._optional = config_json_object["optional"]

@abstractmethod
def ask_user_for_input(self, default_value, logger: Logger, hide_input: bool = False):
Expand Down
15 changes: 10 additions & 5 deletions lean/models/json_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,18 @@ def get_non_user_required_properties(self) -> List[str]:
return [config._id for config in self._lean_configs if not config._is_required_from_user and not
config._is_type_configurations_env and self.check_if_config_passes_filters(config)]

def get_required_properties(self, filters: List[Type[Configuration]] = []) -> List[str]:
return [config._id for config in self.get_required_configs(filters)]

def get_required_configs(self, filters: List[Type[Configuration]] = []) -> List[Configuration]:
def get_required_properties(self,
filters: List[Type[Configuration]] = [],
include_optionals: bool = True) -> List[str]:
return [config._id for config in self.get_required_configs(filters, include_optionals)]

def get_required_configs(self,
filters: List[Type[Configuration]] = [],
include_optionals: bool = True) -> List[Configuration]:
required_configs = [copy(config) for config in self._lean_configs if config._is_required_from_user
and type(config) not in filters
and self.check_if_config_passes_filters(config)]
and self.check_if_config_passes_filters(config)
and (include_optionals or not getattr(config, '_optional', False))]
return required_configs

def get_persistent_save_properties(self, filters: List[Type[Configuration]] = []) -> List[str]:
Expand Down

0 comments on commit 5e62db1

Please sign in to comment.