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

DM-43522:Remove too large alert packet write to disk #202

Merged
merged 3 commits into from
Mar 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions python/lsst/ap/association/packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ class PackageAlertsConfig(pexConfig.Config):
default=False,
)

doWriteFailedAlerts = pexConfig.Field(
dtype=bool,
doc="Write alerts which fail to send to disk for debugging purposes.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth mentioning that this option is only used if doProduceAlerts, and is independent of doWriteAlerts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find the wording a bit hard to parse; maybe:

Suggested change
doc="Write alerts which fail to send to disk for debugging purposes.",
doc="If an alert cannot be sent, write it to disk for debugging purposes.",

default=False,
)


class PackageAlertsTask(pipeBase.Task):
"""Tasks for packaging Dia and Pipelines data into Avro alert packages.
Expand Down Expand Up @@ -320,9 +326,11 @@ def produceAlerts(self, alerts, ccdVisitId):

except KafkaException as e:
self.log.warning('Kafka error: {}, message was {} bytes'.format(e, sys.getsizeof(alertBytes)))
with open(os.path.join(self.config.alertWriteLocation,
f"{ccdVisitId}_{alert['alertId']}.avro"), "wb") as f:
f.write(alertBytes)

if self.config.doWriteFailedAlerts:
with open(os.path.join(self.config.alertWriteLocation,
f"{ccdVisitId}_{alert['alertId']}.avro"), "wb") as f:
f.write(alertBytes)

self.producer.flush()

Expand Down