Skip to content

Commit

Permalink
Merge pull request #343 from sot/support-maude-telemetry-for-events
Browse files Browse the repository at this point in the history
Support MAUDE telemetry for events
  • Loading branch information
taldcroft authored Feb 20, 2025
2 parents 5aefbdd + d388bcc commit d97dd60
Show file tree
Hide file tree
Showing 18 changed files with 1,121 additions and 153 deletions.
4 changes: 2 additions & 2 deletions kadi/cmds/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ def _find(start=None, stop=None, **kwargs):
if stop:
ok &= idx_cmds["date"] < DateTime(stop).date
for key, val in kwargs.items():
key = key.lower()
key = key.lower() # noqa: PLW2901
if isinstance(val, str):
val = val.upper()
val = val.upper() # noqa: PLW2901
if key in idx_cmds.dtype.names:
ok &= idx_cmds[key] == val
else:
Expand Down
2 changes: 1 addition & 1 deletion kadi/commands/command_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def get_cmds_from_event(date, event, params_str):
for step, cmd in enumerate(cmds):
# Force CommandTable row to be a dict
if not isinstance(cmd, dict):
cmd = {name: cmd[name] for name in cmd.colnames}
cmd = {name: cmd[name] for name in cmd.colnames} # noqa: PLW2901

# Get command duration (if any). If the cmd is only {'dur': <dt>} then
# it is a pure delay so skip subsequent processing.
Expand Down
10 changes: 5 additions & 5 deletions kadi/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ def _find(
ok &= idx_cmds["date"] < CxoTime(stop).date

for key, val in kwargs.items():
key = key.lower()
key = key.lower() # noqa: PLW2901
if isinstance(val, str):
val = val.upper()
val = val.upper() # noqa: PLW2901
if key in idx_cmds.dtype.names:
ok &= idx_cmds[key] == val
else:
Expand Down Expand Up @@ -1017,16 +1017,16 @@ def remove_not_run_cmds(self):

# Now check that the params match.
idxs_match = []
for idx in idxs:
for idx_check in idxs:
# Get the intersection of the keys in cmd_not_run["params"] and self["params"][idx]
self_params = self["params"][idx]
self_params = self["params"][idx_check]
cmd_not_run_params = cmd_not_run["params"]
keys = set(cmd_not_run_params) & set(self_params)

# Check that the values match for all common keys
match = all(cmd_not_run_params[key] == self_params[key] for key in keys)
if match:
idxs_match.append(idx)
idxs_match.append(idx_check)

idxs_remove.update(idxs_match)

Expand Down
2 changes: 1 addition & 1 deletion kadi/commands/tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_validate_regression(
assert data_obs["vals_compressed"].keys() == data_exp["vals_compressed"].keys()

for key, vals_obs in data_obs["vals_compressed"].items():
vals_obs = np.asarray(vals_obs)
vals_obs = np.asarray(vals_obs) # noqa: PLW2901
vals_exp = np.asarray(data_exp["vals_compressed"][key])
assert vals_obs.shape == vals_exp.shape
assert vals_obs.dtype.kind == vals_exp.dtype.kind
Expand Down
2 changes: 2 additions & 0 deletions kadi/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
import importlib
import os

import ska_helpers.logging

# In addition, set DJANGO_ALLOW_ASYNC_UNSAFE, to avoid exception seen running in
# Jupyter notebook: SynchronousOnlyOperation: You cannot call this from an async
# context. See: https://stackoverflow.com/questions/59119396
Expand Down
Loading

0 comments on commit d97dd60

Please sign in to comment.