Commit 2d9d300e authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

add utils

parent 7992adb4
import numpy as np import numpy as np
from csst_dag import CSST_DAG_LIST, Redis from csst_dag import CSST_DAG_LIST, Redis, dump_message_list
from csst_dag.constants import MSC_MBI_CHIPID from csst_dag.constants import MSC_MBI_CHIPID
# set BATCH_ID and DATASET # set BATCH_ID and DATASET
...@@ -28,6 +28,14 @@ for this_obsid in OBSID_LIST_CORRECTED: ...@@ -28,6 +28,14 @@ for this_obsid in OBSID_LIST_CORRECTED:
) )
message_list.append(this_message) message_list.append(this_message)
# push messages to redis # push messages to redis
for msg in message_list: for msg in message_list:
r.push(msg) r.push(msg)
print(f" N_message = {len(message_list)}")
print(f" N_in_redis = {len(r.get_all())}")
# dump messages
dump_message_list(message_list, path=f"batch/msc-v093/C9_W1_Phot.{BATCH_ID}")
# from .dag import gen_dag_run_id, gen_level1_dag_message, CSST_DAG_LIST # from .dag import gen_dag_run_id, gen_level1_dag_message, CSST_DAG_LIST
from .redis import Redis from .redis import Redis
from .dag import CSST_DAG_LIST # all DAGs from .dag import CSST_DAG_LIST # all DAGs
from .utils import dump_message_list
from .constants import MSC_MBI_CHIPID
import json
def dump_message_list(
messages,
path="",
):
with open(path + ".messages", "w+") as f:
for msg in messages:
f.write(msg + "\n")
with open(path + ".dag_run_id", "w+") as f:
for msg in messages:
f.write(json.loads(msg)["dag_run_id"] + "\n")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment