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

feat: created a flag to make the mjd filtering optional in lc step #267

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions charts/lightcurve-step/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ data:
sql-secret-name: {{ .Values.configmap.psqlSecretName }}
mongo-secret: {{ .Values.configmap.mongoSecret }}
logging-debug: "{{ .Values.configmap.loggingDebug }}"
skip-mjd-filter: "{{ .Values.configmap.skipMjdFilter }}"
5 changes: 5 additions & 0 deletions charts/lightcurve-step/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ spec:
configMapKeyRef:
name: {{ include "lightcurve-step.fullname" . }}
key: logging-debug
- name: SKIP_MJD_FILTER
valueFrom:
configMapKeyRef:
name: {{ include "lightcurve-step.fullname" . }}
key: skip-mjd-filter
{{- if .Values.secrets.kafkaAuth.consumer.enabled }}
- name: CONSUMER_KAFKA_USERNAME
valueFrom:
Expand Down
1 change: 1 addition & 0 deletions charts/lightcurve-step/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ configmap:
useProfiling: ""
mongoSecret: ""
pyroscopeServer: "http://pyroscope.pyroscope:4040"
skipMjdFilter: ""

secrets:
kafkaAuth:
Expand Down
4 changes: 1 addition & 3 deletions correction_step/correction/_step/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from pprint import pprint


class CorrectionStep(GenericStep):
"""Step that applies magnitude correction to new alert and previous candidates.

Expand Down Expand Up @@ -90,13 +91,10 @@ def pre_execute(cls, messages: list[dict]) -> dict:

@classmethod
def execute(cls, message: dict) -> dict:
pprint(message)
corrector = Corrector(message["detections"])
detections = corrector.corrected_as_records()
non_detections = pd.DataFrame(message["non_detections"]).drop_duplicates(["oid", "fid", "mjd"])
coords = corrector.coordinates_as_records()
# delet dis
pprint(coords)
return {
"detections": detections,
"non_detections": non_detections.to_dict("records"),
Expand Down
7 changes: 5 additions & 2 deletions lightcurve-step/lightcurve_step/step.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import numpy as np
import os
import pandas as pd
import pickle
from typing import List
Expand Down Expand Up @@ -53,6 +54,7 @@ def pre_execute(cls, messages: List[dict]) -> dict:
last_mjds[aid] = max(last_mjds.get(aid, 0), msg["detections"][0]["mjd"])
detections.extend([det | {"new": True} for det in msg["detections"]])
non_detections.extend(msg["non_detections"])

logger = logging.getLogger("alerce.LightcurveStep")
logger.debug(f"Received {len(detections)} detections from messages")
return {
Expand Down Expand Up @@ -231,8 +233,9 @@ def serialize_dia_object(ef: dict):
except KeyError:
nd = []
dets["extra_fields"] = dets["extra_fields"].apply(serialize_dia_object)
mjds = result["last_mjds"]
dets = dets[dets["mjd"] <= mjds[aid]]
if not os.getenv("SKIP_MJD_FILTER", "false") == "true":
mjds = result["last_mjds"]
dets = dets[dets["mjd"] <= mjds[aid]]
output.append(
{
"aid": aid,
Expand Down