Skip to content

Commit

Permalink
slackbot tries to download results from DESY cloud if not told otherw…
Browse files Browse the repository at this point in the history
…ise with -rerun or -nodl
  • Loading branch information
simeonreusch committed May 6, 2023
1 parent c566b90 commit 74d0f39
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
16 changes: 14 additions & 2 deletions slackbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
from pathlib import Path

from astropy.time import Time # type: ignore
from slack import WebClient # type: ignore

from nuztf.neutrino_scanner import NeutrinoScanner
from nuztf.skymap import EventNotFound
from nuztf.skymap_scanner import SkymapScanner
from slack import WebClient # type: ignore

logging.basicConfig()

Expand Down Expand Up @@ -41,13 +42,15 @@ def __init__(
ts,
name: str,
event_type: str,
dl_results: bool = False,
do_gcn: bool = False,
time_window: int | None = None,
):
self.channel = channel
self.ts = ts
self.name = name
self.event_type = event_type
self.dl_results = dl_results
self.logger = logging.getLogger(__name__)
self.logger.setLevel(logging.DEBUG)
self.webclient = WebClient(token=os.environ.get("SLACK_TOKEN"))
Expand Down Expand Up @@ -76,7 +79,16 @@ def __init__(
self.scanner.logger = SlackLogHandler(
channel=self.channel, ts=self.ts, webclient=self.webclient
)
self.scanner.scan_area(t_max=self.scanner.t_min + self.time_window)

if self.event_type == "nu":
self.scanner.scan_area(t_max=self.scanner.t_min + self.time_window)

elif self.event_type == "gw":
if self.dl_results:
self.scanner.download_results()
else:
self.scanner.get_alerts()
self.scanner.filter_alerts()

scan_message = "Scanning done."

Expand Down
8 changes: 7 additions & 1 deletion slackbot_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

from flask import Flask # type: ignore
from slack import WebClient # type: ignore
from slackeventsapi import SlackEventAdapter # type: ignore

from nuztf.utils import is_icecube_name, is_ligo_name
from slackbot import Slackbot
from slackeventsapi import SlackEventAdapter # type: ignore

nuztf_slackbot = Flask(__name__)

Expand All @@ -24,6 +24,7 @@ def scan(
channel: str,
ts: str,
name: str,
dl_results: bool,
event_type: str,
do_gcn: bool,
time_window: int | None,
Expand All @@ -33,6 +34,7 @@ def scan(
channel=channel,
ts=ts,
name=name,
dl_results=dl_results,
event_type=event_type,
do_gcn=do_gcn,
time_window=time_window,
Expand Down Expand Up @@ -112,10 +114,13 @@ def message(payload):
return

time_window = None
dl_results = True

for i, parameter in enumerate(split_text):
if parameter in fuzzy_parameters(["gcn", "GCN"]):
do_gcn = True
elif parameter in fuzzy_parameters(["rerun", "nodl"]):
dl_results = False
elif parameter in fuzzy_parameters(
["window", "timewindow", "time-window"]
):
Expand Down Expand Up @@ -156,6 +161,7 @@ def message(payload):
channel=channel_id,
ts=ts,
name=name,
dl_results=dl_results,
event_type=event_type,
do_gcn=do_gcn,
time_window=time_window,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_skymap_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_gw_scan_desy_download(self):

scanner.download_results()

n_expected_candidates = 122
n_expected_candidates = 13

n_retrieved_candidates = len(scanner.final_candidates)

Expand Down

0 comments on commit 74d0f39

Please sign in to comment.