Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix publish_data defaulting to opt_res_latest, tweak warning logs. #375

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions src/emhass/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,25 +798,30 @@
if os.path.exists(entity_path) and len(os.listdir(entity_path)) > 0:
# Obtain all files in entity_path
entity_path_contents = os.listdir(entity_path)
for entity in entity_path_contents:
if entity != "metadata.json":
# If publish_prefix is "all" publish all saved entities to Home Assistant
# If publish_prefix matches the prefix from saved entities, publish to Home Assistant
if publish_prefix in entity or publish_prefix == "all":
entity_data = publish_json(entity,input_data_dict,entity_path,logger)
if not isinstance(entity_data, bool):
opt_res_list.append(entity_data)
opt_res_list_names.append(entity.replace(".json", ""))
else:
return False
# Build a DataFrame with published entities
opt_res = pd.concat(opt_res_list, axis=1)
opt_res.columns = opt_res_list_names
return opt_res
# Confirm the entity path contains at least one file containing publish prefix or publish_prefix='all'
if any(publish_prefix in entity for entity in entity_path_contents) or publish_prefix == "all":
# Loop through all items in entity path
for entity in entity_path_contents:
# If publish_prefix is "all" publish all saved entities to Home Assistant
# If publish_prefix matches the prefix from saved entities, publish to Home Assistant
if entity != "metadata.json" and (publish_prefix in entity or publish_prefix == "all"):
entity_data = publish_json(entity,input_data_dict,entity_path,logger)
if not isinstance(entity_data, bool):
opt_res_list.append(entity_data)
opt_res_list_names.append(entity.replace(".json", ""))
else:
return False
# Build a DataFrame with published entities
opt_res = pd.concat(opt_res_list, axis=1)
opt_res.columns = opt_res_list_names
return opt_res
else:
logger.warning("No saved entity json files that match prefix: " + str(publish_prefix))

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (secret)
as clear text.
This expression logs
sensitive data (secret)
as clear text.
This expression logs
sensitive data (secret)
as clear text.
This expression logs
sensitive data (secret)
as clear text.
This expression logs
sensitive data (private)
as clear text.
This expression logs
sensitive data (private)
as clear text.
This expression logs
sensitive data (secret)
as clear text.
logger.warning("Falling back to opt_res_latest")
else:
logger.warning("no saved entity json files in path:" + str(entity_path))
logger.warning("falling back to opt_res_latest")
filename = "opt_res_latest.csv"
logger.warning("No saved entity json files in path:" + str(entity_path))
logger.warning("Falling back to opt_res_latest")
filename = "opt_res_latest.csv"
else:
filename = "opt_res_latest.csv"
if opt_res_latest is None:
Expand Down
4 changes: 2 additions & 2 deletions src/emhass/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ def treat_runtimeparams(runtimeparams: str, params: str, retrieve_hass_conf: dic
historic_days_to_retrieve = runtimeparams.get(
'historic_days_to_retrieve', runtimeparams.get('days_to_retrieve'))
if historic_days_to_retrieve < 9:
logger.warning("warning `days_to_retrieve` is set to a value less than 9, this could cause an error with the fit")
logger.warning("setting`passed_data:days_to_retrieve` to 9 for fit/predict/tune")
logger.warning("`days_to_retrieve` is set to a value less than 9, this could cause an error with the fit")
logger.warning("setting fit/predict/tune `days_to_retrieve` to 9")
historic_days_to_retrieve = 9
params["passed_data"]['historic_days_to_retrieve'] = historic_days_to_retrieve
if "model_type" not in runtimeparams.keys():
Expand Down
Loading