Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions dripline/core/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def wrapper(self, *args, **kwargs):
val_dict['value_cal'] = cal
elif isinstance(self._calibration, dict):
logger.debug('calibration is dictionary, looking up value')
if val_dict['value_raw'] in self._calibration:
val_dict['value_cal'] = self._calibration[val_dict['value_raw']]
if str(val_dict['value_raw']) in self._calibration:
val_dict['value_cal'] = self._calibration[str(val_dict['value_raw'])]
else:
raise ThrowReply('service_error_invalid_value', f"raw value <{repr(val_dict['value_raw'])}> not in cal dict")
else:
Expand Down
8 changes: 6 additions & 2 deletions dripline/core/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,12 @@ def log_interval(self, new_interval):
raise ThrowReply('service_error_invalid_value', f"unable to interpret a new_interval of type <{type(new_interval)}>")

def scheduled_log(self):
logger.debug("in a scheduled log event")
result = self.on_get()
logger.debug(f"in a scheduled log event for {self.name}")
try:
result = self.on_get()
except ThrowReply as err:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels overly broad --- all thrown exceptions are turned into warnings in the log file. There's no way to have an actual error that results in an error reply. And no information about the failure is passed back to the user.

Do we perhaps want to consider something where the on_get() function returns an optional warning/error message? This could be passed back to the user in the reply message, perhaps using a warning return code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the scheduled_log method, so by construction nothing can be passed as a reply because there is neither user initiator nor reply. This action is happening according to the scheduler (should only route through https://github.com/driplineorg/dripline-python/blob/develop/dripline/core/entity.py#L223). That was my logic for putting a very broad catch here.

I thought it better to handle it here so that the service continues running, guaranteed. Rather than messing with the on_get() method, where we could worry about intercepting what gets returned in the user reply (for example, users with dl_agent or queries that are part of a cmd would not be passing through this part of the code).

But maybe I'm missing something.

logger.warning(f'scheduled log failed with error:\n{err}')
return
try:
this_value = float(result[self._check_field])
is_float = True
Expand Down