Skip to content

Commit

Permalink
Add test utility scripts and update test docs
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed Nov 15, 2024
1 parent 55cc376 commit 42fd7b4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
11 changes: 8 additions & 3 deletions make_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
cd ..
rsync -av t_now/ /proj/sot/ska/www/ASPECT_ICXC/test_review_outputs/arc/${PR}/t_now/
diff t_now/{flight,$COMMIT}/timeline_states.js
Local
-----
Testing on a local machine (Mac) requires syncing the data files from kady. This tests
Expand All @@ -62,11 +64,11 @@
Get the flight run date and convert that to a full date-format date (e.g. "317/1211z"
=> "2024:317:12:11:00")::
tail -c 400 t_now/flight/timeline_states.js | grep now_date
DATE_NOW=`python utils/get_date_now.py t_now/flight`
Run the script with the test option::
python make_timeline.py --test --data-dir=t_now/$COMMIT --date-now=<now_date>
python make_timeline.py --test --data-dir=t_now/$COMMIT --date-now=$DATE_NOW
To view the output, open the directory in a browser::
Expand All @@ -75,7 +77,10 @@
Compare the timeline_states.js files::
diff t_now/{flight,$COMMIT}/timeline_states.js
python utils/convert_states_to_yaml.py t_now/$COMMIT
python utils/convert_states_to_yaml.py t_now/flight
diff t_now/{flight,$COMMIT}/timeline_states.yaml
"""

import argparse
Expand Down
12 changes: 12 additions & 0 deletions utils/convert_states_to_yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Convert timeline_states.js to YAML timeline_states.yaml for easier comparison."""

import json
import sys
from pathlib import Path

import yaml

data_dir = sys.argv[1]
text = Path(f"{data_dir}/timeline_states.js").read_text()
states = json.loads(text[11:])
yaml.dump(states, open(f"{data_dir}/timeline_states.yaml", "w"))
19 changes: 19 additions & 0 deletions utils/get_date_now.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Convert the now_date from timeline_states.js to a CxoTime date string."""

import json
import sys
from pathlib import Path

from cxotime import CxoTime

data_dir = sys.argv[1]
text = Path(f"{data_dir}/timeline_states.js").read_text()
data = json.loads(text[11:])

# Get date like "319/1215z"
now_date = data["now_date"]
year = CxoTime.now().date[:4]

# Convert now_date to "{year}:319:12:15:00"
date = f"{year}:{now_date[0:3]}:{now_date[4:6]}:{now_date[6:8]}:00"
print(date)

0 comments on commit 42fd7b4

Please sign in to comment.