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

Support MAUDE telemetry for events #343

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4bfc70b
Add --maude cmd line arg and improve cmd line handling
taldcroft Dec 4, 2024
c74e620
Add TlmEvent method get_sample_period_max
taldcroft Dec 4, 2024
a5252c0
Use MAUDE for telemetry for --maude
taldcroft Dec 4, 2024
e5c1dec
Update get_events_and_event_models
taldcroft Dec 4, 2024
952d3e4
Do not fetch unnecessary telemetry
taldcroft Dec 4, 2024
e2fb220
Factor out get_sample_period_max as a function not method
taldcroft Dec 5, 2024
61eb190
Replace deprecated logger.warn with logger.warning
taldcroft Dec 5, 2024
bd1ed03
Limit MAUDE telemetry fetches start and stop
taldcroft Dec 6, 2024
4980531
More progress
taldcroft Dec 10, 2024
c3c627c
Fix issue from trailing space in CXC state values
taldcroft Dec 14, 2024
3c65049
Use ska_helpers.logging for logging
taldcroft Dec 14, 2024
6134463
Add maude-tlm-lookback command arg
taldcroft Dec 16, 2024
0c77759
Fix issues uncovered in regression testing
taldcroft Dec 16, 2024
1347601
Events regression testing scripts
taldcroft Dec 16, 2024
945310b
Minor Improvements to events validation scripts
taldcroft Jan 6, 2025
c7ac9b2
Enforce PLW2901 - do not redefine loop variable for new code
taldcroft Jan 7, 2025
9c6a216
Also write events as human-readable .dat
taldcroft Jan 7, 2025
c088c00
Update precommit
taldcroft Jan 7, 2025
301bb65
Add notebook for SCS-107 detection
taldcroft Jan 8, 2025
34d7e1d
Remove fuzzing in Normal/Safe Suns
taldcroft Jan 8, 2025
b7333aa
Fix bug in from_dict setting obsid
taldcroft Jan 8, 2025
73acb0a
Handle corrupted COBSRQID values
taldcroft Jan 8, 2025
3544b91
Detect SCS107 event using RW bias disable only
taldcroft Jan 8, 2025
f33faee
Improve compare_events
taldcroft Jan 8, 2025
130eb5a
Refactor TlmEvent-specific code from from_dict()
taldcroft Jan 8, 2025
91181cb
Require minimum 100s for eclipses
taldcroft Jan 9, 2025
671bc93
Add shell script commands for functional testing of events PR#343
taldcroft Jan 27, 2025
0389536
Update pre-commit
taldcroft Jan 27, 2025
23e8fc4
ruff format
taldcroft Jan 27, 2025
023a568
Update task schedules
taldcroft Jan 30, 2025
0e050ae
Move check_cron process into separate config file
taldcroft Feb 2, 2025
b480bb9
Update task_schedules
taldcroft Feb 3, 2025
2510ec5
Send check_cron alerts to aca@cfa
taldcroft Feb 3, 2025
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.2
rev: v0.9.0
hooks:
# Run the linter.
- id: ruff
Expand Down
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 @@ -259,7 +259,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
12 changes: 6 additions & 6 deletions kadi/commands/commands_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def update_archive_and_get_cmds_recent(

# Update loads table and download/archive backstop files from OCCweb
loads = update_loads(scenario, cmd_events=cmd_events, lookback=lookback, stop=stop)
logger.info(f'Including loads {", ".join(loads["name"])}')
logger.info(f"Including loads {', '.join(loads['name'])}")

for load in loads:
load_name = load["name"]
Expand Down Expand Up @@ -437,7 +437,7 @@ def update_archive_and_get_cmds_recent(
logger.info(f"Processing {cmds_source} with {len(cmds)} commands")
end_scs = collections.defaultdict(list)
if date_end := cmds.meta.get("rltt"):
source = f'RLTT in {cmds["source"][0]}'
source = f"RLTT in {cmds['source'][0]}"
end_scs[date_end, source].extend([128, 129, 130, 131, 132, 133])

# Explicit END SCS commands. Most commonly these come from command events
Expand All @@ -447,7 +447,7 @@ def update_archive_and_get_cmds_recent(
if np.any(ok):
for cmd in cmds[ok]:
if (scs := cmd["params"]["codisas1"]) >= 128:
source = f'DISABLE SCS in {cmd["source"]} at {cmd["date"]}'
source = f"DISABLE SCS in {cmd['source']} at {cmd['date']}"
end_scs[cmd["date"], source].append(scs)

for (date_end, source), scss in end_scs.items():
Expand All @@ -465,7 +465,7 @@ def update_archive_and_get_cmds_recent(
n_bad = np.count_nonzero(bad)
logger.info(
f"Removing {n_bad} cmds in SCS slots {scss} from "
f'{prev_cmds["source"][0]} due to {source}'
f"{prev_cmds['source'][0]} due to {source}"
)
cmds_list[jj] = prev_cmds[~bad]

Expand Down Expand Up @@ -654,15 +654,15 @@ def get_cmds_obs_from_manvrs(cmds, prev_att=None):
npnt_enab = False
if targ_att is None:
# No target attitude is unexpected since we got to a MANVR cmd.
logger.warning(f'WARNING: no target attitude for {cmd["date"]}')
logger.warning(f"WARNING: no target attitude for {cmd['date']}")
log_context_obs(cmds, cmd)
continue
if prev_att is None:
# No previous attitude happens always for first manvr at the
# beginning of loads, and normally we just push on to the next
# OBS. But if we already have OBS command this is a problem.
if cmds_obs:
logger.warning(f'WARNING: No previous attitude for {cmd["date"]}')
logger.warning(f"WARNING: No previous attitude for {cmd['date']}")
log_context_obs(cmds, cmd)
prev_att = targ_att
continue
Expand Down
12 changes: 6 additions & 6 deletions kadi/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,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 @@ -892,7 +892,7 @@ def pformat_like_backstop(
fmt = "{}={}"
fmtvals.append(fmt.format(key, val))

fmtvals.append(f'scs={cmd["scs"]}')
fmtvals.append(f"scs={cmd['scs']}")

params_str = ", ".join(fmtvals)
else:
Expand Down Expand Up @@ -1016,16 +1016,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 @@ -173,7 +173,7 @@ def test_validate_regression(cls, no_exclude, fast_sun_position_method, regress_
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 @@ -43,6 +43,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