diff --git a/.gitignore b/.gitignore index 3e243e7..8129439 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ doc/_build/ *.log /snews_cs/hop_sub.py /snews_cs/slack_alert.py -/snews_cs/auxiliary/test-config.env +/snews_cs/etc/test-config.env firedrill.ipynb server_run_me.py *.db diff --git a/README.md b/README.md index 58c589a..41ee128 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ The backend tools that needs to run in order for the observation messages to be The **observation messages** submitted to a given kafka topic using the [SNEWS Publishing Tools](https://github.com/SNEWS2/SNEWS_Publishing_Tools). The SNEWS Coincidence System listen this topic and caches all the messages submitted. These messages then assigned to different _sublists_ depending on their `neutrino_time`. -The first message in the stream makes the first sublist as `sublist=0`, and sets the coincidence window. Next, the second message is compared against the first and if the `neutrino_time` differences are less than the defined `coincidence_threshold` ([default](https://github.com/SNEWS2/SNEWS_Coincidence_System/blob/main/snews_cs/auxiliary/test-config.env) is 10sec) it is added to the same _sublist_ and an alert is triggered. This alert is sent to all subscribed users through the Kafka Alert Channels, and a slack bot message is published on the relavant SNEWS Slack channel. In case if the second message is earlier than the first one and there were no alerts triggered before (the first message was alone), then the second message is replaced as the _initial message_ of that sublist and the coincidence window is started from the neutrino time of the second message. The alert is still published. +The first message in the stream makes the first sublist as `sublist=0`, and sets the coincidence window. Next, the second message is compared against the first and if the `neutrino_time` differences are less than the defined `coincidence_threshold` ([default](https://github.com/SNEWS2/SNEWS_Coincidence_System/blob/main/snews_cs/etc/test-config.env) is 10sec) it is added to the same _sublist_ and an alert is triggered. This alert is sent to all subscribed users through the Kafka Alert Channels, and a slack bot message is published on the relavant SNEWS Slack channel. In case if the second message is earlier than the first one and there were no alerts triggered before (the first message was alone), then the second message is replaced as the _initial message_ of that sublist and the coincidence window is started from the neutrino time of the second message. The alert is still published. If there are more incoming observation messages, they are compared against the _initial message_ of each sublist i.e. if the neutrino time difference of the 3rd (or later) messages are within +10 seconds they are added to the same sublist, and another alert message is published, only this time stating that it is an **"UPDATE"** on the previous alert message. diff --git a/doc/user/quickstart.md b/doc/user/quickstart.md index a5f6c18..6e4e9c8 100644 --- a/doc/user/quickstart.md +++ b/doc/user/quickstart.md @@ -6,7 +6,7 @@ The backend tools that needs to run in order for the observation messages to be The **observation messages** submitted to a given kafka topic using the [SNEWS Publishing Tools](https://github.com/SNEWS2/SNEWS_Publishing_Tools). The SNEWS Coincidence System listen this topic and caches all the messages submitted. These messages then assigned to different _sublists_ depending on their `neutrino_time`. -The first message in the stream makes the first sublist as `sublist=0`, and sets the coincidence window. Next, the second message is compared against the first and if the `neutrino_time` differences are less than the defined `coincidence_threshold` ([default](https://github.com/SNEWS2/SNEWS_Coincidence_System/blob/main/snews_cs/auxiliary/test-config.env) is 10sec) it is added to the same _sublist_ and an alert is triggered. This alert is sent to all subscribed users through the Kafka Alert Channels, and a slack bot message is published on the relavant SNEWS Slack channel. In case if the second message is earlier than the first one and there were no alerts triggered before (the first message was alone), then the second message is replaced as the _initial message_ of that sublist and the coincidence window is started from the neutrino time of the second message. The alert is still published. +The first message in the stream makes the first sublist as `sublist=0`, and sets the coincidence window. Next, the second message is compared against the first and if the `neutrino_time` differences are less than the defined `coincidence_threshold` ([default](https://github.com/SNEWS2/SNEWS_Coincidence_System/blob/main/snews_cs/etc/test-config.env) is 10sec) it is added to the same _sublist_ and an alert is triggered. This alert is sent to all subscribed users through the Kafka Alert Channels, and a slack bot message is published on the relavant SNEWS Slack channel. In case if the second message is earlier than the first one and there were no alerts triggered before (the first message was alone), then the second message is replaced as the _initial message_ of that sublist and the coincidence window is started from the neutrino time of the second message. The alert is still published. If there are more incoming observation messages, they are compared against the _initial message_ of each sublist i.e. if the neutrino time difference of the 3rd (or later) messages are within +10 seconds they are added to the same sublist, and another alert message is published, only this time stating that it is an **"UPDATE"** on the previous alert message. diff --git a/setup.cfg b/setup.cfg index cedbc8a..e31b6a0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,4 +9,4 @@ keywords = packages = SNEWS_CS data_files = - auxiliary/ = ./auxiliary/* + etc/ = ./etc/* diff --git a/snews_cs/__main__.py b/snews_cs/__main__.py index ad772bd..ab8cddd 100644 --- a/snews_cs/__main__.py +++ b/snews_cs/__main__.py @@ -19,8 +19,8 @@ @click.group(invoke_without_command=True) @click.version_option(__version__) @click.option('--env', type=str, - default='/auxiliary/test-config.env', - show_default='auxiliary/test-config.env', + default='/etc/test-config.env', + show_default='etc/test-config.env', help='environment file containing the configurations') @click.pass_context def main(ctx, env): @@ -67,4 +67,4 @@ def run_feedback(verbose): if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/snews_cs/cs_alert_schema.py b/snews_cs/cs_alert_schema.py index 7d1e96c..1030568 100644 --- a/snews_cs/cs_alert_schema.py +++ b/snews_cs/cs_alert_schema.py @@ -8,7 +8,7 @@ class CoincidenceTierAlert: ---------- env_path : `str`, optional The path containing the environment configuration file - If None, uses the default file in '/auxiliary/test-config.env' + If None, uses the default file in '/etc/test-config.env' """ diff --git a/snews_cs/cs_email.py b/snews_cs/cs_email.py index 82d2292..5cbbd43 100644 --- a/snews_cs/cs_email.py +++ b/snews_cs/cs_email.py @@ -27,7 +27,7 @@ if os.getenv("smtp_server_addr") is not None: smtpserver = os.getenv("smtp_server_addr") -contact_list_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'auxiliary/contact_list.json')) +contact_list_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'etc/contact_list.json')) with open(contact_list_file) as file: contact_list = json.load(file) diff --git a/snews_cs/cs_remote_commands.py b/snews_cs/cs_remote_commands.py index ffd9c20..aa29348 100644 --- a/snews_cs/cs_remote_commands.py +++ b/snews_cs/cs_remote_commands.py @@ -28,7 +28,7 @@ "Get-Feedback" ] -contact_list_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'auxiliary/contact_list.json')) +contact_list_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'etc/contact_list.json')) with open(contact_list_file) as file: contact_list = json.load(file) diff --git a/snews_cs/cs_utils.py b/snews_cs/cs_utils.py index 9d750c3..67ee696 100644 --- a/snews_cs/cs_utils.py +++ b/snews_cs/cs_utils.py @@ -14,7 +14,7 @@ def set_env(env_path=None): Use default settings if not given """ - default_env_path = os.path.dirname(__file__) + '/auxiliary/test-config.env' + default_env_path = os.path.dirname(__file__) + '/etc/test-config.env' env = env_path or default_env_path load_dotenv(env) diff --git a/snews_cs/auxiliary/contact_list.json b/snews_cs/etc/contact_list.json similarity index 100% rename from snews_cs/auxiliary/contact_list.json rename to snews_cs/etc/contact_list.json diff --git a/snews_cs/auxiliary/detector_properties.json b/snews_cs/etc/detector_properties.json similarity index 100% rename from snews_cs/auxiliary/detector_properties.json rename to snews_cs/etc/detector_properties.json diff --git a/snews_cs/auxiliary/make_detector_file.py b/snews_cs/etc/make_detector_file.py similarity index 100% rename from snews_cs/auxiliary/make_detector_file.py rename to snews_cs/etc/make_detector_file.py diff --git a/snews_cs/auxiliary/snalert.gif b/snews_cs/etc/snalert.gif similarity index 100% rename from snews_cs/auxiliary/snalert.gif rename to snews_cs/etc/snalert.gif diff --git a/snews_cs/auxiliary/test-config.env b/snews_cs/etc/test-config.env similarity index 97% rename from snews_cs/auxiliary/test-config.env rename to snews_cs/etc/test-config.env index 5afd59f..8561a07 100644 --- a/snews_cs/auxiliary/test-config.env +++ b/snews_cs/etc/test-config.env @@ -10,7 +10,7 @@ MSG_EXPIRATION=120 # HB configs STORE_HEARTBEAT="True" -HB_STASH_TIME="24" # hours +#HB_STASH_TIME="24" # hours HB_DELETE_AFTER="7" # days # Send heartbeats from the following email diff --git a/snews_cs/auxiliary/update_image.png b/snews_cs/etc/update_image.png similarity index 100% rename from snews_cs/auxiliary/update_image.png rename to snews_cs/etc/update_image.png diff --git a/snews_cs/heartbeat_feedbacks.py b/snews_cs/heartbeat_feedbacks.py index e54f296..f364864 100644 --- a/snews_cs/heartbeat_feedbacks.py +++ b/snews_cs/heartbeat_feedbacks.py @@ -12,12 +12,12 @@ log = getLogger(__name__) -contact_list_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'auxiliary/contact_list.json')) +contact_list_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'etc/contact_list.json')) with open(contact_list_file) as file: contact_list = json.load(file) # Check if detector name is in registered list. -detector_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'auxiliary/detector_properties.json')) +detector_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'etc/detector_properties.json')) with open(detector_file) as file: snews_detectors = json.load(file) snews_detectors = list(snews_detectors.keys()) diff --git a/snews_cs/snews_bot.py b/snews_cs/snews_bot.py index 5f7c349..84dd59f 100644 --- a/snews_cs/snews_bot.py +++ b/snews_cs/snews_bot.py @@ -40,10 +40,10 @@ def get_image(is_test, alert_data, topic): header = f"{test} *SUPERNOVA ALERT* {alert_type}".center(60, '=')+topic_str+f"{tag}" + \ f"> False Alarm Probability= *{falseprob}*\n> Issued from {server}" - giflink = "https://raw.githubusercontent.com/SNEWS2/SNEWS_Coincidence_System/main/snews_cs/auxiliary/snalert.gif" + giflink = "https://raw.githubusercontent.com/SNEWS2/SNEWS_Coincidence_System/main/snews_cs/etc/snalert.gif" retractlink = "https://www.shutterstock.com/image-vector/ooops-word-bubble-pop-art-600w-408777070.jpg" updatelink = "https://www.shutterstock.com/image-vector/vector-illustration-modern-label-new-600w-1520423249.jpg" - # updatelink = "https://raw.githubusercontent.com/SNEWS2/SNEWS_Coincidence_System/main/snews_cs/auxiliary/update_image.png" + # updatelink = "https://raw.githubusercontent.com/SNEWS2/SNEWS_Coincidence_System/main/snews_cs/etc/update_image.png" #"https://www.ris.world/wp-content/uploads/2018/09/update.jpg" sendlink = giflink if alert_type=="NEW_MESSAGE" else (updatelink if alert_type=="UPDATE" else retractlink) diff --git a/snews_cs/snews_coinc.py b/snews_cs/snews_coinc.py index d622ac5..d5c55e7 100644 --- a/snews_cs/snews_coinc.py +++ b/snews_cs/snews_coinc.py @@ -382,7 +382,7 @@ def __init__(self, env_path=None, drop_db=False, firedrill_mode=True, hb_path=No Parameters ---------- env_path : `str` - path to env file, defaults to '/auxiliary/test-config.env' + path to env file, defaults to '/etc/test-config.env' send_slack: `bool` Whether to send alerts on slack diff --git a/snews_cs/snews_hb.py b/snews_cs/snews_hb.py index 3f15e80..7da13ba 100644 --- a/snews_cs/snews_hb.py +++ b/snews_cs/snews_hb.py @@ -15,7 +15,7 @@ log = getLogger(__name__) # Check if detector name is in registered list. -detector_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'auxiliary/detector_properties.json')) +detector_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'etc/detector_properties.json')) with open(detector_file) as file: snews_detectors = json.load(file) diff --git a/snews_cs/snews_sql.py b/snews_cs/snews_sql.py index 6b29fce..b62da66 100644 --- a/snews_cs/snews_sql.py +++ b/snews_cs/snews_sql.py @@ -22,7 +22,7 @@ class Storage: Parameters ---------- env : `str`, optional - Path to env file, defaults to './auxiliary/test-config.env' + Path to env file, defaults to './etc/test-config.env' drop_db : `bool`, optional drops all items in the DB every time Storage is initialized, defaults to False