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

Fritzscan #84

Merged
merged 19 commits into from
Aug 5, 2022
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
first pass at api manager
  • Loading branch information
sukishore12 committed Aug 4, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 39737e2bac08702bfdf240e06f3bad8722543dc5
37 changes: 37 additions & 0 deletions winterdrp/processors/send_to_fritz.py
Original file line number Diff line number Diff line change
@@ -102,6 +102,7 @@ def _get_fritz_token():
self.session.mount("https://", adapter)
self.session.mount("http://", adapter)
self.origin = base_name # used for sending updates to Fritz
self.verbose = verbose

def _apply_to_candidates(
self,
@@ -749,6 +750,42 @@ def alert_skyportal_manager(self, alert):

logger.info(f'======== Manager complete for {alert["objectId"]} =======')

def alert_skyportal_manager(self, alert):
"""Posts alerts to SkyPortal if criteria is met

:param alert: _description_
:type alert: _type_
"""
# check if candidate/source exists in SkyPortal
# log.info(f"Checking if {alert['objectId']} is candidate in SkyPortal")
with timer(
f"Checking if {alert['objectId']} is candidate in SkyPortal",
self.verbose > 1,
):
response = self.api(
"HEAD", f"https://fritz.science/api/candidates/{alert['objectId']}"
)
is_candidate = response.status_code == 200

# logger.info(f"{alert['objectId']} {'is' if is_candidate else 'is not'} candidate in SkyPortal")
if self.verbose > 1:
log(
f"{alert['objectId']} {'is' if is_candidate else 'is not'} candidate in SkyPortal"
)
# logger.info(f"Checking if {alert['objectId']} is source in SkyPortal")
with timer(
f"Checking if {alert['objectId']} is source in SkyPortal", self.verbose > 1
):
response = self.api("HEAD", f"https://fritz.science/api/sources/{alert['objectId']}")
is_source = response.status_code == 200
log(
f"{alert['objectId']} {'is' if is_source else 'is not'} source in SkyPortal"
)
if self.verbose > 1:
log(
f"{alert['objectId']} {'is' if is_source else 'is not'} source in SkyPortal"
)

def make_alert(self, cand_table):
t0 = time.time()
all_cands = self.read_input_df(cand_table)